Changeset 16723 for branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/StorableTest.cs
- Timestamp:
- 03/28/19 16:54:20 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/StorableTest.cs
r16692 r16723 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 25 25 using System.Reflection; 26 26 using System.Text; 27 using HEAL.Attic; 27 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 41 42 42 43 foreach (Type storableType in ApplicationManager.Manager.GetTypes(typeof(object)) 43 .Where(Storable ClassAttribute.IsStorableClass)) {44 .Where(StorableTypeAttribute.IsStorableType)) { 44 45 //test only types contained in HL plugin assemblies 46 if (!storableType.Namespace.StartsWith("HeuristicLab")) continue; 45 47 if (storableType.Namespace.Contains(".Tests")) continue; 46 48 if (!PluginLoader.Assemblies.Contains(storableType.Assembly)) continue; 47 49 50 if (storableType.IsEnum || storableType.IsInterface) continue; 51 var storableFields = storableType 52 .GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) 53 .Where(fi => StorableAttribute.IsStorable(fi)); 54 var storableProps = storableType 55 .GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) 56 .Where(fi => StorableAttribute.IsStorable(fi)); 57 58 // a storable constructor should be given but is not absolutely required. 59 // when there are no storable fields then a storable ctor has no real purpose. 60 if (!storableFields.Any() && !storableProps.Any()) continue; 61 48 62 IEnumerable<ConstructorInfo> ctors = storableType.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); 49 ConstructorInfo storableConstructor = ctors.Where(c => c.GetParameters().Count() == 1 && c.GetParameters().First().ParameterType == typeof( bool)).FirstOrDefault();63 ConstructorInfo storableConstructor = ctors.Where(c => c.GetParameters().Count() == 1 && c.GetParameters().First().ParameterType == typeof(HEAL.Attic.StorableConstructorFlag)).FirstOrDefault(); 50 64 if (storableConstructor == null) errorMessage.Append(Environment.NewLine + storableType.ToString() + ": No storable constructor is defined."); 51 65 else { … … 68 82 foreach (var type in ApplicationManager.Manager.GetTypes(typeof(object), onlyInstantiable: false, includeGenericTypeDefinitions: true) 69 83 .Where(t => t.Namespace != null && !t.Namespace.Contains(".Tests")) 70 .Where(t => !Storable ClassAttribute.IsStorableClass(t))) {84 .Where(t => !StorableTypeAttribute.IsStorableType(t))) { 71 85 var members = type.GetMembers(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly); 72 86 var storableConstructor = members.SingleOrDefault(m => Attribute.IsDefined(m, typeof(StorableConstructorAttribute), inherit: false)); … … 74 88 75 89 if (storableConstructor != null) { 76 errorMessage.Append(Environment.NewLine + type.Namespace + "." + type.GetPrettyName() + ": Contains a storable constructor but is not a storable class.");90 errorMessage.Append(Environment.NewLine + type.Namespace + "." + type.GetPrettyName() + ": Contains a storable constructor but is not a storable type."); 77 91 } else if (storableMembers.Any()) { 78 errorMessage.Append(Environment.NewLine + type.Namespace + "." + type.GetPrettyName() + ": Contains at least one storable member but is not a storable class.");92 errorMessage.Append(Environment.NewLine + type.Namespace + "." + type.GetPrettyName() + ": Contains at least one storable member but is not a storable type."); 79 93 } 80 94 }
Note: See TracChangeset
for help on using the changeset viewer.