Skip to content

Commit

Permalink
added nuget package
Browse files Browse the repository at this point in the history
  • Loading branch information
rofr committed Nov 23, 2014
1 parent a756438 commit d3ad649
Show file tree
Hide file tree
Showing 30 changed files with 138 additions and 58,039 deletions.
6 changes: 4 additions & 2 deletions JsonNetFormatter.Test/JsonNetFormatter.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<AssemblyName>JsonNetFormatter.Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -20,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,13 +30,14 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="OrigoDB.Core">
<HintPath>..\packages\OrigoDB.Core.0.10.2\lib\OrigoDB.Core.dll</HintPath>
<HintPath>..\packages\OrigoDB.Core.0.17.1\lib\net40\OrigoDB.Core.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -48,7 +51,6 @@
<Compile Include="TestModel\Category.cs" />
<Compile Include="TestModel\Collection.cs" />
<Compile Include="TestModel\MyModel.cs" />
<Compile Include="TestModel\MySubModel.cs" />
<Compile Include="TestModel\SubThing.cs" />
<Compile Include="Tests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
19 changes: 0 additions & 19 deletions JsonNetFormatter.Test/TestModel/MySubModel.cs

This file was deleted.

29 changes: 0 additions & 29 deletions JsonNetFormatter.Test/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using Modules.JsonNet;
Expand Down Expand Up @@ -44,9 +43,6 @@ private MyModel ConstructComplexGraph()

model.Categories.Add(cat.Name, cat);

var subModel = model.ChildFor<MySubModel>();
subModel.AddModel(model);
subModel.AddModel(subModel);
model.AddThing(null);
model.AddThing(new SubThing(3, "Fish") { DingDong = "Woohoo!" });
return model;
Expand All @@ -70,31 +66,6 @@ public void Public_field_is_initialized()
Assert.IsNotNull(_target.Collection);
}

[Test]
public void Inherited_field_is_assigned()
{
//private field of OrigoDB.Core.Model
var inheritedFieldValue = _target.GetType().BaseType
.GetField("_children", BindingFlags.Instance | BindingFlags.NonPublic)
.GetValue(_target);
Assert.IsNotNull(inheritedFieldValue);
}

[Test]
public void Object_in_inherited_collection_is_populated()
{
var subModel = _target.ChildFor<MySubModel>();
Assert.AreEqual(2, subModel.Ugg.Count);
}

[Test]
public void Objects_in_inherited_collection_have_correct_refs()
{
var subModel = _target.ChildFor<MySubModel>();
Assert.IsTrue(subModel.Ugg.Values.Contains(subModel));
Assert.IsTrue(subModel.Ugg.Values.Contains(_target));
}

