Skip to content

Commit

Permalink
Fixed issue with ref returns
Browse files Browse the repository at this point in the history
(cherry picked from commit cbd37c9)
  • Loading branch information
JordanL8 committed Feb 20, 2024
1 parent a0dee88 commit 4c1d544
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 4c1d544

Please sign in to comment.