Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2858


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

fix handling of public key token (#802)

Location:
branches/Persistence Test/HeuristicLab.Persistence
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Persistence Test/HeuristicLab.Persistence/3.3/Auxiliary/TypeName.cs

    r1795 r2858  
    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('[');
  • branches/Persistence Test/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs

    r2735 r2858  
    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    }
  • branches/Persistence Test/HeuristicLab.Persistence/UnitTests/UseCases.cs

    r2106 r2858  
    408408        foreach (Type t in a.GetTypes()) {
    409409          foreach (MemberInfo mi in t.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) {
     410            if (mi.DeclaringType.Name.StartsWith("<>"))
     411              continue;
    410412            if (char.IsLower(mi.Name[0])) {
    411413              if (mi.MemberType == MemberTypes.Field)
     
    506508
    507509    [TestMethod]
     510    public void TestHexadecimalPublicKeyToken() {
     511      string name = "TestClass, TestAssembly, Version=1.2.3.4, PublicKey=1234abc";
     512      string shortName = "TestClass, TestAssembly";
     513      Assert.AreEqual(name, TypeNameParser.Parse(name).ToString());
     514      Assert.AreEqual(shortName, TypeNameParser.Parse(name).ToString(false));
     515    }
     516
     517    [TestMethod]
    508518    public void TestMultipleFailure() {
    509519      List<NonSerializable> l = new List<NonSerializable>();
Note: See TracChangeset for help on using the changeset viewer.