diff --git a/.build-and-publish-nuget-package.cmd b/.build-and-publish-nuget-package.cmd
new file mode 100644
index 0000000..2954f59
--- /dev/null
+++ b/.build-and-publish-nuget-package.cmd
@@ -0,0 +1,5 @@
+dotnet build --force --no-incremental --configuration Release ./GroBuf.sln
+dotnet pack --no-build --configuration Release ./GroBuf.sln
+cd ./GroBuf/bin/Release
+dotnet nuget push *.nupkg -s https://nuget.org
+pause
\ No newline at end of file
diff --git a/.cake/packages.config b/.cake/packages.config
deleted file mode 100644
index e0dd39b..0000000
--- a/.cake/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..26b6c1c
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,4 @@
+; 4-column space indentation
+[*.cs]
+indent_style = space
+indent_size = 4
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 8337662..a15dd92 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,322 @@
-bin
-obj
-[Dd]ebug
-[Rr]elease
-*.user
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
*.suo
-GroBuf.dll
-GroBuf.pdb
-_ReSharper.*
-Output/
-.cake/*
-!.cake/packages.config
-packages/
-.vs/
\ No newline at end of file
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+**/Properties/launchSettings.json
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# TypeScript v1 declaration files
+typings/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+#.cake/**
+#!.cake/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
diff --git a/.rebuild.cmd b/.rebuild.cmd
index eec1c4d..1a49857 100644
--- a/.rebuild.cmd
+++ b/.rebuild.cmd
@@ -1,3 +1,2 @@
-@echo off
-PowerShell.exe -ExecutionPolicy ByPass -Command "& { %~dp0build.ps1 -Script %~dp0build.cake -Target Build-And-Merge -Configuration Release; exit $LASTEXITCODE }"
+dotnet build --force --no-incremental --configuration Release ./GroBuf.sln
pause
diff --git a/.run-all-tests.cmd b/.run-all-tests.cmd
index 22df998..ae6b9ab 100644
--- a/.run-all-tests.cmd
+++ b/.run-all-tests.cmd
@@ -1,3 +1,2 @@
-@echo off
-PowerShell.exe -ExecutionPolicy ByPass -Command "& { %~dp0build.ps1 -Script %~dp0build.cake -Target Run-All-Tests -Configuration Release; exit $LASTEXITCODE }"
+dotnet test --configuration Release ./GroBuf.Tests/GroBuf.Tests.csproj
pause
\ No newline at end of file
diff --git a/.run-unit-tests.cmd b/.run-unit-tests.cmd
index 874dbeb..5f29970 100644
--- a/.run-unit-tests.cmd
+++ b/.run-unit-tests.cmd
@@ -1,3 +1,2 @@
-@echo off
-PowerShell.exe -ExecutionPolicy ByPass -Command "& { %~dp0build.ps1 -Script %~dp0build.cake -Target Run-Unit-Tests -Configuration Release; exit $LASTEXITCODE }"
+dotnet test --configuration Release --filter TestCategory!=LongRunning ./GroBuf.Tests/GroBuf.Tests.csproj
pause
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..888f257
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,12 @@
+dist: trusty
+sudo: false
+language: csharp
+dotnet: 2.0.0
+mono: none
+script:
+ - dotnet restore ./GroBuf.sln --verbosity m
+ - dotnet build --configuration Release --framework netstandard2.0 ./GroBuf/GroBuf.csproj
+ - dotnet build --configuration Release --framework netcoreapp2.0 ./GroBuf.Tests/GroBuf.Tests.csproj
+ - dotnet test --no-build --configuration Release --framework netcoreapp2.0 --filter TestCategory!=LongRunning ./GroBuf.Tests/GroBuf.Tests.csproj
+
+
diff --git a/Common.DotSettings b/Common.DotSettings
index 05e90f6..a0ab47d 100644
--- a/Common.DotSettings
+++ b/Common.DotSettings
@@ -24,8 +24,11 @@
NEXT_LINE_SHIFTED_2
NEXT_LINE_SHIFTED_2
NEXT_LINE_SHIFTED_2
+ NEVER
+ NEVER
120
False
+ False
<?xml version="1.0" encoding="utf-16"?>
<Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns">
<TypePattern DisplayName="Default Pattern">
@@ -161,11 +164,17 @@
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
False
+ True
True
+ True
+ True
+ True
True
True
+ True
True
True
+ True
True
True
True
diff --git a/GroBuf/Tests/DataSchemeChangedTest.cs b/GroBuf.Tests/DataSchemeChangedTest.cs
similarity index 96%
rename from GroBuf/Tests/DataSchemeChangedTest.cs
rename to GroBuf.Tests/DataSchemeChangedTest.cs
index 0087b4d..cabe18c 100644
--- a/GroBuf/Tests/DataSchemeChangedTest.cs
+++ b/GroBuf.Tests/DataSchemeChangedTest.cs
@@ -1,277 +1,277 @@
-using System;
-using System.Runtime.Serialization;
-
-using GroBuf.DataMembersExtracters;
-
-using NUnit.Framework;
-
-namespace GroBuf.Tests
-{
- [TestFixture]
- public class DataSchemeChangedTest
- {
- [SetUp]
- public void SetUp()
- {
- serializer = new Serializer(new PropertiesExtractor(), null, GroBufOptions.MergeOnRead);
- }
-
- [Test]
- public void PropertyHasBeenAdded()
- {
- var o = new C1_Old {S = "zzz", X = 123};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("zzz", oo.S);
- Assert.AreEqual(123, oo.X);
- Assert.IsNull(oo.D);
- }
-
- [Test]
- public void PropertyHasBeenRemoved()
- {
- var o = new C2_Old {S = "zzz", X = 123, D = 3.14};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("zzz", oo.S);
- Assert.AreEqual(3.14, oo.D);
- }
-
- [Test]
- public void PropertyHasBecomeArray()
- {
- var o = new C3_Old {S = "zzz", X = 123, C3 = new C3_Subclass {S = "qxx"}};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
-
- Assert.IsNotNull(oo.S);
- Assert.AreEqual(1, oo.S.Length);
- Assert.AreEqual("zzz", oo.S[0]);
- Assert.IsNotNull(oo.X);
- Assert.AreEqual(1, oo.X.Length);
- Assert.AreEqual(123, oo.X[0]);
- Assert.IsNotNull(oo.C3);
- Assert.AreEqual(1, oo.C3.Length);
- Assert.IsNotNull(oo.C3[0]);
- Assert.AreEqual("qxx", oo.C3[0].S);
-
- oo = new C3_New {S = new string[0], X = new int[0], C3 = new C3_Subclass[0]};
- serializer.Merge(o, ref oo);
- Assert.IsNotNull(oo.S);
- Assert.AreEqual(1, oo.S.Length);
- Assert.AreEqual("zzz", oo.S[0]);
- Assert.IsNotNull(oo.X);
- Assert.AreEqual(1, oo.X.Length);
- Assert.AreEqual(123, oo.X[0]);
- Assert.IsNotNull(oo.C3);
- Assert.AreEqual(1, oo.C3.Length);
- Assert.IsNotNull(oo.C3[0]);
- Assert.AreEqual("qxx", oo.C3[0].S);
-
- oo = new C3_New {S = new string[1], X = new int[1], C3 = new C3_Subclass[1]};
- serializer.Merge(o, ref oo);
- Assert.IsNotNull(oo.S);
- Assert.AreEqual(1, oo.S.Length);
- Assert.AreEqual("zzz", oo.S[0]);
- Assert.IsNotNull(oo.X);
- Assert.AreEqual(1, oo.X.Length);
- Assert.AreEqual(123, oo.X[0]);
- Assert.IsNotNull(oo.C3);
- Assert.AreEqual(1, oo.C3.Length);
- Assert.IsNotNull(oo.C3[0]);
- Assert.AreEqual("qxx", oo.C3[0].S);
-
- oo = new C3_New {S = new string[2], X = new int[2], C3 = new C3_Subclass[2]};
- serializer.Merge(o, ref oo);
- Assert.IsNotNull(oo.S);
- Assert.AreEqual(2, oo.S.Length);
- Assert.AreEqual("zzz", oo.S[0]);
- Assert.IsNotNull(oo.X);
- Assert.AreEqual(2, oo.X.Length);
- Assert.AreEqual(123, oo.X[0]);
- Assert.IsNotNull(oo.C3);
- Assert.AreEqual(2, oo.C3.Length);
- Assert.IsNotNull(oo.C3[0]);
- Assert.AreEqual("qxx", oo.C3[0].S);
- }
-
- [Test]
- public void TestReadWriteToId()
- {
- var o = new C4_Old {S = "zzz", X = 123};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("zzz", oo.Zzz);
- Assert.AreEqual(123, oo.Qxx);
- }
-
- [Test]
- public void TestReadWriteFromId()
- {
- var o = new C4_New {Zzz = "zzz", Qxx = 123};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("zzz", oo.S);
- Assert.AreEqual(123, oo.X);
- }
-
- [Test]
- public void Test_GroboMember_IdCollision()
- {
- var o = new C5_GroboMember_IdCollision();
- var e = Assert.Throws(() => serializer.Serialize(o));
- Assert.That(e.Message, Is.EqualTo("Hash code collision: members 'C5_GroboMember_IdCollision.X' and 'C5_GroboMember_IdCollision.S' have the same hash code = 1"));
- }
-
- [Test]
- public void Test_GroboMember_EmptyName()
- {
- var o = new C6_GroboMember_EmptyName();
- var e = Assert.Throws(() => serializer.Serialize(o));
- Assert.That(e.Message, Is.EqualTo("Empty grobo name of member 'C6_GroboMember_EmptyName.S'"));
- }
-
- [Test]
- public void Test_GroboMember_EmptyId()
- {
- var o = new C7_GroboMember_EmptyId();
- var e = Assert.Throws(() => serializer.Serialize(o));
- Assert.That(e.Message, Is.EqualTo("Hash code of 'C7_GroboMember_EmptyId.S' equals to zero"));
- }
-
- [Test]
- public void Test_MixedAnnotationAttributes()
- {
- var o = new C8_MixedAnnotationAttributes {S = "zzz", X = 123, Q = -1};
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("zzz", oo.S);
- Assert.AreEqual(123, oo.X);
- Assert.AreEqual(-1, oo.Q);
- }
-
- [Test]
- public void Test_GroboMember_ReadonlyProperty()
- {
- var o = new C9_GroboMember_ReadonlyProperty_Old("GRobas");
- var data = serializer.Serialize(o);
- var oo = serializer.Deserialize(data);
- Assert.AreEqual("GRobas", oo.Zzz);
- }
-
- public class C1_Old
- {
- public string S { get; set; }
- public int X { get; set; }
- }
-
- public class C1_New
- {
- public int X { get; set; }
- public double? D { get; set; }
- public string S { get; set; }
- }
-
- public class C2_Old
- {
- public int X { get; set; }
- public double? D { get; set; }
- public string S { get; set; }
- }
-
- public class C2_New
- {
- public string S { get; set; }
- public double? D { get; set; }
- }
-
- public class C3_Subclass
- {
- public string S { get; set; }
- }
-
- public class C3_Old
- {
- public string S { get; set; }
- public int X { get; set; }
- public C3_Subclass C3 { get; set; }
- }
-
- public class C3_New
- {
- public string[] S { get; set; }
- public int[] X { get; set; }
- public C3_Subclass[] C3 { get; set; }
- }
-
- public class C4_Old
- {
- public string S { get; set; }
- public int X { get; set; }
- }
-
- public class C4_New
- {
- [GroboMember(7770670552212394539)]
- public string Zzz { get; set; }
-
- [GroboMember("X")]
- public int Qxx { get; set; }
- }
-
- public class C5_GroboMember_IdCollision
- {
- [GroboMember(1)]
- public string S { get; set; }
-
- [GroboMember(1)]
- public int X { get; set; }
- }
-
- public class C6_GroboMember_EmptyName
- {
- [GroboMember("")]
- public string S { get; set; }
- }
-
- public class C7_GroboMember_EmptyId
- {
- [GroboMember(0)]
- public string S { get; set; }
- }
-
- public class C8_MixedAnnotationAttributes
- {
- public string S { get; set; }
-
- [DataMember(Name = "Z")]
- public int X { get; set; }
-
- [GroboMember(1)]
- public int? Q { get; set; }
- }
-
- public class C9_GroboMember_ReadonlyProperty_Old
- {
- public C9_GroboMember_ReadonlyProperty_Old(string qxx)
- {
- Qxx = qxx;
- }
-
- public string Qxx { get; }
- }
-
- public class C9_GroboMember_ReadonlyProperty_New
- {
- public C9_GroboMember_ReadonlyProperty_New(string gRobas)
- {
- Zzz = gRobas;
- }
-
- [GroboMember("Qxx")]
- public string Zzz { get; }
- }
-
- private Serializer serializer;
- }
+using System;
+using System.Runtime.Serialization;
+
+using GroBuf.DataMembersExtracters;
+
+using NUnit.Framework;
+
+namespace GroBuf.Tests
+{
+ [TestFixture]
+ public class DataSchemeChangedTest
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ serializer = new Serializer(new PropertiesExtractor(), null, GroBufOptions.MergeOnRead);
+ }
+
+ [Test]
+ public void PropertyHasBeenAdded()
+ {
+ var o = new C1_Old {S = "zzz", X = 123};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("zzz", oo.S);
+ Assert.AreEqual(123, oo.X);
+ Assert.IsNull(oo.D);
+ }
+
+ [Test]
+ public void PropertyHasBeenRemoved()
+ {
+ var o = new C2_Old {S = "zzz", X = 123, D = 3.14};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("zzz", oo.S);
+ Assert.AreEqual(3.14, oo.D);
+ }
+
+ [Test]
+ public void PropertyHasBecomeArray()
+ {
+ var o = new C3_Old {S = "zzz", X = 123, C3 = new C3_Subclass {S = "qxx"}};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+
+ Assert.IsNotNull(oo.S);
+ Assert.AreEqual(1, oo.S.Length);
+ Assert.AreEqual("zzz", oo.S[0]);
+ Assert.IsNotNull(oo.X);
+ Assert.AreEqual(1, oo.X.Length);
+ Assert.AreEqual(123, oo.X[0]);
+ Assert.IsNotNull(oo.C3);
+ Assert.AreEqual(1, oo.C3.Length);
+ Assert.IsNotNull(oo.C3[0]);
+ Assert.AreEqual("qxx", oo.C3[0].S);
+
+ oo = new C3_New {S = new string[0], X = new int[0], C3 = new C3_Subclass[0]};
+ serializer.Merge(o, ref oo);
+ Assert.IsNotNull(oo.S);
+ Assert.AreEqual(1, oo.S.Length);
+ Assert.AreEqual("zzz", oo.S[0]);
+ Assert.IsNotNull(oo.X);
+ Assert.AreEqual(1, oo.X.Length);
+ Assert.AreEqual(123, oo.X[0]);
+ Assert.IsNotNull(oo.C3);
+ Assert.AreEqual(1, oo.C3.Length);
+ Assert.IsNotNull(oo.C3[0]);
+ Assert.AreEqual("qxx", oo.C3[0].S);
+
+ oo = new C3_New {S = new string[1], X = new int[1], C3 = new C3_Subclass[1]};
+ serializer.Merge(o, ref oo);
+ Assert.IsNotNull(oo.S);
+ Assert.AreEqual(1, oo.S.Length);
+ Assert.AreEqual("zzz", oo.S[0]);
+ Assert.IsNotNull(oo.X);
+ Assert.AreEqual(1, oo.X.Length);
+ Assert.AreEqual(123, oo.X[0]);
+ Assert.IsNotNull(oo.C3);
+ Assert.AreEqual(1, oo.C3.Length);
+ Assert.IsNotNull(oo.C3[0]);
+ Assert.AreEqual("qxx", oo.C3[0].S);
+
+ oo = new C3_New {S = new string[2], X = new int[2], C3 = new C3_Subclass[2]};
+ serializer.Merge(o, ref oo);
+ Assert.IsNotNull(oo.S);
+ Assert.AreEqual(2, oo.S.Length);
+ Assert.AreEqual("zzz", oo.S[0]);
+ Assert.IsNotNull(oo.X);
+ Assert.AreEqual(2, oo.X.Length);
+ Assert.AreEqual(123, oo.X[0]);
+ Assert.IsNotNull(oo.C3);
+ Assert.AreEqual(2, oo.C3.Length);
+ Assert.IsNotNull(oo.C3[0]);
+ Assert.AreEqual("qxx", oo.C3[0].S);
+ }
+
+ [Test]
+ public void TestReadWriteToId()
+ {
+ var o = new C4_Old {S = "zzz", X = 123};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("zzz", oo.Zzz);
+ Assert.AreEqual(123, oo.Qxx);
+ }
+
+ [Test]
+ public void TestReadWriteFromId()
+ {
+ var o = new C4_New {Zzz = "zzz", Qxx = 123};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("zzz", oo.S);
+ Assert.AreEqual(123, oo.X);
+ }
+
+ [Test]
+ public void Test_GroboMember_IdCollision()
+ {
+ var o = new C5_GroboMember_IdCollision();
+ var e = Assert.Throws(() => serializer.Serialize(o));
+ Assert.That(e.Message, Is.EqualTo("Hash code collision: members 'C5_GroboMember_IdCollision.X' and 'C5_GroboMember_IdCollision.S' have the same hash code = 1"));
+ }
+
+ [Test]
+ public void Test_GroboMember_EmptyName()
+ {
+ var o = new C6_GroboMember_EmptyName();
+ var e = Assert.Throws(() => serializer.Serialize(o));
+ Assert.That(e.Message, Is.EqualTo("Empty grobo name of member 'C6_GroboMember_EmptyName.S'"));
+ }
+
+ [Test]
+ public void Test_GroboMember_EmptyId()
+ {
+ var o = new C7_GroboMember_EmptyId();
+ var e = Assert.Throws(() => serializer.Serialize(o));
+ Assert.That(e.Message, Is.EqualTo("Hash code of 'C7_GroboMember_EmptyId.S' equals to zero"));
+ }
+
+ [Test]
+ public void Test_MixedAnnotationAttributes()
+ {
+ var o = new C8_MixedAnnotationAttributes {S = "zzz", X = 123, Q = -1};
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("zzz", oo.S);
+ Assert.AreEqual(123, oo.X);
+ Assert.AreEqual(-1, oo.Q);
+ }
+
+ [Test]
+ public void Test_GroboMember_ReadonlyProperty()
+ {
+ var o = new C9_GroboMember_ReadonlyProperty_Old("GRobas");
+ var data = serializer.Serialize(o);
+ var oo = serializer.Deserialize(data);
+ Assert.AreEqual("GRobas", oo.Zzz);
+ }
+
+ public class C1_Old
+ {
+ public string S { get; set; }
+ public int X { get; set; }
+ }
+
+ public class C1_New
+ {
+ public int X { get; set; }
+ public double? D { get; set; }
+ public string S { get; set; }
+ }
+
+ public class C2_Old
+ {
+ public int X { get; set; }
+ public double? D { get; set; }
+ public string S { get; set; }
+ }
+
+ public class C2_New
+ {
+ public string S { get; set; }
+ public double? D { get; set; }
+ }
+
+ public class C3_Subclass
+ {
+ public string S { get; set; }
+ }
+
+ public class C3_Old
+ {
+ public string S { get; set; }
+ public int X { get; set; }
+ public C3_Subclass C3 { get; set; }
+ }
+
+ public class C3_New
+ {
+ public string[] S { get; set; }
+ public int[] X { get; set; }
+ public C3_Subclass[] C3 { get; set; }
+ }
+
+ public class C4_Old
+ {
+ public string S { get; set; }
+ public int X { get; set; }
+ }
+
+ public class C4_New
+ {
+ [GroboMember(7770670552212394539)]
+ public string Zzz { get; set; }
+
+ [GroboMember("X")]
+ public int Qxx { get; set; }
+ }
+
+ public class C5_GroboMember_IdCollision
+ {
+ [GroboMember(1)]
+ public string S { get; set; }
+
+ [GroboMember(1)]
+ public int X { get; set; }
+ }
+
+ public class C6_GroboMember_EmptyName
+ {
+ [GroboMember("")]
+ public string S { get; set; }
+ }
+
+ public class C7_GroboMember_EmptyId
+ {
+ [GroboMember(0)]
+ public string S { get; set; }
+ }
+
+ public class C8_MixedAnnotationAttributes
+ {
+ public string S { get; set; }
+
+ [DataMember(Name = "Z")]
+ public int X { get; set; }
+
+ [GroboMember(1)]
+ public int? Q { get; set; }
+ }
+
+ public class C9_GroboMember_ReadonlyProperty_Old
+ {
+ public C9_GroboMember_ReadonlyProperty_Old(string qxx)
+ {
+ Qxx = qxx;
+ }
+
+ public string Qxx { get; }
+ }
+
+ public class C9_GroboMember_ReadonlyProperty_New
+ {
+ public C9_GroboMember_ReadonlyProperty_New(string gRobas)
+ {
+ Zzz = gRobas;
+ }
+
+ [GroboMember("Qxx")]
+ public string Zzz { get; }
+ }
+
+ private Serializer serializer;
+ }
}
\ No newline at end of file
diff --git a/GroBuf.Tests/GroBuf.Tests.csproj b/GroBuf.Tests/GroBuf.Tests.csproj
new file mode 100644
index 0000000..2451441
--- /dev/null
+++ b/GroBuf.Tests/GroBuf.Tests.csproj
@@ -0,0 +1,15 @@
+
+
+ false
+ netcoreapp2.0;net45
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GroBuf/Tests/ImmutableObjectChangedBugTest.cs b/GroBuf.Tests/ImmutableObjectChangedBugTest.cs
similarity index 97%
rename from GroBuf/Tests/ImmutableObjectChangedBugTest.cs
rename to GroBuf.Tests/ImmutableObjectChangedBugTest.cs
index 4b209f6..df91d8c 100644
--- a/GroBuf/Tests/ImmutableObjectChangedBugTest.cs
+++ b/GroBuf.Tests/ImmutableObjectChangedBugTest.cs
@@ -1,82 +1,82 @@
-using System;
-using System.Runtime.Serialization;
-
-using GroBuf.DataMembersExtracters;
-
-using NUnit.Framework;
-
-namespace GroBuf.Tests
-{
- [TestFixture]
- public class ImmutableObjectChangedBugTest
- {
- [SetUp]
- public void SetUp()
- {
- serializer = new Serializer(new PropertiesExtractor());
- }
-
- [Test]
- public void Test()
- {
- Console.WriteLine(DebugViewBuilder.DebugView(serializer.Serialize(new[]
- {
- new RSV1DisabledPerson {Validation = new ValidationResult("zaa", ValidationResultType.Error)},
- new RSV1DisabledPerson {Validation = ValidationResult.Ok},
- new RSV1DisabledPerson {Validation = new ValidationResult("qs", ValidationResultType.Warning)},
- })));
- }
-
- [Test]
- public void TestValidationResultBug()
- {
- var expected = new[]
- {
- new RSV1DisabledPerson {Validation = new ValidationResult("zaa", ValidationResultType.Error)},
- new RSV1DisabledPerson {Validation = ValidationResult.Ok},
- new RSV1DisabledPerson {Validation = new ValidationResult("qs", ValidationResultType.Warning)},
- };
- Assert.AreEqual(ValidationResultType.Ok, ValidationResult.Ok.Type);
- Assert.AreEqual(null, ValidationResult.Ok.Message);
- var actual = serializer.Deserialize(serializer.Serialize(expected));
- Assert.AreEqual(ValidationResultType.Error, actual[0].Validation.Type);
- Assert.AreEqual("zaa", actual[0].Validation.Message);
- Assert.AreEqual(ValidationResultType.Ok, actual[1].Validation.Type);
- Assert.AreEqual(null, actual[1].Validation.Message);
- Assert.AreEqual(ValidationResultType.Warning, actual[2].Validation.Type);
- Assert.AreEqual("qs", actual[2].Validation.Message);
- }
-
- private Serializer serializer;
-
- private class ValidationResult
- {
- public ValidationResult(string message, ValidationResultType type)
- {
- Message = message;
- Type = type;
- }
-
- public string Message { get; private set; }
-
- public ValidationResultType Type { get; private set; }
- public static readonly ValidationResult Ok = new ValidationResult(null, ValidationResultType.Ok);
- }
-
- private class RSV1DisabledPerson
- {
- [DataMember]
- public ValidationResult Validation { get { return validation ?? ValidationResult.Ok; } set { validation = value; } }
-
- private ValidationResult validation;
- }
-
- private enum ValidationResultType
- {
- Ok = 0,
- Warning = 1,
- Error = 2,
- Fatal = 3
- }
- }
+using System;
+using System.Runtime.Serialization;
+
+using GroBuf.DataMembersExtracters;
+
+using NUnit.Framework;
+
+namespace GroBuf.Tests
+{
+ [TestFixture]
+ public class ImmutableObjectChangedBugTest
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ serializer = new Serializer(new PropertiesExtractor());
+ }
+
+ [Test]
+ public void Test()
+ {
+ Console.WriteLine(DebugViewBuilder.DebugView(serializer.Serialize(new[]
+ {
+ new RSV1DisabledPerson {Validation = new ValidationResult("zaa", ValidationResultType.Error)},
+ new RSV1DisabledPerson {Validation = ValidationResult.Ok},
+ new RSV1DisabledPerson {Validation = new ValidationResult("qs", ValidationResultType.Warning)},
+ })));
+ }
+
+ [Test]
+ public void TestValidationResultBug()
+ {
+ var expected = new[]
+ {
+ new RSV1DisabledPerson {Validation = new ValidationResult("zaa", ValidationResultType.Error)},
+ new RSV1DisabledPerson {Validation = ValidationResult.Ok},
+ new RSV1DisabledPerson {Validation = new ValidationResult("qs", ValidationResultType.Warning)},
+ };
+ Assert.AreEqual(ValidationResultType.Ok, ValidationResult.Ok.Type);
+ Assert.AreEqual(null, ValidationResult.Ok.Message);
+ var actual = serializer.Deserialize(serializer.Serialize(expected));
+ Assert.AreEqual(ValidationResultType.Error, actual[0].Validation.Type);
+ Assert.AreEqual("zaa", actual[0].Validation.Message);
+ Assert.AreEqual(ValidationResultType.Ok, actual[1].Validation.Type);
+ Assert.AreEqual(null, actual[1].Validation.Message);
+ Assert.AreEqual(ValidationResultType.Warning, actual[2].Validation.Type);
+ Assert.AreEqual("qs", actual[2].Validation.Message);
+ }
+
+ private Serializer serializer;
+
+ private class ValidationResult
+ {
+ public ValidationResult(string message, ValidationResultType type)
+ {
+ Message = message;
+ Type = type;
+ }
+
+ public string Message { get; private set; }
+
+ public ValidationResultType Type { get; private set; }
+ public static readonly ValidationResult Ok = new ValidationResult(null, ValidationResultType.Ok);
+ }
+
+ private class RSV1DisabledPerson
+ {
+ [DataMember]
+ public ValidationResult Validation { get { return validation ?? ValidationResult.Ok; } set { validation = value; } }
+
+ private ValidationResult validation;
+ }
+
+ private enum ValidationResultType
+ {
+ Ok = 0,
+ Warning = 1,
+ Error = 2,
+ Fatal = 3
+ }
+ }
}
\ No newline at end of file
diff --git a/GroBuf/Tests/IntegrationTest.cs b/GroBuf.Tests/IntegrationTest.cs
similarity index 95%
rename from GroBuf/Tests/IntegrationTest.cs
rename to GroBuf.Tests/IntegrationTest.cs
index ba99793..b549376 100644
--- a/GroBuf/Tests/IntegrationTest.cs
+++ b/GroBuf.Tests/IntegrationTest.cs
@@ -1,145 +1,147 @@
-using System;
-using System.Threading;
-
-using GroBuf.DataMembersExtracters;
-using GroBuf.Tests.TestData.Desadv;
-using GroBuf.Tests.TestData.Orders;
-using GroBuf.Tests.TestTools;
-
-using NUnit.Framework;
-
-namespace GroBuf.Tests
-{
- [TestFixture]
- public class IntegrationTest
- {
- [SetUp]
- public void SetUp()
- {
- serializer = new Serializer(new PropertiesExtractor());
- }
-
- [Test, Ignore]
- [Category("LongRunning")]
- public void TestChangeObjectDuringSerialization()
- {
- var random = new Random(54717651);
- var data = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
- var thread = new Thread(FillWithRandomTrash);
- thread.Start(data);
- while(true)
- {
- try
- {
- var serializedData = serializer.Serialize(data);
- }
- catch(Exception e)
- {
- Console.WriteLine(e);
- }
- }
- }
-
- public void FillWithRandomTrash(object param)
- {
- var data = (Orders)param;
- var random = new Random(1231241);
- while(true)
- TestHelpers.FillWithRandomTrash(data, random, 75, 10, 2);
- }
-
- [Test]
- [Category("LongRunning")]
- public void Test()
- {
- const int numberOfMessages = 10000;
- var random = new Random(54717651);
- var datas = new Orders[numberOfMessages];
- datas[0] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
- for(int i = 1; i < datas.Length; ++i)
- datas[i] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
-
- var messages = new byte[numberOfMessages][];
- for(int i = 0; i < datas.Length; ++i)
- messages[i] = serializer.Serialize(datas[i]);
-
- var deserializedMessages = new Orders[numberOfMessages];
- for(int i = 0; i < messages.Length; ++i)
- deserializedMessages[i] = serializer.Deserialize(messages[i]) ?? new Orders();
-
- for(int i = 0; i < numberOfMessages; ++i)
- {
- TestHelpers.Extend(deserializedMessages[i]);
- TestHelpers.Extend(datas[i]);
- deserializedMessages[i].AssertEqualsTo(datas[i]);
- }
- }
-
- [Test]
- [Category("LongRunning")]
- public void TestWithGarbageCollection()
- {
- const int numberOfMessages = 100000;
- var random = new Random(54717651);
- var datas = new Orders[numberOfMessages];
- datas[0] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
- for(int i = 1; i < datas.Length; ++i)
- datas[i] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
-
- stop = false;
- var thread = new Thread(Collect);
- thread.Start();
-
- var messages = new byte[numberOfMessages][];
- for(int i = 0; i < datas.Length; ++i)
- messages[i] = serializer.Serialize(datas[i]);
-
- var deserializedMessages = new Orders[numberOfMessages];
- for(int i = 0; i < messages.Length; ++i)
- deserializedMessages[i] = serializer.Deserialize(messages[i]);
-
- stop = true;
- }
-
- [Test, Ignore]
- [Category("LongRunning")]
- public void TestWithGarbageCollection2()
- {
- const int numberOfMessages = 1000000;
-
- stop = false;
- var thread = new Thread(Collect);
- thread.Start();
-
- for (int i = 0; i < 10; ++i )
- new Thread(Zzz).Start(serializer);
- Zzz(serializer);
-
- stop = true;
- }
-
- private void Zzz(object param)
- {
- var serializer = (Serializer)param;
- var random = new Random(Guid.NewGuid().GetHashCode());
- for (int i = 0; i < 1000000; ++i)
- {
- var data = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
- var message = serializer.Serialize(data);
- var deserializedData = serializer.Deserialize(message);
- }
- }
-
- private void Collect()
- {
- while(!stop)
- {
- Thread.Sleep(100);
- GC.Collect();
- }
- }
-
- private Serializer serializer;
- private volatile bool stop;
- }
+using System;
+using System.Threading;
+
+using GroBuf.DataMembersExtracters;
+using GroBuf.Tests.TestData.Desadv;
+using GroBuf.Tests.TestData.Orders;
+using GroBuf.Tests.TestTools;
+
+using NUnit.Framework;
+
+namespace GroBuf.Tests
+{
+ [TestFixture]
+ public class IntegrationTest
+ {
+ [SetUp]
+ public void SetUp()
+ {
+ serializer = new Serializer(new PropertiesExtractor());
+ }
+
+ [Test]
+ [Category("LongRunning")]
+ [Ignore("Is used for debugging")]
+ public void TestChangeObjectDuringSerialization()
+ {
+ var random = new Random(54717651);
+ var data = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+ var thread = new Thread(FillWithRandomTrash);
+ thread.Start(data);
+ while(true)
+ {
+ try
+ {
+ var serializedData = serializer.Serialize(data);
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine(e);
+ }
+ }
+ }
+
+ public void FillWithRandomTrash(object param)
+ {
+ var data = (Orders)param;
+ var random = new Random(1231241);
+ while(true)
+ TestHelpers.FillWithRandomTrash(data, random, 75, 10, 2);
+ }
+
+ [Test]
+ [Category("LongRunning")]
+ public void Test()
+ {
+ const int numberOfMessages = 10000;
+ var random = new Random(54717651);
+ var datas = new Orders[numberOfMessages];
+ datas[0] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+ for(int i = 1; i < datas.Length; ++i)
+ datas[i] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+
+ var messages = new byte[numberOfMessages][];
+ for(int i = 0; i < datas.Length; ++i)
+ messages[i] = serializer.Serialize(datas[i]);
+
+ var deserializedMessages = new Orders[numberOfMessages];
+ for(int i = 0; i < messages.Length; ++i)
+ deserializedMessages[i] = serializer.Deserialize(messages[i]) ?? new Orders();
+
+ for(int i = 0; i < numberOfMessages; ++i)
+ {
+ TestHelpers.Extend(deserializedMessages[i]);
+ TestHelpers.Extend(datas[i]);
+ deserializedMessages[i].AssertEqualsTo(datas[i]);
+ }
+ }
+
+ [Test]
+ [Category("LongRunning")]
+ public void TestWithGarbageCollection()
+ {
+ const int numberOfMessages = 100000;
+ var random = new Random(54717651);
+ var datas = new Orders[numberOfMessages];
+ datas[0] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+ for(int i = 1; i < datas.Length; ++i)
+ datas[i] = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+
+ stop = false;
+ var thread = new Thread(Collect);
+ thread.Start();
+
+ var messages = new byte[numberOfMessages][];
+ for(int i = 0; i < datas.Length; ++i)
+ messages[i] = serializer.Serialize(datas[i]);
+
+ var deserializedMessages = new Orders[numberOfMessages];
+ for(int i = 0; i < messages.Length; ++i)
+ deserializedMessages[i] = serializer.Deserialize(messages[i]);
+
+ stop = true;
+ }
+
+ [Test]
+ [Category("LongRunning")]
+ [Ignore("Is used for debugging")]
+ public void TestWithGarbageCollection2()
+ {
+ const int numberOfMessages = 1000000;
+
+ stop = false;
+ var thread = new Thread(Collect);
+ thread.Start();
+
+ for (int i = 0; i < 10; ++i )
+ new Thread(Zzz).Start(serializer);
+ Zzz(serializer);
+
+ stop = true;
+ }
+
+ private void Zzz(object param)
+ {
+ var serializer = (Serializer)param;
+ var random = new Random(Guid.NewGuid().GetHashCode());
+ for (int i = 0; i < 1000000; ++i)
+ {
+ var data = TestHelpers.GenerateRandomTrash(random, 75, 10, 2);
+ var message = serializer.Serialize(data);
+ var deserializedData = serializer.Deserialize(message);
+ }
+ }
+
+ private void Collect()
+ {
+ while(!stop)
+ {
+ Thread.Sleep(100);
+ GC.Collect();
+ }
+ }
+
+ private Serializer serializer;
+ private volatile bool stop;
+ }
}
\ No newline at end of file
diff --git a/GroBuf/Tests/ObjectConstructionHelperTest.cs b/GroBuf.Tests/ObjectConstructionHelperTest.cs
similarity index 96%
rename from GroBuf/Tests/ObjectConstructionHelperTest.cs
rename to GroBuf.Tests/ObjectConstructionHelperTest.cs
index eae16a1..b006d45 100644
--- a/GroBuf/Tests/ObjectConstructionHelperTest.cs
+++ b/GroBuf.Tests/ObjectConstructionHelperTest.cs
@@ -1,43 +1,43 @@
-using System;
-
-using GroBuf.Readers;
-
-using NUnit.Framework;
-
-namespace GroBuf.Tests
-{
- [TestFixture]
- public class ObjectConstructionHelperTest
- {
- [Test]
- public void TestEnptyConstructor()
- {
- Func