- Timestamp:
- 02/24/10 12:35:19 (15 years ago)
- 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 31 31 public string ToString(bool full, bool includeAssembly) { 32 32 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); 34 36 if (IsGeneric) { 35 37 sb.Append('`').Append(GenericArgs.Count).Append('['); -
branches/Persistence Test/HeuristicLab.Persistence/3.3/Auxiliary/TypeNameParser.cs
r2735 r2858 29 29 | 'Culture=[a-zA-F0-9]+' 30 30 31 Version := '\d+\.\d+\.\d+\.\d+)'31 Version := \d+\.\d+\.\d+\.\d+ 32 32 33 33 IDENTIFIER = [_a-zA-Z][_a-ZA-Z0-9]* … … 50 50 {"`", "BACKTICK"} }; 51 51 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]*"); 53 54 public string Name { get; private set; } 54 55 public string Value { get; private set; } 56 public bool IsIdentifier { get; private set; } 55 57 public int? Number { get; private set; } 56 58 public int Position { get; private set; } … … 63 65 } else { 64 66 Value = value; 67 IsIdentifier = IdentifierRegex.IsMatch(value); 65 68 } 66 69 } … … 239 242 private KeyValuePair<string, string> ConsumeAssignment(string name) { 240 243 ConsumeToken("EQUALS", true); 241 return new KeyValuePair<string, string>(name, Consume Identifier());244 return new KeyValuePair<string, string>(name, ConsumeToken()); 242 245 } 243 246 … … 273 276 if (tokens.Count == 0) 274 277 return false; 275 if (tokens.Peek().Value == value ) {278 if (tokens.Peek().Value == value && tokens.Peek().IsIdentifier) { 276 279 tokens.Dequeue(); 277 280 return true; … … 288 291 if (tokens.Count == 0) 289 292 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"); 290 303 if (tokens.Peek().Value != null) 291 304 return tokens.Dequeue().Value; 292 305 throw new ParseError(String.Format( 293 " Identifierexpected, found \"{0}\" instead",306 "Token expected, found \"{0}\" instead", 294 307 tokens.Peek().ToString())); 295 308 } -
branches/Persistence Test/HeuristicLab.Persistence/UnitTests/UseCases.cs
r2106 r2858 408 408 foreach (Type t in a.GetTypes()) { 409 409 foreach (MemberInfo mi in t.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)) { 410 if (mi.DeclaringType.Name.StartsWith("<>")) 411 continue; 410 412 if (char.IsLower(mi.Name[0])) { 411 413 if (mi.MemberType == MemberTypes.Field) … … 506 508 507 509 [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] 508 518 public void TestMultipleFailure() { 509 519 List<NonSerializable> l = new List<NonSerializable>();
Note: See TracChangeset
for help on using the changeset viewer.