Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
can serialize zero member struct, improve Unity struct formatter seri…
Browse files Browse the repository at this point in the history
…alization performance
  • Loading branch information
neuecc committed Dec 11, 2016
1 parent 7015f97 commit 93a65c9
Show file tree
Hide file tree
Showing 40 changed files with 546 additions and 258 deletions.
2 changes: 1 addition & 1 deletion nuget/ZeroFormatter.Interfaces.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ZeroFormatter.Interfaces</id>
<version>1.5.4</version>
<version>1.5.5</version>
<title>ZeroFormatter.Interfaces</title>
<authors>neuecc</authors>
<owners>y.neuecc</owners>
Expand Down
4 changes: 2 additions & 2 deletions nuget/ZeroFormatter.Unity.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ZeroFormatter.Unity</id>
<version>1.5.4</version>
<version>1.5.5</version>
<title>ZeroFormatter.Unity</title>
<authors>neuecc</authors>
<owners>y.neuecc</owners>
Expand All @@ -17,7 +17,7 @@
</frameworkAssemblies>
<dependencies>
<group targetFramework="Unity Full v3.5">
<dependency id="ZeroFormatter.Interfaces" version="1.5.4" />
<dependency id="ZeroFormatter.Interfaces" version="1.5.5" />
</group>
</dependencies>
</metadata>
Expand Down
6 changes: 3 additions & 3 deletions nuget/ZeroFormatter.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>ZeroFormatter</id>
<version>1.5.4</version>
<version>1.5.5</version>
<title>ZeroFormatter</title>
<authors>neuecc</authors>
<owners>y.neuecc</owners>
Expand All @@ -17,10 +17,10 @@
</frameworkAssemblies>
<dependencies>
<group targetFramework=".NETFramework4.5">
<dependency id="ZeroFormatter.Interfaces" version="1.5.4" />
<dependency id="ZeroFormatter.Interfaces" version="1.5.5" />
</group>
<group targetFramework=".NETStandard1.6">
<dependency id="ZeroFormatter.Interfaces" version="1.5.4" />
<dependency id="ZeroFormatter.Interfaces" version="1.5.5" />
<dependency id="System.Reflection.Emit" version="4.0.1" />
<dependency id="System.Runtime" version="4.1.0" />
<dependency id="System.Runtime.Extensions" version="4.1.0" />
Expand Down
2 changes: 1 addition & 1 deletion nuget/check_zfc.bat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
zfc -i "C:\Users\y.kawai\Documents\neuecc\ZeroFormatter\sandbox\Sandbox.Shared\Sandbox.Shared.csproj" -o "C:\Users\y.kawai\Documents\neuecc\ZeroFormatter\tests\ZeroFormatter.UnityTests\Assets\ZeroFormatterGenerated.cs" -c UNITY -u
zfc -i "C:\Users\neuecc\Documents\Git\neuecc\ZeroFormatter\sandbox\Sandbox.Shared\Sandbox.Shared.csproj" -o "C:\Users\neuecc\Documents\Git\neuecc\ZeroFormatter\tests\ZeroFormatter.UnityTests\Assets\ZeroFormatterGenerated.cs" -c UNITY -u
6 changes: 3 additions & 3 deletions nuget/push.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REM nuget push ZeroFormatter.Analyzer.1.1.1.0.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.1.5.4.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.Interfaces.1.5.4.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.Unity.1.5.4.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.1.5.5.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.Interfaces.1.5.5.nupkg -Source https://www.nuget.org/api/v2/package
nuget push ZeroFormatter.Unity.1.5.5.nupkg -Source https://www.nuget.org/api/v2/package
4 changes: 2 additions & 2 deletions sandbox/PerformanceComparison/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.4.0")]
[assembly: AssemblyFileVersion("1.5.4.0")]
[assembly: AssemblyVersion("1.5.5.0")]
[assembly: AssemblyFileVersion("1.5.5.0")]
6 changes: 3 additions & 3 deletions sandbox/Sandbox.NETCore/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.4-*",
"version": "1.5.5-*",
"buildOptions": {
"emitEntryPoint": true
},
Expand All @@ -9,8 +9,8 @@
"type": "platform",
"version": "1.0.0"
},
"ZeroFormatter.Interfaces.NETCore": "1.5.4",
"ZeroFormatter.NETCore": "1.5.4"
"ZeroFormatter.Interfaces.NETCore": "1.5.5",
"ZeroFormatter.NETCore": "1.5.5"
},

