Skip to content

Commit

Permalink
No gc alloc v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HCricle committed Mar 10, 2024
1 parent 28c54d4 commit c0380ee
Show file tree
Hide file tree
Showing 24 changed files with 344 additions and 538 deletions.
4 changes: 2 additions & 2 deletions UnionType.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnionType", "src\UnionType\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnionType.Test", "test\UnionType.Test\UnionType.Test.csproj", "{8BC764AA-3C70-4AA2-82B2-95904FD00F86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnionType.Sample", "samples\UnionType.Sample\UnionType.Sample.csproj", "{D28EE92F-E07E-4529-A635-F03D21C08455}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnionType.Sample", "samples\UnionType.Sample\UnionType.Sample.csproj", "{D28EE92F-E07E-4529-A635-F03D21C08455}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3CB097BD-DD9D-49CB-A995-8A02336DB260}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnionType.Benchmarks", "test\UnionType.Benchmarks\UnionType.Benchmarks.csproj", "{96A9EC5E-3E80-4AD9-AA1E-E413C7FE5097}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnionType.Benchmarks", "test\UnionType.Benchmarks\UnionType.Benchmarks.csproj", "{96A9EC5E-3E80-4AD9-AA1E-E413C7FE5097}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
7 changes: 3 additions & 4 deletions samples/UnionType.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Numerics;
using System.Runtime.InteropServices;

namespace UnionType.Sample
{
Expand All @@ -12,7 +11,7 @@ static unsafe void Main(string[] args)
Console.WriteLine($"Min:{int.MinValue} vs {num.MinValue}");
Console.WriteLine($"Max:{int.MaxValue} vs {num.MaxValue}");
Console.WriteLine("Decimal size:" + sizeof(decimal));
Console.WriteLine("UnionValue size:" + sizeof(UnionValue));
Console.WriteLine("UnionValue size:" + UnionValue.Size);

Console.WriteLine();

Expand Down Expand Up @@ -40,8 +39,8 @@ static unsafe void Main(string[] args)

var stu = new Student { Id = 123 };
var stuUv = new UnionValue();
stuUv.SetObject(stu);
var stuBack = stuUv.GetObject();
stuUv.Object=(stu);
var stuBack = stuUv.Object;
Console.WriteLine("Can store instance:");
Console.WriteLine("Origan hash:" + stu.GetHashCode());
Console.WriteLine("Back hash :" + stuBack.GetHashCode());
Expand Down
5 changes: 3 additions & 2 deletions src/UnionType/UnionType.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>10.0</LangVersion>
<Version>1.4.0</Version>
<Version>1.5.0</Version>
<RepositoryUrl>https://github.com/Cricle/UnionType</RepositoryUrl>
<RepositoryType>https://github.com/Cricle/UnionType</RepositoryType>
<PackageTags>union;type;</PackageTags>
Expand All @@ -29,6 +29,7 @@
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
<InternalsVisibleTo Include="UnionType.Test"/>
</ItemGroup>

</Project>

0 comments on commit c0380ee

Please sign in to comment.