Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public readonly partial struct Int32OrString
#nullable enable
namespace EfficientUnionGenerator.SampleApp.SimpleUnionOfInt32OrString;


[System.Runtime.CompilerServices.Union]
partial struct Int32OrString
{
private enum __TypeSpecifier : byte
Expand Down Expand Up @@ -146,7 +146,7 @@ public readonly partial struct SignedInteger
#nullable enable
namespace EfficientUnionGenerator.SampleApp.SimpleUnionOfSignedInteger;


[System.Runtime.CompilerServices.Union]
partial struct SignedInteger
{
private enum __TypeSpecifier : byte
Expand Down Expand Up @@ -312,7 +312,7 @@ public static class Program
#nullable enable
namespace EfficientUnionGenerator.SampleApp.PositiveOnlyIntOrFloat;


[System.Runtime.CompilerServices.Union]
partial struct PositiveOnlyIntOrFloat
{
private enum __TypeSpecifier : uint
Expand Down Expand Up @@ -444,7 +444,7 @@ public readonly partial struct ElfHeader
#nullable enable
namespace EfficientUnionGenerator.SampleApp.ElfHeader;


[System.Runtime.CompilerServices.Union]
partial struct ElfHeader
{
private enum __TypeSpecifier : ulong
Expand Down
4 changes: 3 additions & 1 deletion src/EfficientUnionGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ private static void EmitUnionType(SourceProductionContext context, UnionTypeDefi
sb.AppendAutoGeneratedComment();
sb.AppendLine("#nullable enable");
sb.AppendNamespaceDeclaration();


using (sb.BeginTargetTypeDeclare())
using (var typeDecl = sb.BeginTargetTypeDeclare())
{
typeDecl.AddAttribute($"System.Runtime.CompilerServices.Union");
GenerateTypeSpecifierEnumDeclaration(source);

if (source.CandidateUnmanagedTypes.Length > 0)
Expand Down
Loading