[Test]
public void Related_things_refer_to_each_other()
{
Expand Down
2 changes: 1 addition & 1 deletion JsonNetFormatter.Test/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.3" targetFramework="net40" />
<package id="OrigoDB.Core" version="0.10.2" targetFramework="net40" />
<package id="OrigoDB.Core" version="0.17.1" targetFramework="net40" />
</packages>
30 changes: 30 additions & 0 deletions JsonNetFormatter.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>OrigoDB.JsonNetFormatter</id>
<title>OrigoDB JsonNetFormatter</title>
<version>0.1.0</version>
<authors>Robert Friberg</authors>
<copyright>Devrex Labs</copyright>
<summary>
An IFormatter implementation based on NewtonSoft.Json
</summary>
<description>
An IFormatter implementation based on NewtonSoft.Json
</description>
<projectUrl>https://github.com/DevrexLabs/Modules.JsonNetFormatter</projectUrl>
<iconUrl>http://devrexlabs.com/Content/icons/favicon.ico</iconUrl>
<licenseUrl>https://github.com/DevrexLabs/Modules.JsonNetFormatter/blob/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<releaseNotes>https://github.com/DevrexLabs/Modules.JsonNetFormatter</releaseNotes>
<tags>OrigoDB in-memory imdb nosql database</tags>
<dependencies>
<dependency id="NewtonSoft.Json" version="6.0.6"/>
</dependencies>
</metadata>
<files>
<file src="build/OrigoDb.JsonNetFormatter.dll" target="lib\net40" />
<file src="build/OrigoDb.JsonNetFormatter.pdb" target="lib\net40" />
<file src="src/Modules.JsonNetFormatter/**/*.cs" target="src" />
</files>
</package>
10 changes: 7 additions & 3 deletions Modules.JsonNetFormatter/Modules.JsonNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Modules.JsonNet</RootNamespace>
<AssemblyName>Modules.JsonNet</AssemblyName>
<AssemblyName>OrigoDb.JsonNetFormatter</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -20,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -28,10 +30,12 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\json.spike\packages\Newtonsoft.Json.6.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.6\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion Modules.JsonNetFormatter/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net40" requireReinstallation="True" />
</packages>
31 changes: 20 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
Modules.JsonNetFormatter
=====================
An IFormatter implementation based on Newtonsoft.Json serialization.
An IFormatter implementation based on Newtonsoft.Json serialization intended as an alternative to the default `BinaryFormatter` used by OrigoDB for messages and data. It can also be used independently.

Intended as a replacement for `BinaryFormatter` used by OrigoDB for snapshots, the command journal, requests and response.
OrigoDB snapshots are arbitrarily complex object graphs. Deserialization needs to recreate an identical object graph as the one serialized.
OrigoDB snapshots are arbitrarily complex object graphs. Deserialization needs to recreate an identical object graph as the one serialized.

## Why?
The major benefits are readability, interoperability and maintainability. We ran a single test on a
small (8.6k binary serialized, 3.6k json serialized) but complex graph. Serialization speed was slightly
slower but deserialization was about 25% faster. Size is about 60% smaller which not only requires
less storage for snapshots and journal but also means less i/o. Test is included.
The major benefits are readability, interoperability and maintainability. But performance in general is probably better too. You should run benchmarks based on your own data.

Note! This is based on NET 4.5. Using NET 4.0 serialization/deserialization speed is about twice as fast as BinaryFormatter.

See more about OrigoDB on the project page: http://devrexlabs.github.io/
## Performance
Here's some test output:
```
Release
Modules.JsonNet.JsonNetFormatter
Size: 1736
Serialization: 00:00:00.5210129
Deserialization: 00:00:00.5948599
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Size: 4953
Serialization: 00:00:00.9770694
Deserialization: 00:00:01.2388305
```

## Specification
* All types must be marked with `SerializableAttribute`
Expand All @@ -31,4 +38,6 @@ formatter.Serialize(ms, someObjectRef);
ms.Position = 0;
object clone = formatter.Deserialize(ms);
```

## Download / install
Nuget: https://www.nuget.org/packages/OrigoDB.JsonNetFormatter/
Binary: https://github.com/DevrexLabs/Modules.JsonNetFormatter/releases
74 changes: 74 additions & 0 deletions build.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/perl
use strict;

# tools
my $msbuild = 'C:/Windows/Microsoft.NET/Framework/v4.0.30319/msbuild.exe';
my $nuget = "nuget.exe";
my $sevenZip = "C:/Program Files/7-Zip/7z.exe";


my $version = extract('Modules.JsonNetFormatter/Properties/AssemblyInfo.cs');
die "missing or bad version: [$version]\n" unless $version =~ /^\d+\.\d+\.\d+(-[a-z]+)?$/;

my $target = shift || 'default';
my $config = shift || 'Release';


my $solution = 'Modules.JsonNetFormatter.sln';
my $output = "build";


my $msbuild_out = "Modules.JsonNetFormatter/bin/$config";


sub run;

my $targets = {
default => sub
{
run qw|clean compile copy zip pack|;
},
clean => sub
{
system "rm -fr $output";
mkdir $output;
},
compile => sub
{
system "$msbuild $solution -target:clean,rebuild -p:Configuration=$config -p:NoWarn=1591 > build/build.log";
},
copy => sub
{
system "cp $msbuild_out/OrigoDb.JsonNetFormatter.* $msbuild_out/Newton*.dll $output";
},
zip => sub {
chdir 'build';
my $zipFile = "OrigoDB.JsonNetFormatter.$version-$config.zip";
system "\"$sevenZip\" a -r -tzip ../$zipFile *";
chdir '..';
`mv $zipFile build`;
},
pack => sub
{
system("$nuget pack JsonNetFormatter.nuspec -OutputDirectory build -version $version -symbols")
}
};

run $target;

sub run
{
for my $targetName (@_) {
die "No such target: $targetName\n" unless exists $targets->{$targetName};
print "target: $targetName\n";
$targets->{$targetName}->();
}
}

sub extract
{
my $file = shift;
`grep AssemblyVersion $file` =~ /(\d+\.\d+\.\d+)/;
$1;
}

Binary file not shown.
16 changes: 0 additions & 16 deletions packages/Newtonsoft.Json.6.0.1/Newtonsoft.Json.6.0.1.nuspec

This file was deleted.

Binary file not shown.
Loading

0 comments on commit d3ad649

Please sign in to comment.