"frameworks": {
Expand Down
14 changes: 7 additions & 7 deletions sandbox/Sandbox.NETCore/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@
"lib/netstandard1.3/_._": {}
}
},
"ZeroFormatter.Interfaces.NETCore/1.5.4": {
"ZeroFormatter.Interfaces.NETCore/1.5.5": {
"type": "project",
"framework": ".NETStandard,Version=v1.1",
"dependencies": {
Expand All @@ -2006,7 +2006,7 @@
"netstandard1.1/ZeroFormatter.Interfaces.NETCore.dll": {}
}
},
"ZeroFormatter.NETCore/1.5.4": {
"ZeroFormatter.NETCore/1.5.5": {
"type": "project",
"framework": ".NETStandard,Version=v1.6",
"dependencies": {
Expand All @@ -2024,7 +2024,7 @@
"System.Text.Encoding": "4.0.11",
"System.Text.Encoding.Extensions": "4.0.11",
"System.Threading": "4.0.11",
"ZeroFormatter.Interfaces.NETCore": "1.5.4"
"ZeroFormatter.Interfaces.NETCore": "1.5.5"
},
"compile": {
"netstandard1.6/ZeroFormatter.NETCore.dll": {}
Expand Down Expand Up @@ -6627,12 +6627,12 @@
"ref/xamarinwatchos10/_._"
]
},
"ZeroFormatter.Interfaces.NETCore/1.5.4": {
"ZeroFormatter.Interfaces.NETCore/1.5.5": {
"type": "project",
"path": "../../src/ZeroFormatter.Interfaces.NETCore/project.json",
"msbuildProject": "../../src/ZeroFormatter.Interfaces.NETCore/ZeroFormatter.Interfaces.NETCore.xproj"
},
"ZeroFormatter.NETCore/1.5.4": {
"ZeroFormatter.NETCore/1.5.5": {
"type": "project",
"path": "../../src/ZeroFormatter.NETCore/project.json",
"msbuildProject": "../../src/ZeroFormatter.NETCore/ZeroFormatter.NETCore.xproj"
Expand All @@ -6641,8 +6641,8 @@
"projectFileDependencyGroups": {
"": [
"Microsoft.NETCore.App >= 1.0.0",
"ZeroFormatter.Interfaces.NETCore >= 1.5.4",
"ZeroFormatter.NETCore >= 1.5.4"
"ZeroFormatter.Interfaces.NETCore >= 1.5.5",
"ZeroFormatter.NETCore >= 1.5.5"
],
".NETCoreApp,Version=v1.0": []
},
Expand Down
4 changes: 2 additions & 2 deletions sandbox/Sandbox.Shared/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.4.0")]
[assembly: AssemblyFileVersion("1.5.4.0")]
[assembly: AssemblyVersion("1.5.5.0")]
[assembly: AssemblyFileVersion("1.5.5.0")]
4 changes: 2 additions & 2 deletions sandbox/Sandbox.Shared/Sandbox.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<TargetFrameworkVersion Condition="'$(Configuration)|$(Platform)' != 'Unity|AnyCPU'">v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion Condition="'$(Configuration)|$(Platform)' == 'Unity|AnyCPU'">v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -41,8 +42,6 @@
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
Expand All @@ -59,6 +58,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnionType.cs" />
<Compile Include="Versioning.cs" />
<Compile Include="ZeroArgument.cs" />
<Compile Include="ZeroFormatter.Tests\TestClasses.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
17 changes: 17 additions & 0 deletions sandbox/Sandbox.Shared/ZeroArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

using ZeroFormatter;

namespace Sandbox.Shared
{
[ZeroFormattable]
public class ZeroClass
{

}

[ZeroFormattable]
public struct ZeroStruct
{

}
}
11 changes: 7 additions & 4 deletions sandbox/Sandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,18 @@ public class Nest
}


[ZeroFormattable]
public struct ZeroA
{
}

class Program
{
static void Main(string[] args)
{
var a = ZeroFormatterSerializer.Convert(new InnerClassA.InnerObject());
var b = ZeroFormatterSerializer.Convert(new InnerClassB.InnerObject());
var a = ZeroFormatterSerializer.Serialize(default(ZeroA));


Console.WriteLine(a.GetType().FullName);
Console.WriteLine(b.GetType().FullName);
}
}

Expand Down
4 changes: 2 additions & 2 deletions sandbox/Sandbox/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.4.0")]
[assembly: AssemblyFileVersion("1.5.4.0")]
[assembly: AssemblyVersion("1.5.5.0")]
[assembly: AssemblyFileVersion("1.5.5.0")]
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="ZeroFormatterAnalyzer.343bae8e-c880-437c-9e30-748b9e0f9b6e" Version="1.5.4" Language="en-US" Publisher="neuecc"/>
<Identity Id="ZeroFormatterAnalyzer.343bae8e-c880-437c-9e30-748b9e0f9b6e" Version="1.5.5" Language="en-US" Publisher="neuecc"/>
<DisplayName>ZeroFormatterAnalyzer</DisplayName>
<Description xml:space="preserve">New Launcher of ZeroFormatter.Analyzer</Description>
</Metadata>
Expand Down
16 changes: 16 additions & 0 deletions src/ZeroFormatter.CodeGenerator/GeneratorPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public int[] ElementFixedSizes
{
get
{
if (Properties.Length == 0) return new int[0];

var schemaLastIndex = Properties.Select(x => x.Index).LastOrDefault();
var dict = Properties.Where(x => x.IsFixedSize).ToDictionary(x => x.Index, x => x.FixedSize);
var elementSizes = new int[schemaLastIndex + 1];
Expand All @@ -101,6 +103,20 @@ public int[] ElementFixedSizes
return elementSizes;
}
}

public int? GetLength()
{
if (Properties.Length == 0) return 0;

var sum = 0;
foreach (var item in Properties)
{
if (!item.IsFixedSize) return null;
sum += item.FixedSize;
}

return sum;
}
}

public partial class InitializerGenerator
Expand Down
4 changes: 2 additions & 2 deletions src/ZeroFormatter.CodeGenerator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.5.4.0")]
[assembly: AssemblyFileVersion("1.5.4.0")]
[assembly: AssemblyVersion("1.5.5.0")]
[assembly: AssemblyFileVersion("1.5.5.0")]
Loading

0 comments on commit 93a65c9

Please sign in to comment.