Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/28/18 16:10:48 (5 years ago)
Author:
jkarder
Message:

#2520: worked on reintegration of new persistence

  • added nuget references to HEAL.Fossil
  • added StorableType attributes to many classes
  • changed signature of StorableConstructors
  • removed some classes in old persistence
  • removed some unnecessary usings
Location:
branches/2520_PersistenceReintegration/HeuristicLab.Tests
Files:
2 added
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab-3.3/StorableTest.cs

    r16453 r16462  
    2525using System.Reflection;
    2626using System.Text;
     27using HEAL.Fossil;
    2728using HeuristicLab.Common;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/StorableAttributeTests.cs

    r16453 r16462  
    2020#endregion
    2121
    22 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     22using HEAL.Fossil;
    2323
    2424namespace HeuristicLab.Persistence.Tests {
    2525
    26   [StorableClass]
     26  [StorableType("EF55A82D-7D9B-486E-B811-4DCC389FDB05")]
    2727  class DemoClass {
    2828
     
    3434
    3535    public int y = 0;
     36
     37    [StorableConstructor]
     38    protected DemoClass(StorableConstructorFlag _) {
     39    }
     40    public DemoClass() {
     41    }
    3642  }
    3743
    38   [StorableClass]
     44  [StorableType("31F18F9A-C25D-449D-900A-FEBF95D7CE39")]
    3945  class Base {
    4046    public string baseName;
     
    4450      set { baseName = value; }
    4551    }
     52
     53    [StorableConstructor]
     54    protected Base(StorableConstructorFlag _) {
     55    }
     56    public Base() {
     57    }
    4658  }
    4759
    48   [StorableClass]
     60  [StorableType("DF26C284-08C4-4703-A1A4-AFE834079B85")]
    4961  class Override : Base {
    5062    [Storable]
     
    5365      set { base.Name = value; }
    5466    }
     67
     68    [StorableConstructor]
     69    protected Override(StorableConstructorFlag _) : base(_) {
     70    }
     71    public Override() {
     72    }
    5573  }
    5674
    57   [StorableClass]
     75  [StorableType("6BFB1984-6670-4D5E-AEAC-3E77C627AF98")]
    5876  class Intermediate : Override {
     77    [StorableConstructor]
     78    protected Intermediate(StorableConstructorFlag _) : base(_) {
     79    }
     80    public Intermediate() {
     81    }
    5982  }
    6083
    61   [StorableClass]
     84  [StorableType("856F9BDB-A20C-4B80-981B-5B4F5188FBCD")]
    6285  class New : Intermediate {
    6386    public string newName;
     
    6790      set { newName = value; }
    6891    }
     92
     93    [StorableConstructor]
     94    protected New(StorableConstructorFlag _) : base(_) {
     95    }
     96    public New() {
     97    }
    6998  }
    7099}
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence-3.3/UseCases.cs

    r16453 r16462  
    3131using System.Text.RegularExpressions;
    3232using System.Threading.Tasks;
     33using HEAL.Fossil;
    3334using HeuristicLab.Algorithms.GeneticAlgorithm;
    3435using HeuristicLab.Persistence.Auxiliary;
     
    4344using HeuristicLab.Tests;
    4445using Microsoft.VisualStudio.TestTools.UnitTesting;
     46using Serializer = HeuristicLab.Persistence.Core.Serializer;
    4547
    4648namespace HeuristicLab.Persistence.Tests {
    4749
    48   [StorableClass]
     50  [StorableType("25A94A36-F3AA-4207-A3C9-54260D2A1724")]
    4951  public class NumberTest {
    5052    [Storable]
     
    9395        _ulong.GetHashCode();
    9496    }
     97
     98    [StorableConstructor]
     99    protected NumberTest(StorableConstructorFlag _) {
     100    }
     101    public NumberTest() {
     102    }
    95103  }
    96104
    97   [StorableClass]
    98   public class NonDefaultConstructorClass {
    99     [Storable]
    100     int value;
    101     public NonDefaultConstructorClass(int value) {
    102       this.value = value;
    103     }
    104   }
    105 
    106   [StorableClass]
     105  [StorableType("BE44EB33-C8B7-4CDA-A564-3165558FEBE7")]
    107106  public class IntWrapper {
    108107
    109108    [Storable]
    110109    public int Value;
     110
     111    [StorableConstructor]
     112    protected IntWrapper(StorableConstructorFlag _) {
     113    }
    111114
    112115    private IntWrapper() { }
     
    127130  }
    128131
    129   [StorableClass]
     132  [StorableType("A7865A50-E5B7-4656-8648-F375FC678BA3")]
    130133  public class PrimitivesTest : NumberTest {
    131134    [Storable]
     
    155158        o.GetHashCode();
    156159    }
     160
     161    [StorableConstructor]
     162    protected PrimitivesTest(StorableConstructorFlag _) : base(_) {
     163    }
     164    public PrimitivesTest() {
     165    }
    157166  }
    158167
    159   public enum TestEnum { va1, va2, va3, va8 } ;
    160 
    161   [StorableClass]
     168  [StorableType("18245FB6-D650-4378-9197-CCE6BB678F66")]
     169  public enum TestEnum { va1, va2, va3, va8 };
     170
     171  [StorableType("F5646F6C-DCD3-47D7-BBE5-2B33812B06D7")]
    162172  public class RootBase {
    163173    [Storable]
     
    176186        myEnum.GetHashCode();
    177187    }
     188
     189    [StorableConstructor]
     190    protected RootBase(StorableConstructorFlag _) {
     191    }
     192    public RootBase() {
     193    }
    178194  }
    179195
    180   [StorableClass]
     196  [StorableType("A9F5AFC4-20D3-4898-A7B6-E78A2CCE343B")]
    181197  public class Root : RootBase {
    182198    [Storable]
     
    206222    [Storable(DefaultValue = "default")]
    207223    public string uninitialized;
     224
     225    [StorableConstructor]
     226    protected Root(StorableConstructorFlag _) : base(_) {
     227    }
     228    public Root() {
     229    }
    208230  }
    209231
     
    213235  public enum TrickyEnum { zero = 0, one = 1, two = 2 }
    214236
    215   [StorableClass]
     237  [StorableType("969350FD-1E94-4A6F-BA95-6D2D48014E73")]
    216238  public class EnumTest {
    217239    [Storable]
     
    221243    [Storable]
    222244    public TrickyEnum trickyEnum = (TrickyEnum)15;
     245
     246    [StorableConstructor]
     247    protected EnumTest(StorableConstructorFlag _) {
     248    }
     249    public EnumTest() {
     250    }
    223251  }
    224252
    225   [StorableClass]
     253  [StorableType("03CC855E-1DCA-451E-9BFB-3B06E7F96CAA")]
    226254  public class Custom {
    227255    [Storable]
     
    231259    [Storable]
    232260    public string name = "<![CDATA[<![CDATA[Serial]]>]]>";
     261
     262    [StorableConstructor]
     263    protected Custom(StorableConstructorFlag _) {
     264    }
     265
     266    public Custom() {
     267
     268    }
    233269  }
    234270
    235   [StorableClass]
     271  [StorableType("C3A632A5-F356-4E22-8659-BBE515638CDC")]
    236272  public class Manager {
    237273
     
    244280    [Storable]
    245281    public double? dbl;
     282
     283    [StorableConstructor]
     284    protected Manager(StorableConstructorFlag _) {
     285    }
     286    public Manager() {
     287    }
    246288  }
    247289
    248   [StorableClass]
     290  [StorableType("D694E112-47AF-47DF-8A89-F12F95FF43AB")]
    249291  public class C {
    250292    [Storable]
     
    252294    [Storable]
    253295    public KeyValuePair<List<C>, C> kvpList;
     296
     297    [StorableConstructor]
     298    protected C(StorableConstructorFlag _) {
     299    }
     300    public C() {
     301    }
    254302  }
    255303
     
    486534    }
    487535
    488     [StorableClass]
     536    [StorableType("8EA1D97E-91CD-4643-80B2-D66724E3ED4C")]
    489537    public class NestedType {
    490538      [Storable]
     
    498546      public override int GetHashCode() {
    499547        return value.GetHashCode();
     548      }
     549
     550      [StorableConstructor]
     551      protected NestedType(StorableConstructorFlag _) {
     552      }
     553      public NestedType() {
    500554      }
    501555    }
     
    589643        new Configuration(new XmlFormat(),
    590644          new List<IPrimitiveSerializer> { new String2XmlSerializer() },
    591           new List<ICompositeSerializer> { 
     645          new List<ICompositeSerializer> {
    592646            new StorableSerializer(),
    593647            new Number2StringSerializer() }));
     
    629683      Assert.AreEqual(newInts[0], newInts[1]);
    630684      Assert.AreNotSame(newInts[0], newInts[1]);
    631     }
    632 
    633     [TestMethod]
    634     [TestCategory("Persistence")]
    635     [TestProperty("Time", "short")]
    636     public void NonDefaultConstructorTest() {
    637       NonDefaultConstructorClass c = new NonDefaultConstructorClass(1);
    638       try {
    639         XmlGenerator.Serialize(c, tempFile);
    640         Assert.Fail("Exception not thrown");
    641       } catch (PersistenceException) {
    642       }
    643685    }
    644686
     
    753795    }
    754796
    755     [StorableClass]
     797    [StorableType("B7140365-BA53-4E12-A095-86A3AAF5D159")]
    756798    class Child {
    757799      [Storable]
    758800      public GrandParent grandParent;
    759     }
    760 
    761     [StorableClass]
     801
     802      [StorableConstructor]
     803      protected Child(StorableConstructorFlag _) {
     804      }
     805      public Child() {
     806      }
     807    }
     808
     809    [StorableType("45FAEF81-D8CD-47DB-B8DD-BBFE81F37181")]
    762810    class Parent {
    763811      [Storable]
    764812      public Child child;
    765     }
    766 
    767     [StorableClass]
     813
     814      [StorableConstructor]
     815      protected Parent(StorableConstructorFlag _) {
     816      }
     817      public Parent() {
     818      }
     819    }
     820
     821    [StorableType("0668DB55-89ED-4943-B0AB-245AB3167348")]
    768822    class GrandParent {
    769823      [Storable]
    770824      public Parent parent;
     825
     826      [StorableConstructor]
     827      protected GrandParent(StorableConstructorFlag _) {
     828      }
     829      public GrandParent() {
     830      }
    771831    }
    772832
     
    843903    }
    844904
    845     [StorableClass]
     905    [StorableType("92DD18D7-A43C-4DEE-9354-81196F4DC96D")]
    846906    private class PersistenceHooks {
    847907      [Storable]
     
    858918      void PostDeserializationHook() {
    859919        sum = a + b;
     920      }
     921
     922      [StorableConstructor]
     923      protected PersistenceHooks(StorableConstructorFlag _) {
     924      }
     925      public PersistenceHooks() {
    860926      }
    861927    }
     
    880946    }
    881947
    882     [StorableClass]
     948    [StorableType("3E9A9875-875F-41DD-AEEC-2924643C8E45")]
    883949    private class CustomConstructor {
    884950      public string Value = "none";
     
    887953      }
    888954      [StorableConstructor]
    889       private CustomConstructor(bool deserializing) {
    890         Assert.IsTrue(deserializing);
     955      private CustomConstructor(StorableConstructorFlag _) {
    891956        Value = "persistence";
    892957      }
     
    902967      CustomConstructor newCC = (CustomConstructor)XmlParser.Deserialize(tempFile);
    903968      Assert.AreEqual(newCC.Value, "persistence");
    904     }
    905 
    906     [StorableClass]
    907     public class ExplodingDefaultConstructor {
    908       public ExplodingDefaultConstructor() {
    909         throw new Exception("this constructor will always fail");
    910       }
    911       public ExplodingDefaultConstructor(string password) {
    912       }
    913     }
    914 
    915     [TestMethod]
    916     [TestCategory("Persistence")]
    917     [TestProperty("Time", "short")]
    918     public void TestConstructorExceptionUnwrapping() {
    919       ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password");
    920       XmlGenerator.Serialize(x, tempFile);
    921       try {
    922         ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile);
    923         Assert.Fail("Exception expected");
    924       } catch (PersistenceException pe) {
    925         Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail");
    926       }
    927969    }
    928970
     
    954996    }
    955997
    956     [StorableClass]
     998    [StorableType("BC0996AA-6544-4D0F-8CBD-1FCCF08F4637")]
    957999    public class HookInheritanceTestBase {
    9581000      [Storable]
     
    9631005        link = a;
    9641006      }
    965     }
    966 
    967     [StorableClass]
     1007
     1008      [StorableConstructor]
     1009      protected HookInheritanceTestBase(StorableConstructorFlag _) {
     1010      }
     1011      public HookInheritanceTestBase() {
     1012      }
     1013    }
     1014
     1015    [StorableType("E0CABA1E-EA8E-4B50-9840-1F80D23E8DC7")]
    9681016    public class HookInheritanceTestDerivedClass : HookInheritanceTestBase {
    9691017      [Storable]
     
    9741022        link = b;
    9751023      }
     1024
     1025      [StorableConstructor]
     1026      protected HookInheritanceTestDerivedClass(StorableConstructorFlag _) : base(_) {
     1027      }
     1028      public HookInheritanceTestDerivedClass() {
     1029      }
    9761030    }
    9771031
     
    9871041    }
    9881042
    989     [StorableClass(StorableClassType.AllFields)]
     1043    [StorableType(StorableMemberSelection.AllFields, "45B11367-791E-4967-86AA-D6B83EC3CDAE")]
    9901044    public class AllFieldsStorable {
    9911045      public int Value1 = 1;
     
    9951049      public int Value4 { get; private set; }
    9961050      [StorableConstructor]
    997       public AllFieldsStorable(bool isDeserializing) {
    998         if (!isDeserializing) {
    999           Value1 = 12;
    1000           Value2 = 23;
    1001           Value3 = 34;
    1002           Value4 = 56;
    1003         }
     1051      protected AllFieldsStorable(StorableConstructorFlag _) { }
     1052      public AllFieldsStorable() {
     1053        Value1 = 12;
     1054        Value2 = 23;
     1055        Value3 = 34;
     1056        Value4 = 56;
    10041057      }
    10051058    }
     
    10091062    [TestProperty("Time", "short")]
    10101063    public void TestStorableClassDiscoveryAllFields() {
    1011       AllFieldsStorable afs = new AllFieldsStorable(false);
     1064      AllFieldsStorable afs = new AllFieldsStorable();
    10121065      XmlGenerator.Serialize(afs, tempFile);
    10131066      AllFieldsStorable newAfs = (AllFieldsStorable)XmlParser.Deserialize(tempFile);
     
    10181071    }
    10191072
    1020     [StorableClass(StorableClassType.AllProperties)]
     1073    [StorableType(StorableMemberSelection.AllProperties, "BB7931E4-2900-430C-80FA-1CF3C41BA2C9")]
    10211074    public class AllPropertiesStorable {
    10221075      public int Value1 = 1;
     
    10261079      public int Value4 { get; private set; }
    10271080      [StorableConstructor]
    1028       public AllPropertiesStorable(bool isDeserializing) {
    1029         if (!isDeserializing) {
    1030           Value1 = 12;
    1031           Value2 = 23;
    1032           Value3 = 34;
    1033           Value4 = 56;
    1034         }
     1081      protected AllPropertiesStorable(StorableConstructorFlag _) { }
     1082      public AllPropertiesStorable() {
     1083        Value1 = 12;
     1084        Value2 = 23;
     1085        Value3 = 34;
     1086        Value4 = 56;
    10351087      }
    10361088    }
     
    10401092    [TestProperty("Time", "short")]
    10411093    public void TestStorableClassDiscoveryAllProperties() {
    1042       AllPropertiesStorable afs = new AllPropertiesStorable(false);
     1094      AllPropertiesStorable afs = new AllPropertiesStorable();
    10431095      XmlGenerator.Serialize(afs, tempFile);
    10441096      AllPropertiesStorable newAfs = (AllPropertiesStorable)XmlParser.Deserialize(tempFile);
     
    10501102    }
    10511103
    1052     [StorableClass(StorableClassType.AllFieldsAndAllProperties)]
     1104    [StorableType(StorableMemberSelection.AllFieldsAndAllProperties, "D81160A5-BCF9-409A-9082-EFB803C882BF")]
    10531105    public class AllFieldsAndAllPropertiesStorable {
    10541106      public int Value1 = 1;
     
    10581110      public int Value4 { get; private set; }
    10591111      [StorableConstructor]
    1060       public AllFieldsAndAllPropertiesStorable(bool isDeserializing) {
    1061         if (!isDeserializing) {
    1062           Value1 = 12;
    1063           Value2 = 23;
    1064           Value3 = 34;
    1065           Value4 = 56;
    1066         }
     1112      protected AllFieldsAndAllPropertiesStorable(StorableConstructorFlag _) { }
     1113      public AllFieldsAndAllPropertiesStorable() {
     1114        Value1 = 12;
     1115        Value2 = 23;
     1116        Value3 = 34;
     1117        Value4 = 56;
    10671118      }
    10681119    }
     
    10721123    [TestProperty("Time", "short")]
    10731124    public void TestStorableClassDiscoveryAllFieldsAndAllProperties() {
    1074       AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false);
     1125      AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable();
    10751126      XmlGenerator.Serialize(afs, tempFile);
    10761127      AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)XmlParser.Deserialize(tempFile);
     
    10811132    }
    10821133
    1083     [StorableClass(StorableClassType.MarkedOnly)]
     1134    [StorableType(StorableMemberSelection.MarkedOnly, "979BEF0C-D150-4809-9EF4-467B7CCB9665")]
    10841135    public class MarkedOnlyStorable {
    10851136      public int Value1 = 1;
     
    10891140      public int Value4 { get; private set; }
    10901141      [StorableConstructor]
    1091       public MarkedOnlyStorable(bool isDeserializing) {
    1092         if (!isDeserializing) {
    1093           Value1 = 12;
    1094           Value2 = 23;
    1095           Value3 = 34;
    1096           Value4 = 56;
    1097         }
     1142      protected MarkedOnlyStorable(StorableConstructorFlag _) { }
     1143      public MarkedOnlyStorable() {
     1144        Value1 = 12;
     1145        Value2 = 23;
     1146        Value3 = 34;
     1147        Value4 = 56;
    10981148      }
    10991149    }
     
    11031153    [TestProperty("Time", "short")]
    11041154    public void TestStorableClassDiscoveryMarkedOnly() {
    1105       MarkedOnlyStorable afs = new MarkedOnlyStorable(false);
     1155      MarkedOnlyStorable afs = new MarkedOnlyStorable();
    11061156      XmlGenerator.Serialize(afs, tempFile);
    11071157      MarkedOnlyStorable newAfs = (MarkedOnlyStorable)XmlParser.Deserialize(tempFile);
     
    12411291    }
    12421292
    1243     [StorableClass]
     1293    [StorableType("5F96AAB5-F68E-4A41-BA66-E56069822719")]
    12441294    public class ReadOnlyFail {
    12451295      [Storable]
    12461296      public string ReadOnly {
    12471297        get { return "fail"; }
     1298      }
     1299
     1300      [StorableConstructor]
     1301      protected ReadOnlyFail(StorableConstructorFlag _) {
     1302      }
     1303      public ReadOnlyFail() {
    12481304      }
    12491305    }
     
    12631319
    12641320
    1265     [StorableClass]
     1321    [StorableType("9809F12C-B787-4BB5-9930-705673964D45")]
    12661322    public class WriteOnlyFail {
    12671323      [Storable]
    12681324      public string WriteOnly {
    12691325        set { throw new InvalidOperationException("this property should never be set."); }
     1326      }
     1327
     1328      [StorableConstructor]
     1329      protected WriteOnlyFail(StorableConstructorFlag _) {
     1330      }
     1331      public WriteOnlyFail() {
    12701332      }
    12711333    }
     
    12841346    }
    12851347
    1286     [StorableClass]
     1348    [StorableType("749C5247-ABB8-4286-8208-058CC7B9C781")]
    12871349    public class OneWayTest {
     1350      [StorableConstructor]
     1351      protected OneWayTest(StorableConstructorFlag _) {
     1352      }
     1353
    12881354      public OneWayTest() { this.value = "default"; }
    12891355      public string value;
     
    13091375      Assert.AreEqual("ReadOnly", ((PrimitiveToken)it.Current).Name); it.MoveNext();
    13101376      Assert.AreEqual("ROOT", ((EndToken)it.Current).Name); it.MoveNext();
    1311       var deserializer = new Deserializer(new[] { 
     1377      var deserializer = new Deserializer(new[] {
    13121378        new TypeMapping(0, typeof(OneWayTest).AssemblyQualifiedName, typeof(StorableSerializer).AssemblyQualifiedName),
    13131379        new TypeMapping(1, typeof(string).AssemblyQualifiedName, typeof(String2XmlSerializer).AssemblyQualifiedName) });
     
    14611527      b[2] = byte.MaxValue;
    14621528      XmlGenerator.Serialize(b, tempFile);
    1463       var newB = (byte[]) XmlParser.Deserialize(tempFile);
     1529      var newB = (byte[])XmlParser.Deserialize(tempFile);
    14641530      CollectionAssert.AreEqual(b, newB);
    14651531    }
     
    14691535    [TestProperty("Time", "short")]
    14701536    public void TestOptionalNumberEnumerable() {
    1471       var values = new List<double?> {0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1};
     1537      var values = new List<double?> { 0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1 };
    14721538      XmlGenerator.Serialize(values, tempFile);
    1473       var newValues = (List<double?>) XmlParser.Deserialize(tempFile);
     1539      var newValues = (List<double?>)XmlParser.Deserialize(tempFile);
    14741540      CollectionAssert.AreEqual(values, newValues);
    14751541    }
     
    14821548        DateTime.ParseExact("10.09.2014 12:21", "dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture), DateTime.MaxValue};
    14831549      XmlGenerator.Serialize(values, tempFile);
    1484       var newValues = (List<DateTime?>) XmlParser.Deserialize(tempFile);
     1550      var newValues = (List<DateTime?>)XmlParser.Deserialize(tempFile);
    14851551      CollectionAssert.AreEqual(values, newValues);
    14861552    }
     
    14901556    [TestProperty("Time", "short")]
    14911557    public void TestStringEnumerable() {
    1492       var values = new List<string> {"", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated"};
     1558      var values = new List<string> { "", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated" };
    14931559      XmlGenerator.Serialize(values, tempFile);
    1494       var newValues = (List<String>) XmlParser.Deserialize(tempFile);
     1560      var newValues = (List<String>)XmlParser.Deserialize(tempFile);
    14951561      CollectionAssert.AreEqual(values, newValues);
    14961562    }
     
    15001566    [TestProperty("Time", "short")]
    15011567    public void TestUnicodeCharArray() {
    1502       var s = Encoding.UTF8.GetChars(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
     1568      var s = Encoding.UTF8.GetChars(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb });
    15031569      XmlGenerator.Serialize(s, tempFile);
    15041570      var newS = (char[])XmlParser.Deserialize(tempFile);
     
    15101576    [TestProperty("Time", "short")]
    15111577    public void TestUnicode() {
    1512       var s = Encoding.UTF8.GetString(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
     1578      var s = Encoding.UTF8.GetString(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb });
    15131579      XmlGenerator.Serialize(s, tempFile);
    15141580      var newS = XmlParser.Deserialize(tempFile);
     
    15201586    [TestProperty("Time", "short")]
    15211587    public void TestQueue() {
    1522       var q = new Queue<int>(new[] {1, 2, 3, 4, 0});
     1588      var q = new Queue<int>(new[] { 1, 2, 3, 4, 0 });
    15231589      XmlGenerator.Serialize(q, tempFile);
    15241590      var newQ = (Queue<int>)XmlParser.Deserialize(tempFile);
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence.Fossil/StorableAttributeTests.cs

    r16453 r16462  
    2020#endregion
    2121
    22 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     22using HEAL.Fossil;
    2323
    24 namespace HeuristicLab.Persistence.Tests {
     24namespace HeuristicLab.Persistence.Fossil.Tests {
    2525
    26   [StorableClass]
     26  [StorableType("E0862640-FD57-4F1B-929D-03E38D8EA5D3")]
    2727  class DemoClass {
    2828
     
    3434
    3535    public int y = 0;
     36
     37    [StorableConstructor]
     38    protected DemoClass(StorableConstructorFlag _) {
     39    }
     40    public DemoClass() {
     41    }
    3642  }
    3743
    38   [StorableClass]
     44  [StorableType("7C5431ED-9754-44B9-870D-F62E822A74CE")]
    3945  class Base {
    4046    public string baseName;
     
    4450      set { baseName = value; }
    4551    }
     52
     53    [StorableConstructor]
     54    protected Base(StorableConstructorFlag _) {
     55    }
     56    public Base() {
     57    }
    4658  }
    4759
    48   [StorableClass]
     60  [StorableType("39BC0BDD-C5F4-4FAA-B227-558909E7AE6C")]
    4961  class Override : Base {
    5062    [Storable]
     
    5365      set { base.Name = value; }
    5466    }
     67
     68    [StorableConstructor]
     69    protected Override(StorableConstructorFlag _) : base(_) {
     70    }
     71    public Override() {
     72    }
    5573  }
    5674
    57   [StorableClass]
     75  [StorableType("50E13067-A343-4059-B44B-54511ED813AE")]
    5876  class Intermediate : Override {
     77    [StorableConstructor]
     78    protected Intermediate(StorableConstructorFlag _) : base(_) {
     79    }
     80    public Intermediate() {
     81    }
    5982  }
    6083
    61   [StorableClass]
     84  [StorableType("DA7868B2-81CC-48AC-AEC3-2E3AD2E0A34E")]
    6285  class New : Intermediate {
    6386    public string newName;
     
    6790      set { newName = value; }
    6891    }
     92
     93    [StorableConstructor]
     94    protected New(StorableConstructorFlag _) : base(_) {
     95    }
     96    public New() {
     97    }
    6998  }
    7099}
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Persistence.Fossil/UseCases.cs

    r16453 r16462  
    2929using System.Reflection;
    3030using System.Text;
    31 using System.Text.RegularExpressions;
    3231using System.Threading.Tasks;
     32using HEAL.Fossil;
    3333using HeuristicLab.Algorithms.GeneticAlgorithm;
    3434using HeuristicLab.Persistence.Auxiliary;
    3535using HeuristicLab.Persistence.Core;
    36 using HeuristicLab.Persistence.Core.Tokens;
    3736using HeuristicLab.Persistence.Default.CompositeSerializers;
    38 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3937using HeuristicLab.Persistence.Default.DebugString;
    40 using HeuristicLab.Persistence.Default.Xml;
    41 using HeuristicLab.Persistence.Default.Xml.Primitive;
    42 using HeuristicLab.Persistence.Interfaces;
    4338using HeuristicLab.Tests;
    4439using Microsoft.VisualStudio.TestTools.UnitTesting;
    4540
    46 namespace HeuristicLab.Persistence.Tests {
    47 
    48   [StorableClass]
     41namespace HeuristicLab.Persistence.Fossil.Tests {
     42
     43  [StorableType("22B5FC22-44FA-40B4-84E3-BB53540E812E")]
    4944  public class NumberTest {
    5045    [Storable]
     
    9388        _ulong.GetHashCode();
    9489    }
     90
     91    [StorableConstructor]
     92    protected NumberTest(StorableConstructorFlag _) {
     93    }
     94    public NumberTest() {
     95    }
    9596  }
    9697
    97   [StorableClass]
    98   public class NonDefaultConstructorClass {
    99     [Storable]
    100     int value;
    101     public NonDefaultConstructorClass(int value) {
    102       this.value = value;
    103     }
    104   }
    105 
    106   [StorableClass]
     98  [StorableType("2D94AD3B-D411-403F-AC42-60824C78D802")]
    10799  public class IntWrapper {
    108100
    109101    [Storable]
    110102    public int Value;
     103
     104    [StorableConstructor]
     105    protected IntWrapper(StorableConstructorFlag _) {
     106    }
    111107
    112108    private IntWrapper() { }
     
    127123  }
    128124
    129   [StorableClass]
     125  [StorableType("45337DD7-26D0-42D0-8CC4-92E184AE0218")]
    130126  public class PrimitivesTest : NumberTest {
    131127    [Storable]
     
    155151        o.GetHashCode();
    156152    }
     153
     154    [StorableConstructor]
     155    protected PrimitivesTest(StorableConstructorFlag _) : base(_) {
     156    }
     157    public PrimitivesTest() {
     158    }
    157159  }
    158160
    159   public enum TestEnum { va1, va2, va3, va8 } ;
    160 
    161   [StorableClass]
     161  [StorableType("2F63F603-CE7D-4262-99B4-A797F4D04907")]
     162  public enum TestEnum { va1, va2, va3, va8 };
     163
     164  [StorableType("DC944CA9-5F6A-4EF3-AFBD-881FC63797DF")]
    162165  public class RootBase {
    163166    [Storable]
     
    176179        myEnum.GetHashCode();
    177180    }
     181
     182    [StorableConstructor]
     183    protected RootBase(StorableConstructorFlag _) {
     184    }
     185    public RootBase() {
     186    }
    178187  }
    179188
    180   [StorableClass]
     189  [StorableType("C478905A-5029-4F31-9D92-524F41272D46")]
    181190  public class Root : RootBase {
    182191    [Storable]
     
    206215    [Storable(DefaultValue = "default")]
    207216    public string uninitialized;
     217
     218    [StorableConstructor]
     219    protected Root(StorableConstructorFlag _) : base(_) {
     220    }
     221    public Root() {
     222    }
    208223  }
    209224
     225  [StorableType("23DCF22C-EDAB-4C5A-9941-0F2D6030D467")]
    210226  public enum SimpleEnum { one, two, three }
     227  [StorableType("1FA5C129-129E-485C-A8A7-59FCA10CBB20")]
    211228  public enum ComplexEnum { one = 1, two = 2, three = 3 }
    212229  [FlagsAttribute]
     230  [StorableType("D4A5D0CD-295C-4AC1-B5DA-D8DA2861E82C")]
    213231  public enum TrickyEnum { zero = 0, one = 1, two = 2 }
    214232
    215   [StorableClass]
     233  [StorableType("C6EC77AF-C565-4A83-8922-3C6E2370627B")]
    216234  public class EnumTest {
    217235    [Storable]
     
    221239    [Storable]
    222240    public TrickyEnum trickyEnum = (TrickyEnum)15;
     241
     242    [StorableConstructor]
     243    protected EnumTest(StorableConstructorFlag _) {
     244    }
     245    public EnumTest() {
     246    }
    223247  }
    224248
    225   [StorableClass]
     249  [StorableType("9E73E52B-9BF1-489D-9349-C490D518B7C4")]
    226250  public class Custom {
    227251    [Storable]
     
    231255    [Storable]
    232256    public string name = "<![CDATA[<![CDATA[Serial]]>]]>";
     257
     258    [StorableConstructor]
     259    protected Custom(StorableConstructorFlag _) {
     260    }
     261
     262    public Custom() {
     263
     264    }
    233265  }
    234266
    235   [StorableClass]
     267  [StorableType("CEE5C689-948F-443A-A645-54868D913364")]
    236268  public class Manager {
    237269
     
    244276    [Storable]
    245277    public double? dbl;
     278
     279    [StorableConstructor]
     280    protected Manager(StorableConstructorFlag _) {
     281    }
     282    public Manager() {
     283    }
    246284  }
    247285
    248   [StorableClass]
     286  [StorableType("14EB77CD-7061-4B2E-96EB-3E45CC265256")]
    249287  public class C {
    250288    [Storable]
     
    252290    [Storable]
    253291    public KeyValuePair<List<C>, C> kvpList;
     292
     293    [StorableConstructor]
     294    protected C(StorableConstructorFlag _) {
     295    }
     296    public C() {
     297    }
    254298  }
    255299
     
    287331
    288332    [TestMethod]
    289     [TestCategory("Persistence")]
     333    [TestCategory("Persistence.Fossil")]
    290334    [TestProperty("Time", "short")]
    291335    public void ComplexStorable() {
    292336      Root r = InitializeComplexStorable();
    293       XmlGenerator.Serialize(r, tempFile);
    294       Root newR = (Root)XmlParser.Deserialize(tempFile);
     337      var ser = new ProtoBufSerializer();
     338      ser.Serialize(r, tempFile);
     339      Root newR = (Root)ser.Deserialize(tempFile);
    295340      CompareComplexStorables(r, newR);
    296341    }
    297342
    298     [TestMethod]
    299     [TestCategory("Persistence")]
    300     [TestProperty("Time", "short")]
    301     public void ComplexEasyStorable() {
    302       Root r = InitializeComplexStorable();
    303       ReadableXmlGenerator.Serialize(r, tempFile);
    304       using (var reader = new StreamReader(tempFile)) {
    305         string text = reader.ReadToEnd();
    306         Assert.IsTrue(text.StartsWith("<Root"));
    307       }
    308     }
    309 
    310343    private static void CompareComplexStorables(Root r, Root newR) {
    311       Assert.AreEqual(
    312         DebugStringGenerator.Serialize(r),
    313         DebugStringGenerator.Serialize(newR));
    314344      Assert.AreSame(newR, newR.selfReferences[0]);
    315345      Assert.AreNotSame(r, newR);
     
    388418
    389419    [TestMethod]
    390     [TestCategory("Persistence")]
     420    [TestCategory("Persistence.Fossil")]
    391421    [TestProperty("Time", "short")]
    392422    public void SelfReferences() {
     
    397427      c.allCs = cs;
    398428      c.kvpList = new KeyValuePair<List<C>, C>(new List<C> { c }, c);
    399       XmlGenerator.Serialize(cs, tempFile);
    400       object o = XmlParser.Deserialize(tempFile);
     429      new ProtoBufSerializer().Serialize(cs, tempFile);
     430      object o = new ProtoBufSerializer().Deserialize(tempFile);
    401431      Assert.AreEqual(
    402432        DebugStringGenerator.Serialize(cs),
     
    415445
    416446    [TestMethod]
    417     [TestCategory("Persistence")]
     447    [TestCategory("Persistence.Fossil")]
    418448    [TestProperty("Time", "short")]
    419449    public void ArrayCreation() {
     
    431461                              new[] { 1, 2 }, new[] { 3, 4 });
    432462      arrayListArray[2].Add(a);
    433       XmlGenerator.Serialize(arrayListArray, tempFile);
    434       object o = XmlParser.Deserialize(tempFile);
     463      new ProtoBufSerializer().Serialize(arrayListArray, tempFile);
     464      object o = new ProtoBufSerializer().Deserialize(tempFile);
    435465      Assert.AreEqual(
    436466        DebugStringGenerator.Serialize(arrayListArray),
     
    444474
    445475    [TestMethod]
    446     [TestCategory("Persistence")]
     476    [TestCategory("Persistence.Fossil")]
    447477    [TestProperty("Time", "short")]
    448478    public void CustomSerializationProperty() {
    449479      Manager m = new Manager();
    450       XmlGenerator.Serialize(m, tempFile);
    451       Manager newM = (Manager)XmlParser.Deserialize(tempFile);
     480      new ProtoBufSerializer().Serialize(m, tempFile);
     481      Manager newM = (Manager)new ProtoBufSerializer().Deserialize(tempFile);
    452482      Assert.AreNotEqual(
    453483        DebugStringGenerator.Serialize(m),
     
    460490
    461491    [TestMethod]
    462     [TestCategory("Persistence")]
     492    [TestCategory("Persistence.Fossil")]
    463493    [TestProperty("Time", "short")]
    464494    public void Primitives() {
    465495      PrimitivesTest sdt = new PrimitivesTest();
    466       XmlGenerator.Serialize(sdt, tempFile);
    467       object o = XmlParser.Deserialize(tempFile);
     496      new ProtoBufSerializer().Serialize(sdt, tempFile);
     497      object o = new ProtoBufSerializer().Deserialize(tempFile);
    468498      Assert.AreEqual(
    469499        DebugStringGenerator.Serialize(sdt),
     
    472502
    473503    [TestMethod]
    474     [TestCategory("Persistence")]
     504    [TestCategory("Persistence.Fossil")]
    475505    [TestProperty("Time", "short")]
    476506    public void MultiDimensionalArray() {
     
    479509        {"Beten", "und", "Arbeiten"}
    480510      };
    481       XmlGenerator.Serialize(mDimString, tempFile);
    482       object o = XmlParser.Deserialize(tempFile);
     511      new ProtoBufSerializer().Serialize(mDimString, tempFile);
     512      object o = new ProtoBufSerializer().Deserialize(tempFile);
    483513      Assert.AreEqual(
    484514        DebugStringGenerator.Serialize(mDimString),
     
    486516    }
    487517
    488     [StorableClass]
     518    [StorableType("59E73F41-B9D4-489B-AA9C-3A72173498CC")]
    489519    public class NestedType {
    490520      [Storable]
     
    499529        return value.GetHashCode();
    500530      }
    501     }
    502 
    503     [TestMethod]
    504     [TestCategory("Persistence")]
     531
     532      [StorableConstructor]
     533      protected NestedType(StorableConstructorFlag _) {
     534      }
     535      public NestedType() {
     536      }
     537    }
     538
     539    [TestMethod]
     540    [TestCategory("Persistence.Fossil")]
    505541    [TestProperty("Time", "short")]
    506542    public void NestedTypeTest() {
    507543      NestedType t = new NestedType();
    508       XmlGenerator.Serialize(t, tempFile);
    509       object o = XmlParser.Deserialize(tempFile);
     544      new ProtoBufSerializer().Serialize(t, tempFile);
     545      object o = new ProtoBufSerializer().Deserialize(tempFile);
    510546      Assert.AreEqual(
    511547        DebugStringGenerator.Serialize(t),
     
    516552
    517553    [TestMethod]
    518     [TestCategory("Persistence")]
     554    [TestCategory("Persistence.Fossil")]
    519555    [TestProperty("Time", "short")]
    520556    public void SimpleArray() {
    521557      string[] strings = { "ora", "et", "labora" };
    522       XmlGenerator.Serialize(strings, tempFile);
    523       object o = XmlParser.Deserialize(tempFile);
     558      new ProtoBufSerializer().Serialize(strings, tempFile);
     559      object o = new ProtoBufSerializer().Deserialize(tempFile);
    524560      Assert.AreEqual(
    525561        DebugStringGenerator.Serialize(strings),
     
    528564
    529565    [TestMethod]
    530     [TestCategory("Persistence")]
     566    [TestCategory("Persistence.Fossil")]
    531567    [TestProperty("Time", "short")]
    532568    public void PrimitiveRoot() {
    533       XmlGenerator.Serialize(12.3f, tempFile);
    534       object o = XmlParser.Deserialize(tempFile);
     569      new ProtoBufSerializer().Serialize(12.3f, tempFile);
     570      object o = new ProtoBufSerializer().Deserialize(tempFile);
    535571      Assert.AreEqual(
    536572        DebugStringGenerator.Serialize(12.3f),
     
    582618
    583619    [TestMethod]
    584     [TestCategory("Persistence")]
    585     [TestProperty("Time", "short")]
    586     public void Number2StringDecomposer() {
    587       NumberTest sdt = new NumberTest();
    588       XmlGenerator.Serialize(sdt, tempFile,
    589         new Configuration(new XmlFormat(),
    590           new List<IPrimitiveSerializer> { new String2XmlSerializer() },
    591           new List<ICompositeSerializer> {
    592             new StorableSerializer(),
    593             new Number2StringSerializer() }));
    594       object o = XmlParser.Deserialize(tempFile);
    595       Assert.AreEqual(
    596         DebugStringGenerator.Serialize(sdt),
    597         DebugStringGenerator.Serialize(o));
    598       Assert.IsTrue(sdt.Equals(o));
    599     }
    600 
    601     [TestMethod]
    602     [TestCategory("Persistence")]
     620    [TestCategory("Persistence.Fossil")]
    603621    [TestProperty("Time", "short")]
    604622    public void Enums() {
     
    607625      et.complexEnum = ComplexEnum.three;
    608626      et.trickyEnum = TrickyEnum.two | TrickyEnum.one;
    609       XmlGenerator.Serialize(et, tempFile);
    610       EnumTest newEt = (EnumTest)XmlParser.Deserialize(tempFile);
     627      new ProtoBufSerializer().Serialize(et, tempFile);
     628      EnumTest newEt = (EnumTest)new ProtoBufSerializer().Deserialize(tempFile);
    611629      Assert.AreEqual(et.simpleEnum, SimpleEnum.two);
    612630      Assert.AreEqual(et.complexEnum, ComplexEnum.three);
     
    615633
    616634    [TestMethod]
    617     [TestCategory("Persistence")]
     635    [TestCategory("Persistence.Fossil")]
    618636    [TestProperty("Time", "short")]
    619637    public void TestAliasingWithOverriddenEquals() {
     
    623641      Assert.AreEqual(ints[0], ints[1]);
    624642      Assert.AreNotSame(ints[0], ints[1]);
    625       XmlGenerator.Serialize(ints, tempFile);
    626       List<IntWrapper> newInts = (List<IntWrapper>)XmlParser.Deserialize(tempFile);
     643      new ProtoBufSerializer().Serialize(ints, tempFile);
     644      List<IntWrapper> newInts = (List<IntWrapper>)new ProtoBufSerializer().Deserialize(tempFile);
    627645      Assert.AreEqual(newInts[0].Value, 1);
    628646      Assert.AreEqual(newInts[1].Value, 1);
     
    632650
    633651    [TestMethod]
    634     [TestCategory("Persistence")]
    635     [TestProperty("Time", "short")]
    636     public void NonDefaultConstructorTest() {
    637       NonDefaultConstructorClass c = new NonDefaultConstructorClass(1);
    638       try {
    639         XmlGenerator.Serialize(c, tempFile);
    640         Assert.Fail("Exception not thrown");
    641       } catch (PersistenceException) {
    642       }
    643     }
    644 
    645     [TestMethod]
    646     [TestCategory("Persistence")]
     652    [TestCategory("Persistence.Fossil")]
    647653    [TestProperty("Time", "short")]
    648654    public void TestSavingException() {
    649655      List<int> list = new List<int> { 1, 2, 3 };
    650       XmlGenerator.Serialize(list, tempFile);
     656      new ProtoBufSerializer().Serialize(list, tempFile);
    651657      NonSerializable s = new NonSerializable();
    652658      try {
    653         XmlGenerator.Serialize(s, tempFile);
     659        new ProtoBufSerializer().Serialize(s, tempFile);
    654660        Assert.Fail("Exception expected");
    655661      } catch (PersistenceException) { }
    656       List<int> newList = (List<int>)XmlParser.Deserialize(tempFile);
     662      List<int> newList = (List<int>)new ProtoBufSerializer().Deserialize(tempFile);
    657663      Assert.AreEqual(list[0], newList[0]);
    658664      Assert.AreEqual(list[1], newList[1]);
     
    660666
    661667    [TestMethod]
    662     [TestCategory("Persistence")]
     668    [TestCategory("Persistence.Fossil")]
    663669    [TestProperty("Time", "short")]
    664670    public void TestTypeStringConversion() {
     
    672678
    673679    [TestMethod]
    674     [TestCategory("Persistence")]
     680    [TestCategory("Persistence.Fossil")]
    675681    [TestProperty("Time", "short")]
    676682    public void TestHexadecimalPublicKeyToken() {
     
    682688
    683689    [TestMethod]
    684     [TestCategory("Persistence")]
     690    [TestCategory("Persistence.Fossil")]
    685691    [TestProperty("Time", "short")]
    686692    public void TestMultipleFailure() {
     
    690696      l.Add(new NonSerializable());
    691697      try {
    692         Serializer s = new Serializer(l,
    693           ConfigurationService.Instance.GetConfiguration(new XmlFormat()),
    694           "ROOT", true);
    695         StringBuilder tokens = new StringBuilder();
    696         foreach (var token in s) {
    697           tokens.Append(token.ToString());
    698         }
     698        var s = new ProtoBufSerializer();
     699        s.Serialize(l);
    699700        Assert.Fail("Exception expected");
    700701      } catch (PersistenceException px) {
    701         Assert.AreEqual(3, px.Data.Count);
    702       }
    703     }
    704 
    705     [TestMethod]
    706     [TestCategory("Persistence")]
    707     [TestProperty("Time", "short")]
    708     public void TestAssemblyVersionCheck() {
    709       IntWrapper i = new IntWrapper(1);
    710       Serializer s = new Serializer(i, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    711       XmlGenerator g = new XmlGenerator();
    712       StringBuilder dataString = new StringBuilder();
    713       foreach (var token in s) {
    714         dataString.Append(g.Format(token));
    715       }
    716       StringBuilder typeString = new StringBuilder();
    717       foreach (var line in g.Format(s.TypeCache))
    718         typeString.Append(line);
    719       Deserializer d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(typeString.ToString())));
    720       XmlParser p = new XmlParser(new StringReader(dataString.ToString()));
    721       IntWrapper newI = (IntWrapper)d.Deserialize(p);
    722       Assert.AreEqual(i.Value, newI.Value);
    723 
    724       string newTypeString = Regex.Replace(typeString.ToString(),
    725         "Version=\\d+\\.\\d+\\.\\d+\\.\\d+",
    726         "Version=0.0.9999.9999");
    727       try {
    728         d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));
    729         Assert.Fail("Exception expected");
    730       } catch (PersistenceException x) {
    731         Assert.IsTrue(x.Message.Contains("incompatible"));
    732       }
    733       newTypeString = Regex.Replace(typeString.ToString(),
    734         "Version=(\\d+\\.\\d+)\\.\\d+\\.\\d+",
    735         "Version=$1.9999.9999");
    736       try {
    737         d = new Deserializer(XmlParser.ParseTypeCache(new StringReader(newTypeString)));
    738         Assert.Fail("Exception expected");
    739       } catch (PersistenceException x) {
    740         Assert.IsTrue(x.Message.Contains("newer"));
    741       }
    742     }
    743 
    744     [TestMethod]
    745     [TestCategory("Persistence")]
     702      }
     703    }
     704
     705    [TestMethod]
     706    [TestCategory("Persistence.Fossil")]
    746707    [TestProperty("Time", "short")]
    747708    public void InheritanceTest() {
    748709      New n = new New();
    749       XmlGenerator.Serialize(n, tempFile);
    750       New nn = (New)XmlParser.Deserialize(tempFile);
     710      new ProtoBufSerializer().Serialize(n, tempFile);
     711      New nn = (New)new ProtoBufSerializer().Deserialize(tempFile);
    751712      Assert.AreEqual(n.Name, nn.Name);
    752713      Assert.AreEqual(((Override)n).Name, ((Override)nn).Name);
    753714    }
    754715
    755     [StorableClass]
     716    [StorableType("78636BDB-03B9-4BA1-979D-358997AA8063")]
    756717    class Child {
    757718      [Storable]
    758719      public GrandParent grandParent;
    759     }
    760 
    761     [StorableClass]
     720
     721      [StorableConstructor]
     722      protected Child(StorableConstructorFlag _) {
     723      }
     724      public Child() {
     725      }
     726    }
     727
     728    [StorableType("B90F2371-DE30-48ED-BDAA-671B175C5698")]
    762729    class Parent {
    763730      [Storable]
    764731      public Child child;
    765     }
    766 
    767     [StorableClass]
     732
     733      [StorableConstructor]
     734      protected Parent(StorableConstructorFlag _) {
     735      }
     736      public Parent() {
     737      }
     738    }
     739
     740    [StorableType("C48C28A9-F197-4B75-A21D-F21EF6AC0602")]
    768741    class GrandParent {
    769742      [Storable]
    770743      public Parent parent;
    771     }
    772 
    773     [TestMethod]
    774     [TestCategory("Persistence")]
     744
     745      [StorableConstructor]
     746      protected GrandParent(StorableConstructorFlag _) {
     747      }
     748      public GrandParent() {
     749      }
     750    }
     751
     752    [TestMethod]
     753    [TestCategory("Persistence.Fossil")]
    775754    [TestProperty("Time", "short")]
    776755    public void InstantiateParentChainReference() {
     
    780759      gp.parent.child.grandParent = gp;
    781760      Assert.AreSame(gp, gp.parent.child.grandParent);
    782       XmlGenerator.Serialize(gp, tempFile);
    783       GrandParent newGp = (GrandParent)XmlParser.Deserialize(tempFile);
     761      new ProtoBufSerializer().Serialize(gp, tempFile);
     762      GrandParent newGp = (GrandParent)new ProtoBufSerializer().Deserialize(tempFile);
    784763      Assert.AreSame(newGp, newGp.parent.child.grandParent);
    785764    }
    786765
     766    [StorableType("FB4F08BB-6B65-4FBE-BA72-531DB2194F1F")]
    787767    struct TestStruct {
    788768      int value;
     
    796776
    797777    [TestMethod]
    798     [TestCategory("Persistence")]
     778    [TestCategory("Persistence.Fossil")]
    799779    [TestProperty("Time", "short")]
    800780    public void StructTest() {
    801781      TestStruct s = new TestStruct(10);
    802       XmlGenerator.Serialize(s, tempFile);
    803       TestStruct newS = (TestStruct)XmlParser.Deserialize(tempFile);
     782      new ProtoBufSerializer().Serialize(s, tempFile);
     783      TestStruct newS = (TestStruct)new ProtoBufSerializer().Deserialize(tempFile);
    804784      Assert.AreEqual(s, newS);
    805785    }
    806786
    807787    [TestMethod]
    808     [TestCategory("Persistence")]
     788    [TestCategory("Persistence.Fossil")]
    809789    [TestProperty("Time", "short")]
    810790    public void PointTest() {
    811791      Point p = new Point(12, 34);
    812       XmlGenerator.Serialize(p, tempFile);
    813       Point newP = (Point)XmlParser.Deserialize(tempFile);
     792      new ProtoBufSerializer().Serialize(p, tempFile);
     793      Point newP = (Point)new ProtoBufSerializer().Deserialize(tempFile);
    814794      Assert.AreEqual(p, newP);
    815795    }
    816796
    817797    [TestMethod]
    818     [TestCategory("Persistence")]
     798    [TestCategory("Persistence.Fossil")]
    819799    [TestProperty("Time", "short")]
    820800    public void NullableValueTypes() {
    821801      double?[] d = new double?[] { null, 1, 2, 3 };
    822       XmlGenerator.Serialize(d, tempFile);
    823       double?[] newD = (double?[])XmlParser.Deserialize(tempFile);
     802      new ProtoBufSerializer().Serialize(d, tempFile);
     803      double?[] newD = (double?[])new ProtoBufSerializer().Deserialize(tempFile);
    824804      Assert.AreEqual(d[0], newD[0]);
    825805      Assert.AreEqual(d[1], newD[1]);
     
    829809
    830810    [TestMethod]
    831     [TestCategory("Persistence")]
     811    [TestCategory("Persistence.Fossil")]
    832812    [TestProperty("Time", "short")]
    833813    public void BitmapTest() {
    834814      Icon icon = System.Drawing.SystemIcons.Hand;
    835815      Bitmap bitmap = icon.ToBitmap();
    836       XmlGenerator.Serialize(bitmap, tempFile);
    837       Bitmap newBitmap = (Bitmap)XmlParser.Deserialize(tempFile);
     816      new ProtoBufSerializer().Serialize(bitmap, tempFile);
     817      Bitmap newBitmap = (Bitmap)new ProtoBufSerializer().Deserialize(tempFile);
    838818
    839819      Assert.AreEqual(bitmap.Size, newBitmap.Size);
     
    843823    }
    844824
    845     [StorableClass]
     825    [StorableType("5924A5A2-24C7-4588-951E-61212B041B0A")]
    846826    private class PersistenceHooks {
    847827      [Storable]
     
    859839        sum = a + b;
    860840      }
    861     }
    862 
    863     [TestMethod]
    864     [TestCategory("Persistence")]
     841
     842      [StorableConstructor]
     843      protected PersistenceHooks(StorableConstructorFlag _) {
     844      }
     845      public PersistenceHooks() {
     846      }
     847    }
     848
     849    [TestMethod]
     850    [TestCategory("Persistence.Fossil")]
    865851    [TestProperty("Time", "short")]
    866852    public void HookTest() {
     
    870856      Assert.IsFalse(hookTest.WasSerialized);
    871857      Assert.AreEqual(hookTest.sum, 0);
    872       XmlGenerator.Serialize(hookTest, tempFile);
     858      new ProtoBufSerializer().Serialize(hookTest, tempFile);
    873859      Assert.IsTrue(hookTest.WasSerialized);
    874860      Assert.AreEqual(hookTest.sum, 0);
    875       PersistenceHooks newHookTest = (PersistenceHooks)XmlParser.Deserialize(tempFile);
     861      PersistenceHooks newHookTest = (PersistenceHooks)new ProtoBufSerializer().Deserialize(tempFile);
    876862      Assert.AreEqual(newHookTest.a, hookTest.a);
    877863      Assert.AreEqual(newHookTest.b, hookTest.b);
     
    880866    }
    881867
    882     [StorableClass]
     868    [StorableType("35824217-F1BC-450F-BB40-9B0A4F7C7582")]
    883869    private class CustomConstructor {
    884870      public string Value = "none";
     
    887873      }
    888874      [StorableConstructor]
    889       private CustomConstructor(bool deserializing) {
    890         Assert.IsTrue(deserializing);
     875      private CustomConstructor(StorableConstructorFlag _) {
    891876        Value = "persistence";
    892877      }
     
    894879
    895880    [TestMethod]
    896     [TestCategory("Persistence")]
     881    [TestCategory("Persistence.Fossil")]
    897882    [TestProperty("Time", "short")]
    898883    public void TestCustomConstructor() {
    899884      CustomConstructor cc = new CustomConstructor();
    900885      Assert.AreEqual(cc.Value, "default");
    901       XmlGenerator.Serialize(cc, tempFile);
    902       CustomConstructor newCC = (CustomConstructor)XmlParser.Deserialize(tempFile);
     886      new ProtoBufSerializer().Serialize(cc, tempFile);
     887      CustomConstructor newCC = (CustomConstructor)new ProtoBufSerializer().Deserialize(tempFile);
    903888      Assert.AreEqual(newCC.Value, "persistence");
    904889    }
    905890
    906     [StorableClass]
    907     public class ExplodingDefaultConstructor {
    908       public ExplodingDefaultConstructor() {
    909         throw new Exception("this constructor will always fail");
    910       }
    911       public ExplodingDefaultConstructor(string password) {
    912       }
    913     }
    914 
    915     [TestMethod]
    916     [TestCategory("Persistence")]
    917     [TestProperty("Time", "short")]
    918     public void TestConstructorExceptionUnwrapping() {
    919       ExplodingDefaultConstructor x = new ExplodingDefaultConstructor("password");
    920       XmlGenerator.Serialize(x, tempFile);
    921       try {
    922         ExplodingDefaultConstructor newX = (ExplodingDefaultConstructor)XmlParser.Deserialize(tempFile);
    923         Assert.Fail("Exception expected");
    924       } catch (PersistenceException pe) {
    925         Assert.AreEqual(pe.InnerException.Message, "this constructor will always fail");
    926       }
    927     }
    928 
    929     [TestMethod]
    930     [TestCategory("Persistence")]
    931     [TestProperty("Time", "short")]
    932     public void TestRejectionJustifications() {
    933       NonSerializable ns = new NonSerializable();
    934       try {
    935         XmlGenerator.Serialize(ns, tempFile);
    936         Assert.Fail("PersistenceException expected");
    937       } catch (PersistenceException x) {
    938         Assert.IsTrue(x.Message.Contains(new StorableSerializer().JustifyRejection(typeof(NonSerializable))));
    939       }
    940     }
    941 
    942     [TestMethod]
    943     [TestCategory("Persistence")]
     891    [TestMethod]
     892    [TestCategory("Persistence.Fossil")]
    944893    [TestProperty("Time", "short")]
    945894    public void TestStreaming() {
    946895      using (MemoryStream stream = new MemoryStream()) {
    947896        Root r = InitializeComplexStorable();
    948         XmlGenerator.Serialize(r, stream);
     897        var ser = new ProtoBufSerializer();
     898        ser.Serialize(r, stream);
    949899        using (MemoryStream stream2 = new MemoryStream(stream.ToArray())) {
    950           Root newR = (Root)XmlParser.Deserialize(stream2);
     900          Root newR = (Root)ser.Deserialize(stream2);
    951901          CompareComplexStorables(r, newR);
    952902        }
     
    954904    }
    955905
    956     [StorableClass]
     906    [StorableType("7CD5F148-397E-4539-88E0-EE19907E8BA6")]
    957907    public class HookInheritanceTestBase {
    958908      [Storable]
     
    963913        link = a;
    964914      }
    965     }
    966 
    967     [StorableClass]
     915
     916      [StorableConstructor]
     917      protected HookInheritanceTestBase(StorableConstructorFlag _) {
     918      }
     919      public HookInheritanceTestBase() {
     920      }
     921    }
     922
     923    [StorableType("79E3EF89-A19A-408B-A18C-BFEB345159F0")]
    968924    public class HookInheritanceTestDerivedClass : HookInheritanceTestBase {
    969925      [Storable]
     
    974930        link = b;
    975931      }
    976     }
    977 
    978     [TestMethod]
    979     [TestCategory("Persistence")]
     932
     933      [StorableConstructor]
     934      protected HookInheritanceTestDerivedClass(StorableConstructorFlag _) : base(_) {
     935      }
     936      public HookInheritanceTestDerivedClass() {
     937      }
     938    }
     939
     940    [TestMethod]
     941    [TestCategory("Persistence.Fossil")]
    980942    [TestProperty("Time", "short")]
    981943    public void TestLinkInheritance() {
    982944      HookInheritanceTestDerivedClass c = new HookInheritanceTestDerivedClass();
    983945      c.a = new object();
    984       XmlGenerator.Serialize(c, tempFile);
    985       HookInheritanceTestDerivedClass newC = (HookInheritanceTestDerivedClass)XmlParser.Deserialize(tempFile);
     946      new ProtoBufSerializer().Serialize(c, tempFile);
     947      HookInheritanceTestDerivedClass newC = (HookInheritanceTestDerivedClass)new ProtoBufSerializer().Deserialize(tempFile);
    986948      Assert.AreSame(c.b, c.link);
    987949    }
    988950
    989     [StorableClass(StorableClassType.AllFields)]
     951    [StorableType(StorableMemberSelection.AllFields, "B32F5C7A-F1C5-4B96-8A61-01E0DB1C526B")]
    990952    public class AllFieldsStorable {
    991953      public int Value1 = 1;
     
    995957      public int Value4 { get; private set; }
    996958      [StorableConstructor]
    997       public AllFieldsStorable(bool isDeserializing) {
    998         if (!isDeserializing) {
    999           Value1 = 12;
    1000           Value2 = 23;
    1001           Value3 = 34;
    1002           Value4 = 56;
    1003         }
    1004       }
    1005     }
    1006 
    1007     [TestMethod]
    1008     [TestCategory("Persistence")]
     959      protected AllFieldsStorable(StorableConstructorFlag _) { }
     960      public AllFieldsStorable() {
     961        Value1 = 12;
     962        Value2 = 23;
     963        Value3 = 34;
     964        Value4 = 56;
     965      }
     966    }
     967
     968    [TestMethod]
     969    [TestCategory("Persistence.Fossil")]
    1009970    [TestProperty("Time", "short")]
    1010971    public void TestStorableClassDiscoveryAllFields() {
    1011       AllFieldsStorable afs = new AllFieldsStorable(false);
    1012       XmlGenerator.Serialize(afs, tempFile);
    1013       AllFieldsStorable newAfs = (AllFieldsStorable)XmlParser.Deserialize(tempFile);
     972      AllFieldsStorable afs = new AllFieldsStorable();
     973      new ProtoBufSerializer().Serialize(afs, tempFile);
     974      AllFieldsStorable newAfs = (AllFieldsStorable)new ProtoBufSerializer().Deserialize(tempFile);
    1014975      Assert.AreEqual(afs.Value1, newAfs.Value1);
    1015976      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    1018979    }
    1019980
    1020     [StorableClass(StorableClassType.AllProperties)]
     981    [StorableType(StorableMemberSelection.AllProperties, "60EE99CA-B391-4211-9FFB-2677490B33B6")]
    1021982    public class AllPropertiesStorable {
    1022983      public int Value1 = 1;
     
    1026987      public int Value4 { get; private set; }
    1027988      [StorableConstructor]
    1028       public AllPropertiesStorable(bool isDeserializing) {
    1029         if (!isDeserializing) {
    1030           Value1 = 12;
    1031           Value2 = 23;
    1032           Value3 = 34;
    1033           Value4 = 56;
    1034         }
    1035       }
    1036     }
    1037 
    1038     [TestMethod]
    1039     [TestCategory("Persistence")]
     989      protected AllPropertiesStorable(StorableConstructorFlag _) { }
     990      public AllPropertiesStorable() {
     991        Value1 = 12;
     992        Value2 = 23;
     993        Value3 = 34;
     994        Value4 = 56;
     995      }
     996    }
     997
     998    [TestMethod]
     999    [TestCategory("Persistence.Fossil")]
    10401000    [TestProperty("Time", "short")]
    10411001    public void TestStorableClassDiscoveryAllProperties() {
    1042       AllPropertiesStorable afs = new AllPropertiesStorable(false);
    1043       XmlGenerator.Serialize(afs, tempFile);
    1044       AllPropertiesStorable newAfs = (AllPropertiesStorable)XmlParser.Deserialize(tempFile);
     1002      AllPropertiesStorable afs = new AllPropertiesStorable();
     1003      new ProtoBufSerializer().Serialize(afs, tempFile);
     1004      AllPropertiesStorable newAfs = (AllPropertiesStorable)new ProtoBufSerializer().Deserialize(tempFile);
    10451005      Assert.AreEqual(1, newAfs.Value1);
    10461006      Assert.AreEqual(2, newAfs.Value2);
     
    10501010    }
    10511011
    1052     [StorableClass(StorableClassType.AllFieldsAndAllProperties)]
     1012    [StorableType(StorableMemberSelection.AllFieldsAndAllProperties, "97FAFC16-EC58-44CC-A833-CB951C0DD23B")]
    10531013    public class AllFieldsAndAllPropertiesStorable {
    10541014      public int Value1 = 1;
     
    10581018      public int Value4 { get; private set; }
    10591019      [StorableConstructor]
    1060       public AllFieldsAndAllPropertiesStorable(bool isDeserializing) {
    1061         if (!isDeserializing) {
    1062           Value1 = 12;
    1063           Value2 = 23;
    1064           Value3 = 34;
    1065           Value4 = 56;
    1066         }
    1067       }
    1068     }
    1069 
    1070     [TestMethod]
    1071     [TestCategory("Persistence")]
     1020      protected AllFieldsAndAllPropertiesStorable(StorableConstructorFlag _) { }
     1021      public AllFieldsAndAllPropertiesStorable() {
     1022        Value1 = 12;
     1023        Value2 = 23;
     1024        Value3 = 34;
     1025        Value4 = 56;
     1026      }
     1027    }
     1028
     1029    [TestMethod]
     1030    [TestCategory("Persistence.Fossil")]
    10721031    [TestProperty("Time", "short")]
    10731032    public void TestStorableClassDiscoveryAllFieldsAndAllProperties() {
    1074       AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable(false);
    1075       XmlGenerator.Serialize(afs, tempFile);
    1076       AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)XmlParser.Deserialize(tempFile);
     1033      AllFieldsAndAllPropertiesStorable afs = new AllFieldsAndAllPropertiesStorable();
     1034      new ProtoBufSerializer().Serialize(afs, tempFile);
     1035      AllFieldsAndAllPropertiesStorable newAfs = (AllFieldsAndAllPropertiesStorable)new ProtoBufSerializer().Deserialize(tempFile);
    10771036      Assert.AreEqual(afs.Value1, newAfs.Value1);
    10781037      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    10811040    }
    10821041
    1083     [StorableClass(StorableClassType.MarkedOnly)]
     1042    [StorableType("74BDE240-59D5-48C9-9A2A-5D44750DAF78")]
    10841043    public class MarkedOnlyStorable {
    10851044      public int Value1 = 1;
     
    10891048      public int Value4 { get; private set; }
    10901049      [StorableConstructor]
    1091       public MarkedOnlyStorable(bool isDeserializing) {
    1092         if (!isDeserializing) {
    1093           Value1 = 12;
    1094           Value2 = 23;
    1095           Value3 = 34;
    1096           Value4 = 56;
    1097         }
    1098       }
    1099     }
    1100 
    1101     [TestMethod]
    1102     [TestCategory("Persistence")]
     1050      protected MarkedOnlyStorable(StorableConstructorFlag _) { }
     1051      public MarkedOnlyStorable() {
     1052        Value1 = 12;
     1053        Value2 = 23;
     1054        Value3 = 34;
     1055        Value4 = 56;
     1056      }
     1057    }
     1058
     1059    [TestMethod]
     1060    [TestCategory("Persistence.Fossil")]
    11031061    [TestProperty("Time", "short")]
    11041062    public void TestStorableClassDiscoveryMarkedOnly() {
    1105       MarkedOnlyStorable afs = new MarkedOnlyStorable(false);
    1106       XmlGenerator.Serialize(afs, tempFile);
    1107       MarkedOnlyStorable newAfs = (MarkedOnlyStorable)XmlParser.Deserialize(tempFile);
     1063      MarkedOnlyStorable afs = new MarkedOnlyStorable();
     1064      new ProtoBufSerializer().Serialize(afs, tempFile);
     1065      MarkedOnlyStorable newAfs = (MarkedOnlyStorable)new ProtoBufSerializer().Deserialize(tempFile);
    11081066      Assert.AreEqual(1, newAfs.Value1);
    11091067      Assert.AreEqual(afs.Value2, newAfs.Value2);
     
    11131071
    11141072    [TestMethod]
    1115     [TestCategory("Persistence")]
     1073    [TestCategory("Persistence.Fossil")]
    11161074    [TestProperty("Time", "short")]
    11171075    public void TestLineEndings() {
     
    11201078      foreach (var br in lineBreaks)
    11211079        lines.Add("line1" + br + "line2");
    1122       XmlGenerator.Serialize(lines, tempFile);
    1123       List<string> newLines = XmlParser.Deserialize<List<string>>(tempFile);
     1080      new ProtoBufSerializer().Serialize(lines, tempFile);
     1081      List<string> newLines = (List<string>)new ProtoBufSerializer().Deserialize(tempFile);
    11241082      Assert.AreEqual(lines.Count, newLines.Count);
    11251083      for (int i = 0; i < lineBreaks.Count; i++) {
     
    11291087
    11301088    [TestMethod]
    1131     [TestCategory("Persistence")]
     1089    [TestCategory("Persistence.Fossil")]
    11321090    [TestProperty("Time", "short")]
    11331091    public void TestSpecialNumbers() {
     
    11361094      Assert.IsTrue(double.IsNegativeInfinity(specials[1]));
    11371095      Assert.IsTrue(double.IsNaN(specials[2]));
    1138       XmlGenerator.Serialize(specials, tempFile);
    1139       List<double> newSpecials = XmlParser.Deserialize<List<double>>(tempFile);
     1096      new ProtoBufSerializer().Serialize(specials, tempFile);
     1097      List<double> newSpecials = (List<double>)new ProtoBufSerializer().Deserialize(tempFile);
    11401098      Assert.IsTrue(double.IsPositiveInfinity(newSpecials[0]));
    11411099      Assert.IsTrue(double.IsNegativeInfinity(newSpecials[1]));
     
    11441102
    11451103    [TestMethod]
    1146     [TestCategory("Persistence")]
     1104    [TestCategory("Persistence.Fossil")]
    11471105    [TestProperty("Time", "short")]
    11481106    public void TestStringSplit() {
     
    11561114
    11571115    [TestMethod]
    1158     [TestCategory("Persistence")]
     1116    [TestCategory("Persistence.Fossil")]
    11591117    [TestProperty("Time", "medium")]
    11601118    public void TestCompactNumberArraySerializer() {
     
    11631121      for (int i = 0; i < a.Length; i++)
    11641122        a[i] = r.Next(10);
    1165       var config = ConfigurationService.Instance.GetDefaultConfig(new XmlFormat());
    1166       config = new Configuration(config.Format,
    1167         config.PrimitiveSerializers.Where(s => s.SourceType != typeof(double[])),
    1168         config.CompositeSerializers);
    1169       XmlGenerator.Serialize(a, tempFile, config);
    1170       double[] newA = XmlParser.Deserialize<double[]>(tempFile);
     1123      new ProtoBufSerializer().Serialize(a, tempFile);
     1124      double[] newA = (double[])new ProtoBufSerializer().Deserialize(tempFile);
    11711125      Assert.AreEqual(a.Length, newA.Length);
    11721126      for (int i = 0; i < a.Rank; i++) {
     
    11781132      }
    11791133    }
     1134    [StorableType("A174C85C-3B7C-477D-9E6C-121301470DDE")]
    11801135    private class IdentityComparer<T> : IEqualityComparer<T> {
    11811136
     
    11871142        return obj.GetHashCode();
    11881143      }
    1189     }
    1190 
    1191     [TestMethod]
    1192     [TestCategory("Persistence")]
     1144
     1145      [StorableConstructor]
     1146      protected IdentityComparer(StorableConstructorFlag _) {
     1147      }
     1148      public IdentityComparer() {
     1149      }
     1150    }
     1151
     1152    [TestMethod]
     1153    [TestCategory("Persistence.Fossil")]
    11931154    [TestProperty("Time", "short")]
    11941155    public void TestHashSetSerializer() {
     
    11971158        new HashSet<int>(new[] { 4, 5, 6 }, new IdentityComparer<int>()),
    11981159      };
    1199       XmlGenerator.Serialize(hashSets, tempFile);
    1200       var newHashSets = XmlParser.Deserialize<List<HashSet<int>>>(tempFile);
     1160      new ProtoBufSerializer().Serialize(hashSets, tempFile);
     1161      var newHashSets = (List<HashSet<int>>)new ProtoBufSerializer().Deserialize(tempFile);
    12011162      Assert.IsTrue(newHashSets[0].Contains(1));
    12021163      Assert.IsTrue(newHashSets[0].Contains(2));
     
    12101171
    12111172    [TestMethod]
    1212     [TestCategory("Persistence")]
     1173    [TestCategory("Persistence.Fossil")]
    12131174    [TestProperty("Time", "short")]
    12141175    public void TestConcreteDictionarySerializer() {
     
    12231184      dictionaries[1].Add(5, 5);
    12241185      dictionaries[1].Add(6, 6);
    1225       XmlGenerator.Serialize(dictionaries, tempFile, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    1226       var newDictionaries = XmlParser.Deserialize<List<Dictionary<int, int>>>(tempFile);
     1186      new ProtoBufSerializer().Serialize(dictionaries, tempFile);
     1187      var newDictionaries = (List<Dictionary<int, int>>)new ProtoBufSerializer().Deserialize(tempFile);
    12271188      Assert.IsTrue(newDictionaries[0].ContainsKey(1));
    12281189      Assert.IsTrue(newDictionaries[0].ContainsKey(2));
     
    12411202    }
    12421203
    1243     [StorableClass]
     1204    [StorableType("A5DAC970-4E03-4B69-A95A-9DAC683D051F")]
    12441205    public class ReadOnlyFail {
    12451206      [Storable]
     
    12471208        get { return "fail"; }
    12481209      }
    1249     }
    1250 
    1251     [TestMethod]
    1252     [TestCategory("Persistence")]
     1210
     1211      [StorableConstructor]
     1212      protected ReadOnlyFail(StorableConstructorFlag _) {
     1213      }
     1214      public ReadOnlyFail() {
     1215      }
     1216    }
     1217
     1218    [TestMethod]
     1219    [TestCategory("Persistence.Fossil")]
    12531220    [TestProperty("Time", "short")]
    12541221    public void TestReadOnlyFail() {
    12551222      try {
    1256         XmlGenerator.Serialize(new ReadOnlyFail(), tempFile);
     1223        new ProtoBufSerializer().Serialize(new ReadOnlyFail(), tempFile);
    12571224        Assert.Fail("Exception expected");
    12581225      } catch (PersistenceException) {
     
    12631230
    12641231
    1265     [StorableClass]
     1232    [StorableType("653EBC18-E461-4F5C-8FD6-9F588AAC70D9")]
    12661233    public class WriteOnlyFail {
    12671234      [Storable]
     
    12691236        set { throw new InvalidOperationException("this property should never be set."); }
    12701237      }
    1271     }
    1272 
    1273     [TestMethod]
    1274     [TestCategory("Persistence")]
     1238
     1239      [StorableConstructor]
     1240      protected WriteOnlyFail(StorableConstructorFlag _) {
     1241      }
     1242      public WriteOnlyFail() {
     1243      }
     1244    }
     1245
     1246    [TestMethod]
     1247    [TestCategory("Persistence.Fossil")]
    12751248    [TestProperty("Time", "short")]
    12761249    public void TestWriteOnlyFail() {
    12771250      try {
    1278         XmlGenerator.Serialize(new WriteOnlyFail(), tempFile);
     1251        new ProtoBufSerializer().Serialize(new WriteOnlyFail(), tempFile);
    12791252        Assert.Fail("Exception expected");
    12801253      } catch (PersistenceException) {
     
    12841257    }
    12851258
    1286     [StorableClass]
     1259    [StorableType("67BEAF29-9D7C-4C82-BD9F-9957798D6A2D")]
    12871260    public class OneWayTest {
     1261      [StorableConstructor]
     1262      protected OneWayTest(StorableConstructorFlag _) {
     1263      }
     1264
    12881265      public OneWayTest() { this.value = "default"; }
    12891266      public string value;
     
    12991276
    13001277    [TestMethod]
    1301     [TestCategory("Persistence")]
    1302     [TestProperty("Time", "short")]
    1303     public void TestOneWaySerialization() {
    1304       var test = new OneWayTest();
    1305       var serializer = new Serializer(test, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    1306       var it = serializer.GetEnumerator();
    1307       it.MoveNext();
    1308       Assert.AreEqual("ROOT", ((BeginToken)it.Current).Name); it.MoveNext();
    1309       Assert.AreEqual("ReadOnly", ((PrimitiveToken)it.Current).Name); it.MoveNext();
    1310       Assert.AreEqual("ROOT", ((EndToken)it.Current).Name); it.MoveNext();
    1311       var deserializer = new Deserializer(new[] {
    1312         new TypeMapping(0, typeof(OneWayTest).AssemblyQualifiedName, typeof(StorableSerializer).AssemblyQualifiedName),
    1313         new TypeMapping(1, typeof(string).AssemblyQualifiedName, typeof(String2XmlSerializer).AssemblyQualifiedName) });
    1314       var newTest = (OneWayTest)deserializer.Deserialize(new ISerializationToken[] {
    1315         new BeginToken("ROOT", 0, 0),
    1316         new PrimitiveToken("WriteOnly", 1, 1, new XmlString("<![CDATA[serial data]]>")),
    1317         new EndToken("ROOT", 0, 0)
    1318       });
    1319       Assert.AreEqual("serial data", newTest.value);
    1320     }
    1321 
    1322     [TestMethod]
    1323     [TestCategory("Persistence")]
    1324     [TestProperty("Time", "short")]
    1325     public void TestTypeCacheExport() {
    1326       var test = new List<List<int>>();
    1327       test.Add(new List<int>() { 1, 2, 3 });
    1328       IEnumerable<Type> types;
    1329       using (var stream = new MemoryStream()) {
    1330         XmlGenerator.Serialize(test, stream, ConfigurationService.Instance.GetConfiguration(new XmlFormat()), false, out types);
    1331       }
    1332       List<Type> t = new List<Type>(types);
    1333       // Assert.IsTrue(t.Contains(typeof(int))); not serialized as an int list is directly transformed into a string
    1334       Assert.IsTrue(t.Contains(typeof(List<int>)));
    1335       Assert.IsTrue(t.Contains(typeof(List<List<int>>)));
    1336       Assert.AreEqual(t.Count, 2);
    1337     }
    1338 
    1339     [TestMethod]
    1340     [TestCategory("Persistence")]
     1278    [TestCategory("Persistence.Fossil")]
    13411279    [TestProperty("Time", "short")]
    13421280    public void TupleTest() {
     
    13461284      var t4 = Tuple.Create(Tuple.Create(1, 2, 3), Tuple.Create(4, 5, 6), Tuple.Create(8, 9, 10));
    13471285      var tuple = Tuple.Create(t1, t2, t3, t4);
    1348       XmlGenerator.Serialize(tuple, tempFile);
    1349       var newTuple = XmlParser.Deserialize<Tuple<Tuple<int>, Tuple<char, string>, Tuple<double, float, int>, Tuple<Tuple<int, int, int>, Tuple<int, int, int>, Tuple<int, int, int>>>>(tempFile);
     1286      new ProtoBufSerializer().Serialize(tuple, tempFile);
     1287      var newTuple = (Tuple<Tuple<int>, Tuple<char, string>, Tuple<double, float, int>, Tuple<Tuple<int, int, int>, Tuple<int, int, int>, Tuple<int, int, int>>>)new ProtoBufSerializer().Deserialize(tempFile);
    13501288      Assert.AreEqual(tuple, newTuple);
    13511289    }
    13521290
    13531291    [TestMethod]
    1354     [TestCategory("Persistence")]
     1292    [TestCategory("Persistence.Fossil")]
    13551293    [TestProperty("Time", "short")]
    13561294    public void FontTest() {
     
    13611299        new Font("Helvetica", 21, FontStyle.Strikeout, GraphicsUnit.Inch, 0, true),
    13621300      };
    1363       XmlGenerator.Serialize(fonts, tempFile);
    1364       var newFonts = XmlParser.Deserialize<List<Font>>(tempFile);
     1301      new ProtoBufSerializer().Serialize(fonts, tempFile);
     1302      var newFonts = (List<Font>)new ProtoBufSerializer().Deserialize(tempFile);
    13651303      Assert.AreEqual(fonts[0], newFonts[0]);
    13661304      Assert.AreEqual(fonts[1], newFonts[1]);
     
    13701308
    13711309    [TestMethod]
    1372     [TestCategory("Persistence")]
     1310    [TestCategory("Persistence.Fossil")]
    13731311    [TestProperty("Time", "medium")]
    13741312    public void ConcurrencyTest() {
     
    13791317          byte[] data;
    13801318          using (var stream = new MemoryStream()) {
    1381             XmlGenerator.Serialize(new GeneticAlgorithm(), stream);
     1319            new ProtoBufSerializer().Serialize(new GeneticAlgorithm(), stream);
    13821320            data = stream.ToArray();
    13831321          }
     
    13881326
    13891327    [TestMethod]
    1390     [TestCategory("Persistence")]
     1328    [TestCategory("Persistence.Fossil")]
    13911329    [TestProperty("Time", "medium")]
    13921330    public void ConcurrentBitmapTest() {
     
    14031341        tasks[i] = Task.Factory.StartNew((idx) => {
    14041342          using (var stream = new MemoryStream()) {
    1405             XmlGenerator.Serialize(b, stream);
     1343            new ProtoBufSerializer().Serialize(b, stream);
    14061344            datas[(int)idx] = stream.ToArray();
    14071345          }
     
    14111349    }
    14121350
     1351    [StorableType("6923FC3A-AC33-4CA9-919F-9707C00A663B")]
    14131352    public class G<T, T2> {
     1353      [StorableType("16B88964-ECB3-4B41-95BC-EE3BE908CE4A")]
    14141354      public class S { }
     1355      [StorableType("23CC1C7C-031E-4CBD-A87A-8F2235803BB4")]
    14151356      public class S2<T3, T4> { }
    14161357    }
    14171358
    14181359    [TestMethod]
    1419     [TestCategory("Persistence")]
     1360    [TestCategory("Persistence.Fossil")]
    14201361    [TestProperty("Time", "short")]
    14211362    public void TestInternalClassOfGeneric() {
     
    14251366        "UseCases.G<Int32,Char>.S",
    14261367        TypeNameParser.Parse(typeName).GetTypeNameInCode(false));
    1427       XmlGenerator.Serialize(s, tempFile);
    1428       var s1 = XmlParser.Deserialize(tempFile);
    1429     }
    1430 
    1431     [TestMethod]
    1432     [TestCategory("Persistence")]
     1368      new ProtoBufSerializer().Serialize(s, tempFile);
     1369      var s1 = new ProtoBufSerializer().Deserialize(tempFile);
     1370    }
     1371
     1372    [TestMethod]
     1373    [TestCategory("Persistence.Fossil")]
    14331374    [TestProperty("Time", "short")]
    14341375    public void TestInternalClassOfGeneric2() {
     
    14381379        "UseCases.G<Int32,Single>.S2<Int32,Char>",
    14391380        TypeNameParser.Parse(typeName).GetTypeNameInCode(false));
    1440       XmlGenerator.Serialize(s, tempFile);
    1441       var s1 = XmlParser.Deserialize(tempFile);
    1442     }
    1443 
    1444     [TestMethod]
    1445     [TestCategory("Persistence")]
     1381      new ProtoBufSerializer().Serialize(s, tempFile);
     1382      var s1 = new ProtoBufSerializer().Deserialize(tempFile);
     1383    }
     1384
     1385    [TestMethod]
     1386    [TestCategory("Persistence.Fossil")]
    14461387    [TestProperty("Time", "short")]
    14471388    public void TestSpecialCharacters() {
    14481389      var s = "abc" + "\x15" + "def";
    1449       XmlGenerator.Serialize(s, tempFile);
    1450       var newS = XmlParser.Deserialize(tempFile);
     1390      new ProtoBufSerializer().Serialize(s, tempFile);
     1391      var newS = new ProtoBufSerializer().Deserialize(tempFile);
    14511392      Assert.AreEqual(s, newS);
    14521393    }
    14531394
    14541395    [TestMethod]
    1455     [TestCategory("Persistence")]
     1396    [TestCategory("Persistence.Fossil")]
    14561397    [TestProperty("Time", "short")]
    14571398    public void TestByteArray() {
     
    14601401      b[1] = 200;
    14611402      b[2] = byte.MaxValue;
    1462       XmlGenerator.Serialize(b, tempFile);
    1463       var newB = (byte[]) XmlParser.Deserialize(tempFile);
     1403      new ProtoBufSerializer().Serialize(b, tempFile);
     1404      var newB = (byte[])new ProtoBufSerializer().Deserialize(tempFile);
    14641405      CollectionAssert.AreEqual(b, newB);
    14651406    }
    14661407
    14671408    [TestMethod]
    1468     [TestCategory("Persistence")]
     1409    [TestCategory("Persistence.Fossil")]
    14691410    [TestProperty("Time", "short")]
    14701411    public void TestOptionalNumberEnumerable() {
    1471       var values = new List<double?> {0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1};
    1472       XmlGenerator.Serialize(values, tempFile);
    1473       var newValues = (List<double?>) XmlParser.Deserialize(tempFile);
     1412      var values = new List<double?> { 0, null, double.NaN, double.PositiveInfinity, double.MaxValue, 1 };
     1413      new ProtoBufSerializer().Serialize(values, tempFile);
     1414      var newValues = (List<double?>)new ProtoBufSerializer().Deserialize(tempFile);
    14741415      CollectionAssert.AreEqual(values, newValues);
    14751416    }
    14761417
    14771418    [TestMethod]
    1478     [TestCategory("Persistence")]
     1419    [TestCategory("Persistence.Fossil")]
    14791420    [TestProperty("Time", "short")]
    14801421    public void TestOptionalDateTimeEnumerable() {
    14811422      var values = new List<DateTime?> { DateTime.MinValue, null, DateTime.Now, DateTime.Now.Add(TimeSpan.FromDays(1)),
    14821423        DateTime.ParseExact("10.09.2014 12:21", "dd.MM.yyyy hh:mm", CultureInfo.InvariantCulture), DateTime.MaxValue};
    1483       XmlGenerator.Serialize(values, tempFile);
    1484       var newValues = (List<DateTime?>) XmlParser.Deserialize(tempFile);
     1424      new ProtoBufSerializer().Serialize(values, tempFile);
     1425      var newValues = (List<DateTime?>)new ProtoBufSerializer().Deserialize(tempFile);
    14851426      CollectionAssert.AreEqual(values, newValues);
    14861427    }
    14871428
    14881429    [TestMethod]
    1489     [TestCategory("Persistence")]
     1430    [TestCategory("Persistence.Fossil")]
    14901431    [TestProperty("Time", "short")]
    14911432    public void TestStringEnumerable() {
    1492       var values = new List<string> {"", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated"};
    1493       XmlGenerator.Serialize(values, tempFile);
    1494       var newValues = (List<String>) XmlParser.Deserialize(tempFile);
     1433      var values = new List<string> { "", null, "s", "string", string.Empty, "123", "<![CDATA[nice]]>", "<![CDATA[nasty unterminated" };
     1434      new ProtoBufSerializer().Serialize(values, tempFile);
     1435      var newValues = (List<String>)new ProtoBufSerializer().Deserialize(tempFile);
    14951436      CollectionAssert.AreEqual(values, newValues);
    14961437    }
    14971438
    14981439    [TestMethod]
    1499     [TestCategory("Persistence")]
     1440    [TestCategory("Persistence.Fossil")]
    15001441    [TestProperty("Time", "short")]
    15011442    public void TestUnicodeCharArray() {
    1502       var s = Encoding.UTF8.GetChars(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
    1503       XmlGenerator.Serialize(s, tempFile);
    1504       var newS = (char[])XmlParser.Deserialize(tempFile);
     1443      var s = Encoding.UTF8.GetChars(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb });
     1444      new ProtoBufSerializer().Serialize(s, tempFile);
     1445      var newS = (char[])new ProtoBufSerializer().Deserialize(tempFile);
    15051446      CollectionAssert.AreEqual(s, newS);
    15061447    }
    15071448
    15081449    [TestMethod]
    1509     [TestCategory("Persistence")]
     1450    [TestCategory("Persistence.Fossil")]
    15101451    [TestProperty("Time", "short")]
    15111452    public void TestUnicode() {
    1512       var s = Encoding.UTF8.GetString(new byte[] {0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb});
    1513       XmlGenerator.Serialize(s, tempFile);
    1514       var newS = XmlParser.Deserialize(tempFile);
     1453      var s = Encoding.UTF8.GetString(new byte[] { 0, 1, 2, 03, 04, 05, 06, 07, 08, 09, 0xa, 0xb });
     1454      new ProtoBufSerializer().Serialize(s, tempFile);
     1455      var newS = new ProtoBufSerializer().Deserialize(tempFile);
    15151456      Assert.AreEqual(s, newS);
    15161457    }
    15171458
    15181459    [TestMethod]
    1519     [TestCategory("Persistence")]
     1460    [TestCategory("Persistence.Fossil")]
    15201461    [TestProperty("Time", "short")]
    15211462    public void TestQueue() {
    1522       var q = new Queue<int>(new[] {1, 2, 3, 4, 0});
    1523       XmlGenerator.Serialize(q, tempFile);
    1524       var newQ = (Queue<int>)XmlParser.Deserialize(tempFile);
     1463      var q = new Queue<int>(new[] { 1, 2, 3, 4, 0 });
     1464      new ProtoBufSerializer().Serialize(q, tempFile);
     1465      var newQ = (Queue<int>)new ProtoBufSerializer().Deserialize(tempFile);
    15251466      CollectionAssert.AreEqual(q, newQ);
    15261467    }
  • branches/2520_PersistenceReintegration/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r16452 r16462  
    112112      <HintPath>..\bin\ALGLIB-3.7.0.dll</HintPath>
    113113      <Private>False</Private>
     114    </Reference>
     115    <Reference Include="Google.Protobuf, Version=3.6.1.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
     116      <HintPath>..\packages\Google.Protobuf.3.6.1\lib\net45\Google.Protobuf.dll</HintPath>
     117    </Reference>
     118    <Reference Include="HEAL.Fossil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     119      <HintPath>..\packages\HEAL.Fossil.1.0.0\lib\netstandard2.0\HEAL.Fossil.dll</HintPath>
    114120    </Reference>
    115121    <Reference Include="HeuristicLab.Algorithms.ALPS-3.3">
     
    582588    <Compile Include="HeuristicLab.Persistence-3.3\StorableAttributeTests.cs" />
    583589    <Compile Include="HeuristicLab.Persistence-3.3\UseCases.cs" />
     590    <Compile Include="HeuristicLab.Persistence.Fossil\StorableAttributeTests.cs" />
     591    <Compile Include="HeuristicLab.Persistence.Fossil\UseCases.cs" />
    584592    <Compile Include="HeuristicLab.PluginInfraStructure-3.3\TypeExtensionsTest.cs" />
    585593    <Compile Include="HeuristicLab.Problems.DataAnalysis-3.4\ClassificationVariableImpactCalculationTest.cs" />
     
    675683    </None>
    676684    <None Include="HeuristicLab.snk" />
     685    <None Include="packages.config" />
    677686    <None Include="Test Resources\GA_SymbReg.hl">
    678687      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Note: See TracChangeset for help on using the changeset viewer.