Skip to content

Commit

Permalink
ByteSerializable added to generated code for #8
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxantron committed Apr 25, 2016
1 parent 80c45af commit ccacb57
Show file tree
Hide file tree
Showing 18 changed files with 289 additions and 141 deletions.
24 changes: 11 additions & 13 deletions CGbR.Benchmarks/CGbR.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="CGbR.Lib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CGbR.0.3.3\lib\CGbR.Lib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -71,18 +67,20 @@
<None Include="cgbr.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CGbR.Lib\CGbR.Lib.csproj">
<Project>{2e0e6ad3-7336-4ed0-ba8a-2c6d0cc99fed}</Project>
<Name>CGbR.Lib</Name>
</ProjectReference>
<ProjectReference Include="..\CGbR\CGbR.csproj">
<Project>{f42ba2ed-3b24-49a1-b6cf-b1676038141b}</Project>
<Name>CGbR</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>
</PreBuildEvent>
<PreBuildEvent>$(SolutionDir)bin\cgbr.exe $(ProjectDir)</PreBuildEvent>
</PropertyGroup>
<Import Project="..\packages\CGbR.0.3.3\build\cgbr.targets" Condition="Exists('..\packages\CGbR.0.3.3\build\cgbr.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\CGbR.0.3.3\build\cgbr.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CGbR.0.3.3\build\cgbr.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
20 changes: 18 additions & 2 deletions CGbR.Benchmarks/Partial.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.Benchmarks
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class Partial
public partial class Partial : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -52,6 +52,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -112,6 +120,14 @@ public Partial FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
20 changes: 18 additions & 2 deletions CGbR.Benchmarks/Root.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.Benchmarks
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class Root
public partial class Root : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -52,6 +52,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -114,6 +122,14 @@ public Root FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion CGbR.Benchmarks/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CGbR" version="0.3.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net452" />
</packages>
24 changes: 13 additions & 11 deletions CGbR.GeneratorTests/CGbR.GeneratorTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="CGbR.Lib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CGbR.0.3.3\lib\CGbR.Lib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -67,14 +63,20 @@
<None Include="cgbr.json" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CGbR.Lib\CGbR.Lib.csproj">
<Project>{2e0e6ad3-7336-4ed0-ba8a-2c6d0cc99fed}</Project>
<Name>CGbR.Lib</Name>
</ProjectReference>
<ProjectReference Include="..\CGbR\CGbR.csproj">
<Project>{f42ba2ed-3b24-49a1-b6cf-b1676038141b}</Project>
<Name>CGbR</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\CGbR.0.3.3\build\cgbr.targets" Condition="Exists('..\packages\CGbR.0.3.3\build\cgbr.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\CGbR.0.3.3\build\cgbr.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\CGbR.0.3.3\build\cgbr.targets'))" />
</Target>
<PropertyGroup>
<PreBuildEvent>$(SolutionDir)bin\cgbr.exe $(ProjectDir)</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
20 changes: 18 additions & 2 deletions CGbR.GeneratorTests/Dummies/ByteProperties.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.GeneratorTests
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class ByteProperties
public partial class ByteProperties : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -50,6 +50,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -82,6 +90,14 @@ public ByteProperties FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
20 changes: 18 additions & 2 deletions CGbR.GeneratorTests/Dummies/DifferentCollections.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.GeneratorTests
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class DifferentCollections
public partial class DifferentCollections : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -53,6 +53,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -127,6 +135,14 @@ public DifferentCollections FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
20 changes: 18 additions & 2 deletions CGbR.GeneratorTests/Dummies/Partial.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.GeneratorTests
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class Partial
public partial class Partial : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -50,6 +50,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -82,6 +90,14 @@ public Partial FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
20 changes: 18 additions & 2 deletions CGbR.GeneratorTests/Dummies/Root.Generated.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* This code was generated by the CGbR generator on 20.04.2016. Any manual changes will be lost on the next build.
* This code was generated by the CGbR generator on 25.04.2016. Any manual changes will be lost on the next build.
*
* For questions or bug reports please refer to https://github.com/Toxantron/CGbR or contact the distributor of the
* 3rd party generator target.
Expand All @@ -18,7 +18,7 @@ namespace CGbR.GeneratorTests
/// <summary>
/// Auto generated class by CGbR project
/// </summary>
public partial class Root
public partial class Root : IByteSerializable
{
#region BinarySerializer

Expand Down Expand Up @@ -51,6 +51,14 @@ public byte[] ToBytes()
return ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
void IByteSerializable.ToBytes(byte[] bytes, ref int index)
{
ToBytes(bytes, ref index);
}

/// <summary>
/// Convert object to bytes within object tree
/// </summary>
Expand Down Expand Up @@ -99,6 +107,14 @@ public Root FromBytes(byte[] bytes)
return FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
void IByteSerializable.FromBytes(byte[] bytes, ref int index)
{
FromBytes(bytes, ref index);
}

/// <summary>
/// Create object from segment in byte array
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion CGbR.GeneratorTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CGbR" version="0.3.3" targetFramework="net451" />
<package id="coveralls.io" version="1.3.4" targetFramework="net451" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
<package id="NUnit" version="2.6.4" targetFramework="net451" />
Expand Down
6 changes: 6 additions & 0 deletions CGbR/Generator/Serialization/BinarySerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ internal class BinarySerializer : ILocalGenerator
"CGbR.Lib"
};

/// <seealso cref="ILocalGenerator"/>
public string[] Interfaces { get; } = new[]
{
"IByteSerializable"
};

/// <seealso cref="ILocalGenerator"/>
public bool CanExtend(ClassModel model)
{
Expand Down
Loading

0 comments on commit ccacb57

Please sign in to comment.