Skip to content

Commit

Permalink
Fixed issue with ref returns
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanL8 committed Feb 16, 2024
1 parent 1a249b6 commit cbd37c9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Generator/Generators/CSharp/CSharpSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit cbd37c9

Please sign in to comment.