Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/13 13:13:41 (12 years ago)
Author:
spimming
Message:

#1888:

  • Merged revisions from trunk
Location:
branches/OaaS
Files:
2 deleted
10 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/OaaS

  • branches/OaaS/HeuristicLab.Persistence

  • branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/StringExtensions.cs

    r4068 r9363  
    1 using System.Collections.Generic;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System.Collections.Generic;
    223
    324namespace HeuristicLab.Persistence.Auxiliary {
  • branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeLoader.cs

    r7259 r9363  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Reflection;
    2425using HeuristicLab.Persistence.Core;
     
    2627
    2728namespace HeuristicLab.Persistence.Auxiliary {
     29  internal class TypeLoader {
     30    #region Mono Compatibility
     31    private static TypeName cachedMonoRuntimeType;
     32    private static TypeName cachedWindowsRuntimeType;
     33    private static TypeName cachedMonoObjectEqualityComparerType;
     34    private static TypeName cachedWindowsObjectEqualityComparerType;
    2835
    29   internal class TypeLoader {
     36    private static bool MonoInstalled {
     37      get { return Type.GetType("Mono.Runtime") != null; }
     38    }
     39
     40    static TypeLoader() {
     41      // we use Int32 here because we get all the information about Mono's mscorlib and just have to change the class name
     42      cachedMonoRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName);
     43      cachedMonoRuntimeType = new TypeName(cachedMonoRuntimeType, "MonoType");
     44
     45      cachedWindowsRuntimeType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName);
     46      cachedWindowsRuntimeType = new TypeName(cachedWindowsRuntimeType, "RuntimeType");
     47
     48      // we need the information about the Persistence assembly, so we use TypeName here because it is contained in this assembly
     49      cachedMonoObjectEqualityComparerType = TypeNameParser.Parse(typeof(TypeName).AssemblyQualifiedName);
     50      cachedMonoObjectEqualityComparerType = new TypeName(cachedMonoObjectEqualityComparerType, "ObjectEqualityComparer", "HeuristicLab.Persistence.Mono");
     51
     52      cachedWindowsObjectEqualityComparerType = TypeNameParser.Parse(typeof(System.Int32).AssemblyQualifiedName);
     53      cachedWindowsObjectEqualityComparerType = new TypeName(cachedWindowsObjectEqualityComparerType, "ObjectEqualityComparer", "System.Collections.Generic");
     54    }
     55    #endregion
    3056
    3157    public static Type Load(string typeNameString) {
     58      TypeName typeName = null;
     59      try {
     60        typeName = TypeNameParser.Parse(typeNameString);
     61      }
     62      catch (Exception) {
     63        throw new PersistenceException(String.Format(
     64           "Could not parse type string \"{0}\"",
     65           typeNameString));
     66      }
     67
     68      try {
     69        // try to load type normally
     70        return LoadInternal(typeName);
     71      }
     72      catch (PersistenceException) {
     73        #region Mono Compatibility
     74        // if that fails, try to convert to the corresponding Mono or .NET type
     75        if (MonoInstalled) {
     76          typeName = GetMonoType(typeName);
     77          Logger.Info(String.Format(@"Trying to load Mono type ""{0}"" instead of .NET type ""{1}""",
     78                                    typeName, typeNameString));
     79        } else {
     80          typeName = GetDotNetType(typeName);
     81          Logger.Info(String.Format(@"Trying to load .NET type ""{0}"" instead of Mono type ""{1}""",
     82                                    typeName, typeNameString));
     83
     84        }
     85        return LoadInternal(typeName);
     86        #endregion
     87      }
     88    }
     89
     90    private static Type LoadInternal(TypeName typeName) {
    3291      Type type;
    3392      try {
    34         type = Type.GetType(typeNameString, true);
     93        type = Type.GetType(typeName.ToString(true, true), true);
    3594      }
    3695      catch (Exception) {
    3796        Logger.Warn(String.Format(
    38           "Cannot load type \"{0}\", falling back to partial name", typeNameString));
    39         try {
    40           TypeName typeName = TypeNameParser.Parse(typeNameString);
    41 #pragma warning disable 0618
    42           Assembly a = Assembly.LoadWithPartialName(typeName.AssemblyName);
    43           // the suggested Assembly.Load() method fails to load assemblies outside the GAC
    44 #pragma warning restore 0618
    45           type = a.GetType(typeName.ToString(false, false), true);
    46         }
    47         catch (Exception) {
    48           throw new PersistenceException(String.Format(
    49             "Could not load type \"{0}\"",
    50             typeNameString));
    51         }
    52         try {
    53           TypeName requestedTypeName = TypeNameParser.Parse(typeNameString);
    54           TypeName loadedTypeName = TypeNameParser.Parse(type.AssemblyQualifiedName);
    55           if (!requestedTypeName.IsCompatible(loadedTypeName))
    56             throw new PersistenceException(String.Format(
    57               "Serialized type is incompatible with available type: serialized: {0}, loaded: {1}",
    58               typeNameString,
    59               type.AssemblyQualifiedName));
    60           if (requestedTypeName.IsNewerThan(loadedTypeName))
    61             throw new PersistenceException(String.Format(
    62               "Serialized type is newer than available type: serialized: {0}, loaded: {1}",
    63               typeNameString,
    64               type.AssemblyQualifiedName));
    65         }
    66         catch (PersistenceException) {
    67           throw;
    68         }
    69         catch (Exception e) {
    70           Logger.Warn(String.Format(
    71             "Could not perform version check requested type was {0} while loaded type is {1}:",
    72             typeNameString,
    73             type.AssemblyQualifiedName),
    74             e);
    75         }
     97          "Cannot load type \"{0}\", falling back to partial name", typeName.ToString(true, true)));
     98        type = LoadWithPartialName(typeName);
     99        CheckCompatibility(typeName, type);
    76100      }
    77101      return type;
    78102    }
     103
     104    private static Type LoadWithPartialName(TypeName typeName) {
     105      try {
     106#pragma warning disable 0618
     107        Assembly a = Assembly.LoadWithPartialName(typeName.AssemblyName);
     108        // the suggested Assembly.Load() method fails to load assemblies outside the GAC
     109#pragma warning restore 0618
     110        return a.GetType(typeName.ToString(false, false), true);
     111      }
     112      catch (Exception) {
     113        throw new PersistenceException(String.Format(
     114          "Could not load type \"{0}\"",
     115          typeName.ToString(true, true)));
     116      }
     117    }
     118
     119    private static void CheckCompatibility(TypeName typeName, Type type) {
     120      try {
     121        TypeName loadedTypeName = TypeNameParser.Parse(type.AssemblyQualifiedName);
     122        if (!typeName.IsCompatible(loadedTypeName))
     123          throw new PersistenceException(String.Format(
     124            "Serialized type is incompatible with available type: serialized: {0}, loaded: {1}",
     125            typeName.ToString(true, true),
     126            type.AssemblyQualifiedName));
     127        if (typeName.IsNewerThan(loadedTypeName))
     128          throw new PersistenceException(String.Format(
     129            "Serialized type is newer than available type: serialized: {0}, loaded: {1}",
     130            typeName.ToString(true, true),
     131            type.AssemblyQualifiedName));
     132      }
     133      catch (PersistenceException) {
     134        throw;
     135      }
     136      catch (Exception e) {
     137        Logger.Warn(String.Format(
     138          "Could not perform version check requested type was {0} while loaded type is {1}:",
     139          typeName.ToString(true, true),
     140          type.AssemblyQualifiedName),
     141                    e);
     142      }
     143    }
     144
     145    #region Mono Compatibility
     146    /// <summary>
     147    /// Returns the corresponding type for the Mono runtime
     148    /// </summary>
     149    /// <returns>
     150    /// The remapped typeName, or the original typeName if no mapping was found
     151    /// </returns>
     152    private static TypeName GetMonoType(TypeName typeName) {
     153      // map System.RuntimeType to System.MonoType
     154      if (typeName.Namespace == "System" && typeName.ClassName == "RuntimeType") {
     155        return cachedMonoRuntimeType;
     156        // map System.Collections.Generic.ObjectEqualityComparer to HeuristicLab.Mono.ObjectEqualityComparer
     157      } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "ObjectEqualityComparer") {
     158        TypeName newTypeName = new TypeName(cachedMonoObjectEqualityComparerType);
     159        newTypeName.GenericArgs = new List<TypeName>(typeName.GenericArgs);
     160        return newTypeName;
     161      }
     162      return typeName;
     163    }
     164
     165    /// <summary>
     166    /// Returns the corresponding type for the .NET runtime
     167    /// </summary>
     168    /// <returns>
     169    /// The remapped typeName, or the original typeName if no mapping was found
     170    /// </returns>
     171    private static TypeName GetDotNetType(TypeName typeName) {
     172      // map System.MonoType to System.RuntimeType
     173      if (typeName.Namespace == "System" && typeName.ClassName == "MonoType") {
     174        return cachedWindowsRuntimeType;
     175        // maps Mono's string comparer to System.Collections.Generic.ObjectEqualityComparer<string>
     176      } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "InternalStringComparer") {
     177        TypeName newTypeName = new TypeName(cachedWindowsObjectEqualityComparerType);
     178        var genericArgsList = new List<TypeName>();
     179        genericArgsList.Add(new TypeName(typeof(String).Namespace, "String"));
     180        newTypeName.GenericArgs = genericArgsList;
     181        return newTypeName;
     182      } else if (typeName.Namespace == "System.Collections.Generic" && typeName.ClassName == "EqualityComparer+DefaultComparer") {
     183        TypeName newTypeName = new TypeName(cachedWindowsObjectEqualityComparerType);
     184        newTypeName.GenericArgs = new List<TypeName>(typeName.GenericArgs);
     185        return newTypeName;
     186      }
     187      return typeName;
     188    }
     189    #endregion
    79190  }
    80191}
  • branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs

    r7259 r9363  
    5151
    5252    /// <summary>
     53    /// Gets or sets the number of generic args for
     54    /// each class in a series of nested classes.
     55    /// </summary>
     56    [Storable]
     57    public List<int> GenericArgCounts { get; private set; }
     58
     59      /// <summary>
    5360    /// Gets or sets the generic args.
    5461    /// </summary>
     
    103110    /// <param name="nameSpace">The namespace.</param>
    104111    /// <param name="className">Name of the class.</param>
    105     internal TypeName(string nameSpace, string className) {
     112    internal TypeName(string nameSpace, string className, List<int> genericArgCounts=null) {
    106113      Namespace = nameSpace;
    107114      ClassName = className;
     
    109116      MemoryMagic = "";
    110117      AssemblyAttribues = new Dictionary<string, string>();
    111     }
    112 
     118      if (genericArgCounts != null)
     119        GenericArgCounts = genericArgCounts.ToList();
     120    }
     121
     122    internal TypeName(TypeName typeName, string className = null, string nameSpace = null) {
     123      Namespace = nameSpace ?? typeName.Namespace;
     124      ClassName = className ?? typeName.ClassName;
     125      GenericArgs = new List<TypeName>(typeName.GenericArgs);
     126      AssemblyAttribues = new Dictionary<string, string>(typeName.AssemblyAttribues);
     127      MemoryMagic = typeName.MemoryMagic;
     128      AssemblyName = typeName.AssemblyName;
     129      IsReference = typeName.IsReference;
     130      if (typeName.GenericArgCounts != null)
     131        GenericArgCounts = typeName.GenericArgCounts.ToList();
     132    }
    113133
    114134    /// <summary>
     
    135155    /// </returns>
    136156    public string ToString(bool full, bool includeAssembly) {
    137       StringBuilder sb = new StringBuilder();
     157      var sb = new StringBuilder();
    138158      if (!string.IsNullOrEmpty(Namespace))
    139159        sb.Append(Namespace).Append('.');
    140       sb.Append(ClassName);
     160      if (GenericArgCounts != null) {
     161        sb.Append(string.Join("+",
     162          ClassName
     163          .Split('+')
     164          .Zip(GenericArgCounts, (n, c) =>
     165            c > 0 ? String.Format("{0}`{1}", n, c) : n)));
     166      } else {
     167        sb.Append(ClassName);
     168        if (IsGeneric)
     169          sb.Append('`').Append(GenericArgs.Count);
     170      }
    141171      if (IsGeneric) {
    142         sb.Append('`').Append(GenericArgs.Count).Append('[');
    143         bool first = true;
    144         foreach (TypeName t in GenericArgs) {
    145           if (first)
    146             first = false;
    147           else
    148             sb.Append(',');
    149           sb.Append('[').Append(t.ToString(full)).Append(']');
    150         }
     172        sb.Append('[');
     173        sb.Append(String.Join(",", GenericArgs.Select(a =>
     174          string.Format("[{0}]", a.ToString(full)))));
    151175        sb.Append(']');
    152176      }
     
    161185    }
    162186
    163     public string GetTypeNameInCode(HashSet<string> omitNamespaces) {
    164       StringBuilder sb = new StringBuilder();
    165       if (!string.IsNullOrEmpty(Namespace) && omitNamespaces == null || !omitNamespaces.Contains(Namespace))
    166         sb.Append(Namespace).Append('.');
    167       sb.Append(ClassName);
    168       if (IsGeneric) {
    169         sb.Append("<");
    170         sb.Append(
    171           string.Join(", ",
    172             GenericArgs
    173               .Select(a => a.GetTypeNameInCode(omitNamespaces))
    174               .ToArray()));
    175         sb.Append(">");
     187    private IEnumerable<string> GetNestedClassesInCode(HashSet<string> omitNamespaces, bool includeAllNamespaces) {
     188      var i = 0;
     189      foreach (var pair in ClassName.Split('+').Zip(GenericArgCounts, (n, c) => new {n, c})) {
     190        if (pair.c == 0) {
     191          yield return pair.n;
     192        }
     193        else {
     194          yield return string.Format("{0}<{1}>",
     195            pair.n,
     196            string.Join(",",
     197              GenericArgs
     198                .GetRange(i, pair.c)
     199                .Select(a => a.GetTypeNameInCode(omitNamespaces, includeAllNamespaces))));
     200          i += pair.c;
     201        }
     202      }
     203    }
     204
     205    private string GetTypeNameInCode(HashSet<string> omitNamespaces, bool includeNamespaces) {
     206      var sb = new StringBuilder();
     207      if (!string.IsNullOrEmpty(Namespace) &&
     208            (omitNamespaces == null && includeNamespaces) ||
     209             omitNamespaces != null && !omitNamespaces.Contains(Namespace))
     210          sb.Append(Namespace).Append('.');
     211      if (GenericArgCounts != null) {
     212        sb.Append(string.Join(".", GetNestedClassesInCode(omitNamespaces, includeNamespaces)));
     213      } else {
     214        sb.Append(ClassName);
     215        if (IsGeneric) {
     216          sb.Append("<");
     217          sb.Append(
     218            string.Join(", ",
     219                        GenericArgs
     220                          .Select(a => a.GetTypeNameInCode(omitNamespaces, includeNamespaces))
     221                          .ToArray()));
     222          sb.Append(">");
     223        }
    176224      }
    177225      sb.Append(MemoryMagic);
     
    179227    }
    180228
    181     public string GetTypeNameInCode(bool includeAllNamespaces) {
    182       StringBuilder sb = new StringBuilder();
    183       if (includeAllNamespaces)
    184         sb.Append(Namespace).Append('.');
    185       sb.Append(ClassName);
    186       if (IsGeneric) {
    187         sb.Append("<");
    188         sb.Append(
    189           string.Join(", ",
    190             GenericArgs
    191               .Select(a => a.GetTypeNameInCode(includeAllNamespaces))
    192               .ToArray()));
    193         sb.Append(">");
    194       }
    195       sb.Append(MemoryMagic);
    196       return sb.ToString();
     229    public string GetTypeNameInCode(HashSet<string> omitNamespaces) {
     230      return GetTypeNameInCode(omitNamespaces, false);
     231    }
     232
     233    public string GetTypeNameInCode(bool includeNamespaces) {
     234      return GetTypeNameInCode(null, includeNamespaces);
    197235    }
    198236
     
    235273        }
    236274        return false;
    237       } catch (KeyNotFoundException) {
     275      }
     276      catch (KeyNotFoundException) {
    238277        throw new Exception("Could not extract version information from type string");
    239278      }
     
    272311        }
    273312        return true;
    274       } catch (KeyNotFoundException) {
     313      }
     314      catch (KeyNotFoundException) {
    275315        throw new Exception("Could not extract version infomration from type string");
    276316      }
  • branches/OaaS/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs

    r7259 r9363  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Text;
    2526using System.Text.RegularExpressions;
     
    4647  ///
    4748  /// SimpleTypeSpec := (IDENTIFIER '.')*
    48   ///                   (IDENTIFIER '+')*
     49  ///                   (IDENTIFIER '`\d+'? '+')*
    4950  ///                    IDENTIFIER
    5051  ///                   ( '`\d+[' Generics ']' )?
     
    6970
    7071      SimpleTypeSpec := (IDENTIFIER '.')*
    71                         (IDENTIFIER '+')*
    72                          IDENTIFIER
    73                         ( '`\d+[' Generics ']' )?
     72                        (IDENTIFIER '`\d+'?
     73                        ( '+' IDENTIFIER '`\d+'? )*
     74                        ( '[' Generics ']' )?
    7475                        (\*|\[(\d+\.\.\d+|\d+\.\.\.|(|\*)(,(|\*))*)\])*
    7576                        (',\s*' IDENTIFIER (',\s*' AssemblyProperty)* )?
    7677
    77       Generics := '[' SimpleTypeSpec ']' (',[' SimpleTypeSpec ']')
     78      Generics := '[' SimpleTypeSpec ']' (',[' SimpleTypeSpec ']')*
    7879
    7980      AssemblyProperty := 'Version=' Version
     
    8889
    8990    private class Token {
    90       private static Dictionary<string, string> tokens =
    91         new Dictionary<string, string> {
    92           {"-", "DASH"},
    93           {"&", "AMPERSAND"},
    94           {".", "DOT"},
    95           {"+", "PLUS"},
    96           {",", "COMMA"},
    97           {"[", "OPEN_BRACKET"},
    98           {"]", "CLOSE_BRACKET"},
    99           {"*", "ASTERISK"},
    100           {" ", "SPACE"},
    101           {"=", "EQUALS"},
    102           {"`", "BACKTICK"} };
    103       private static Regex NumberRegex = new Regex("^\\d+$");
    104       private static Regex IdentifierRegex = new Regex("^[_a-zA-Z][_a-zA-Z0-9]*$");
    105       private static Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|[a-f0-9]+|\\d+|[_a-zA-Z][_a-zA-Z0-9]*");
    106       public string Name { get; private set; }
     91      public enum Symbol { None, Dash, Ampersand, Dot, Plus, Comma, OpenBracket, CloseBracket, Asterisk, Space, Equals, Backtick }
     92      private static readonly Dictionary<string, Symbol> TOKENS =
     93        new Dictionary<string, Symbol> {
     94          {"-", Symbol.Dash},
     95          {"&", Symbol.Ampersand},
     96          {".", Symbol.Dot},
     97          {"+", Symbol.Plus},
     98          {",", Symbol.Comma},
     99          {"[", Symbol.OpenBracket},
     100          {"]", Symbol.CloseBracket},
     101          {"*", Symbol.Asterisk},
     102          {" ", Symbol.Space},
     103          {"=", Symbol.Equals},
     104          {"`", Symbol.Backtick}};
     105      private static readonly Regex NumberRegex = new Regex("^\\d+$");
     106      private static readonly Regex IdentifierRegex = new Regex("^[_a-zA-Z][_a-zA-Z0-9]*$");
     107      private static readonly Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|[a-f0-9]+|\\d+|[_a-zA-Z][_a-zA-Z0-9]*");
     108      public Symbol Name { get; private set; }
    107109      public string Value { get; private set; }
    108110      public bool IsIdentifier { get; private set; }
     
    111113      private Token(string value, int pos) {
    112114        Position = pos;
    113         if (tokens.ContainsKey(value)) {
    114           Name = tokens[value];
     115        Name = Symbol.None;
     116        if (TOKENS.ContainsKey(value)) {
     117          Name = TOKENS[value];
    115118        } else if (NumberRegex.IsMatch(value)) {
    116119          Number = int.Parse(value);
     
    128131      }
    129132      public override string ToString() {
    130         if (Name != null)
     133        if (Name != Symbol.None)
    131134          return "Token(" + Name + ")";
    132135        if (Value != null)
     
    154157    /// <summary>
    155158    /// Parses the specified typename string as obtained by
    156     /// <c>System.Object.GetType().FullName"</c>.
     159    /// <c>System.Object.GetType().FullName</c> or
     160    /// <c>System.Object.GetType().AssemblyQualifiedName</c>.
    157161    /// </summary>
    158162    /// <param name="s">The typename string.</param>
     
    181185    private TypeName TransformTypeSpec() {
    182186      TypeName t = TransformSimpleTypeSpec();
    183       t.IsReference = ConsumeToken("AMPERSAND");
     187      t.IsReference = ConsumeToken(Token.Symbol.Ampersand);
    184188      return t;
    185189    }
    186190
    187191    private TypeName TransformSimpleTypeSpec() {
    188       List<string> nameSpace = new List<string>();
    189       nameSpace.Add(ConsumeIdentifier());
    190       while (ConsumeToken("DOT"))
     192      var nameSpace = new List<string> { ConsumeIdentifier() };
     193      while (ConsumeToken(Token.Symbol.Dot))
    191194        nameSpace.Add(ConsumeIdentifier());
    192       List<string> className = new List<string>();
     195      var className = new List<string>();
    193196      if (nameSpace.Count > 0) {
    194197        className.Add(nameSpace[nameSpace.Count - 1]);
    195198        nameSpace.RemoveAt(nameSpace.Count - 1);
    196199      }
    197       while (ConsumeToken("PLUS"))
     200      var genericArgCounts = new List<int> {
     201        ConsumeToken(Token.Symbol.Backtick) ? ConsumeNumber() : 0
     202      };
     203      while (ConsumeToken(Token.Symbol.Plus)) {
    198204        className.Add(ConsumeIdentifier());
    199       TypeName typeName = new TypeName(
     205        genericArgCounts.Add(ConsumeToken(Token.Symbol.Backtick) ? ConsumeNumber() : 0);
     206      }
     207      var nGenericArgs = genericArgCounts.Sum();
     208      var typeName = new TypeName(
    200209        string.Join(".", nameSpace.ToArray()),
    201         string.Join("+", className.ToArray()));
    202       if (ConsumeToken("BACKTICK")) {
    203         int nGenericArgs = ConsumeNumber();
    204         if (ConsumeToken("OPEN_BRACKET") &&
    205           CanConsumeToken("OPEN_BRACKET")) {
    206           typeName.GenericArgs.AddRange(TransformGenerics());
    207           ConsumeToken("CLOSE_BRACKET", true);
    208         }
    209       }
    210       StringBuilder pointerOrArray = new StringBuilder();
     210        string.Join("+", className.ToArray()),
     211        nGenericArgs > genericArgCounts.Last() ? genericArgCounts : null);
     212      if (nGenericArgs > 0 && ConsumeToken(Token.Symbol.OpenBracket, true)) {
     213        typeName.GenericArgs.AddRange(TransformGenerics());
     214        ConsumeToken(Token.Symbol.CloseBracket, true);
     215      }
     216      var pointerOrArray = new StringBuilder();
    211217      while (true) {
    212         if (ConsumeToken("ASTERSIK")) {
     218        if (ConsumeToken(Token.Symbol.Asterisk)) {
    213219          pointerOrArray.Append("*");
    214         } else if (ConsumeToken("OPEN_BRACKET")) {
     220        } else if (ConsumeToken(Token.Symbol.OpenBracket)) {
    215221          pointerOrArray.Append('[');
    216222          ParseDimension(pointerOrArray);
    217           while (ConsumeToken("COMMA")) {
     223          while (ConsumeToken(Token.Symbol.Comma)) {
    218224            pointerOrArray.Append(",");
    219225            ParseDimension(pointerOrArray);
    220226          }
    221           ConsumeToken("CLOSE_BRACKET", true);
     227          ConsumeToken(Token.Symbol.CloseBracket, true);
    222228          pointerOrArray.Append(']');
    223229        } else {
     
    227233      typeName.MemoryMagic = pointerOrArray.ToString();
    228234      if (ConsumeComma()) {
    229         StringBuilder sb = new StringBuilder();
     235        var sb = new StringBuilder();
    230236        sb.Append(ConsumeIdentifier());
    231         while (CanConsumeToken("DOT") ||
    232           CanConsumeToken("DASH") ||
     237        while (CanConsumeToken(Token.Symbol.Dot) ||
     238          CanConsumeToken(Token.Symbol.Dash) ||
    233239          CanConsumeNumber() ||
    234240          CanConsumeIdentifier()) {
    235           if (ConsumeToken("DOT"))
     241          if (ConsumeToken(Token.Symbol.Dot))
    236242            sb.Append('.');
    237           else if (ConsumeToken("DASH"))
     243          else if (ConsumeToken(Token.Symbol.Dash))
    238244            sb.Append('-');
    239245          else if (CanConsumeNumber())
     
    253259
    254260    private void ParseDimension(StringBuilder sb) {
    255       if (ConsumeToken("ASTERSIK")) {
     261      if (ConsumeToken(Token.Symbol.Asterisk)) {
    256262        sb.Append("*");
    257263      } else if (CanConsumeNumber()) {
    258264        sb.Append(ConsumeNumber());
    259         ConsumeToken("DOT", true);
    260         ConsumeToken("DOT", true);
    261         if (ConsumeToken("DOT")) {
     265        ConsumeToken(Token.Symbol.Dot, true);
     266        ConsumeToken(Token.Symbol.Dot, true);
     267        if (ConsumeToken(Token.Symbol.Dot)) {
    262268          sb.Append("...");
    263269        } else {
     
    268274
    269275    private IEnumerable<TypeName> TransformGenerics() {
    270       ConsumeToken("OPEN_BRACKET", true);
     276      ConsumeToken(Token.Symbol.OpenBracket, true);
    271277      yield return TransformSimpleTypeSpec();
    272       ConsumeToken("CLOSE_BRACKET", true);
    273       while (ConsumeToken("COMMA")) {
    274         ConsumeToken("OPEN_BRACKET", true);
     278      ConsumeToken(Token.Symbol.CloseBracket, true);
     279      while (ConsumeToken(Token.Symbol.Comma)) {
     280        ConsumeToken(Token.Symbol.OpenBracket, true);
    275281        yield return TransformSimpleTypeSpec();
    276         ConsumeToken("CLOSE_BRACKET", true);
     282        ConsumeToken(Token.Symbol.CloseBracket, true);
    277283      }
    278284    }
     
    280286    private KeyValuePair<string, string> TransformAssemblyProperty() {
    281287      if (ConsumeIdentifier("Version")) {
    282         ConsumeToken("EQUALS", true);
     288        ConsumeToken(Token.Symbol.Equals, true);
    283289        return new KeyValuePair<string, string>(
    284290          "Version",
     
    300306
    301307    private KeyValuePair<string, string> ConsumeAssignment(string name) {
    302       ConsumeToken("EQUALS", true);
     308      ConsumeToken(Token.Symbol.Equals, true);
    303309      return new KeyValuePair<string, string>(name, ConsumeToken());
    304310    }
     
    307313      StringBuilder version = new StringBuilder();
    308314      version.Append(ConsumeNumber());
    309       ConsumeToken("DOT");
     315      ConsumeToken(Token.Symbol.Dot);
    310316      version.Append('.').Append(ConsumeNumber());
    311       ConsumeToken("DOT");
     317      ConsumeToken(Token.Symbol.Dot);
    312318      version.Append('.').Append(ConsumeNumber());
    313       ConsumeToken("DOT");
     319      ConsumeToken(Token.Symbol.Dot);
    314320      version.Append('.').Append(ConsumeNumber());
    315321      return version.ToString();
     
    368374
    369375    private bool ConsumeComma() {
    370       if (ConsumeToken("COMMA")) {
    371         while (ConsumeToken("SPACE")) ;
     376      if (ConsumeToken(Token.Symbol.Comma)) {
     377        while (ConsumeToken(Token.Symbol.Space)) ;
    372378        return true;
    373379      } else {
     
    376382    }
    377383
    378     private bool ConsumeToken(string name) {
    379       return ConsumeToken(name, false);
    380     }
    381 
    382     private bool CanConsumeToken(string name) {
    383       if (tokens.Count == 0)
    384         return false;
    385       if (tokens.Peek().Name == name)
     384    private bool ConsumeToken(Token.Symbol symbol) {
     385      return ConsumeToken(symbol, false);
     386    }
     387
     388    private bool CanConsumeToken(Token.Symbol symbol) {
     389      if (tokens.Count == 0)
     390        return false;
     391      if (tokens.Peek().Name == symbol)
    386392        return true;
    387393      return false;
    388394    }
    389395
    390     private bool ConsumeToken(string name, bool force) {
     396    private bool ConsumeToken(Token.Symbol symbol, bool force) {
    391397      if (tokens.Count == 0)
    392398        if (force)
    393399          throw new ParseError(String.Format(
    394400            "end of input while expecting token \"{0}\"",
    395             name));
     401            symbol));
    396402        else
    397403          return false;
    398       if (tokens.Peek().Name == name) {
     404      if (tokens.Peek().Name == symbol) {
    399405        tokens.Dequeue();
    400406        return true;
     
    402408        throw new ParseError(String.Format(
    403409          "expected \"{0}\" found \"{1}\"",
    404           name,
     410          symbol,
    405411          tokens.Peek().ToString()));
    406412      } else {
  • branches/OaaS/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/TypeSerializer.cs

    r7259 r9363  
    4141
    4242    public bool CanSerialize(Type type) {
     43      #region Mono Compatibility
    4344      return type == typeof(Type) ||
    44              type.VersionInvariantName() == "System.RuntimeType, mscorlib";
     45        type.VersionInvariantName() == "System.RuntimeType, mscorlib" ||
     46        type.VersionInvariantName() == "System.MonoType, mscorlib";
     47      #endregion
    4548    }
    4649
    4750    public string JustifyRejection(Type type) {
    48       return "not System.Type nor System.RuntimeType";
     51      #region Mono Compatibility
     52      return "not System.Type, System.RuntimeType, System.MonoType";
     53      #endregion
    4954    }
    5055
  • branches/OaaS/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r7021 r9363  
    125125  </ItemGroup>
    126126  <ItemGroup>
     127    <Compile Include="Auxiliary\ObjectEqualityComparer.cs" />
    127128    <Compile Include="Auxiliary\StringExtensions.cs" />
    128129    <Compile Include="Auxiliary\TypeLoader.cs" />
     
    246247  </ItemGroup>
    247248  <PropertyGroup>
    248     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     249    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    249250set ProjectDir=$(ProjectDir)
    250251set SolutionDir=$(SolutionDir)
     
    252253
    253254call PreBuildEvent.cmd
     255</PreBuildEvent>
     256    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     257export ProjectDir=$(ProjectDir)
     258export SolutionDir=$(SolutionDir)
     259
     260$SolutionDir/PreBuildEvent.sh
    254261</PreBuildEvent>
    255262    <PostBuildEvent>
  • branches/OaaS/HeuristicLab.Persistence/3.3/Plugin.cs.frame

    r7259 r9363  
    2727  /// The plugin for HeuriticLab.Persistence
    2828  /// </summary>
    29   [Plugin("HeuristicLab.Persistence", "3.3.6.$WCREV$")]
     29  [Plugin("HeuristicLab.Persistence", "3.3.7.$WCREV$")]
    3030  [PluginFile("HeuristicLab.Persistence-3.3.dll", PluginFileType.Assembly)]
    3131  [PluginDependency("HeuristicLab.Tracing", "3.3")]
  • branches/OaaS/HeuristicLab.Persistence/3.3/Properties/AssemblyInfo.cs.frame

    r7259 r9363  
    5252//
    5353[assembly: AssemblyVersion("3.3.0.0")]
    54 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     54[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
Note: See TracChangeset for help on using the changeset viewer.