diff --git a/src/Generator/Generators/CSharp/CSharpSources.cs b/src/Generator/Generators/CSharp/CSharpSources.cs index eb52336d0..a5cf6d70d 100644 --- a/src/Generator/Generators/CSharp/CSharpSources.cs +++ b/src/Generator/Generators/CSharp/CSharpSources.cs @@ -414,7 +414,16 @@ public override bool VisitClassDecl(Class @class) if (@class.IsValueType) { WriteLine($"private {@class.Name}.{Helpers.InternalStruct} {Helpers.InstanceField};"); - WriteLine($"internal ref {@class.Name}.{Helpers.InternalStruct} {Helpers.InstanceIdentifier} => ref {Helpers.InstanceField};"); + WriteLine($"internal ref {@class.Name}.{Helpers.InternalStruct} {Helpers.InstanceIdentifier}"); + WriteOpenBraceAndIndent(); + WriteLine("get"); + WriteOpenBraceAndIndent(); + WriteLine($"fixed ({@class.Name}.{Helpers.InternalStruct}* ptr = &__instance)"); + WriteOpenBraceAndIndent(); + WriteLine("return ref *ptr;"); + UnindentAndWriteCloseBrace(); + UnindentAndWriteCloseBrace(); + UnindentAndWriteCloseBrace(); } else {