Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/10 12:36:43 (15 years ago)
Author:
epitzer
Message:

fix handling of PublicKeyToken in TypeNameParser (#548)

Location:
trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs

    r1795 r2859  
    3131    public string ToString(bool full, bool includeAssembly) {
    3232      StringBuilder sb = new StringBuilder();
    33       sb.Append(Namespace).Append('.').Append(ClassName);
     33      if (!string.IsNullOrEmpty(Namespace))
     34        sb.Append(Namespace).Append('.');
     35      sb.Append(ClassName);
    3436      if (IsGeneric) {
    3537        sb.Append('`').Append(GenericArgs.Count).Append('[');
  • trunk/sources/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs

    r2737 r2859  
    2929                 |  'Culture=[a-zA-F0-9]+'
    3030
    31       Version := '\d+\.\d+\.\d+\.\d+)'
     31      Version := \d+\.\d+\.\d+\.\d+
    3232
    3333      IDENTIFIER = [_a-zA-Z][_a-ZA-Z0-9]*
     
    5050          {"`", "BACKTICK"} };
    5151      private static Regex NumberRegex = new Regex("^\\d+$");
    52       private static Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|\\d+|[_a-zA-Z][_a-zA-Z0-9]*");
     52      private static Regex IdentifierRegex = new Regex("^[_a-zA-Z][_a-zA-Z0-9]*$");
     53      private static Regex TokenRegex = new Regex("[-&.+,\\[\\]* =`]|[a-f0-9]+|\\d+|[_a-zA-Z][_a-zA-Z0-9]*");
    5354      public string Name { get; private set; }
    5455      public string Value { get; private set; }
     56      public bool IsIdentifier { get; private set; }
    5557      public int? Number { get; private set; }
    5658      public int Position { get; private set; }
     
    6365        } else {
    6466          Value = value;
     67          IsIdentifier = IdentifierRegex.IsMatch(value);
    6568        }
    6669      }
     
    239242    private KeyValuePair<string, string> ConsumeAssignment(string name) {
    240243      ConsumeToken("EQUALS", true);
    241       return new KeyValuePair<string, string>(name, ConsumeIdentifier());
     244      return new KeyValuePair<string, string>(name, ConsumeToken());
    242245    }
    243246
     
    273276      if (tokens.Count == 0)
    274277        return false;
    275       if (tokens.Peek().Value == value) {
     278      if (tokens.Peek().Value == value && tokens.Peek().IsIdentifier) {
    276279        tokens.Dequeue();
    277280        return true;
     
    288291      if (tokens.Count == 0)
    289292        throw new ParseError("End of input while expecting identifier");
     293      if (tokens.Peek().Value != null && tokens.Peek().IsIdentifier)
     294        return tokens.Dequeue().Value;
     295      throw new ParseError(String.Format(
     296        "Identifier expected, found \"{0}\" instead",
     297        tokens.Peek().ToString()));
     298    }
     299
     300    private string ConsumeToken() {
     301      if (tokens.Count == 0)
     302        throw new ParseError("End of input while expecting token");
    290303      if (tokens.Peek().Value != null)
    291304        return tokens.Dequeue().Value;
    292305      throw new ParseError(String.Format(
    293         "Identifier expected, found \"{0}\" instead",
     306        "Token expected, found \"{0}\" instead",
    294307        tokens.Peek().ToString()));
    295308    }
Note: See TracChangeset for help on using the changeset viewer.