Improve code generation and use new UnscopedRef.

This commit is contained in:
Amer Koleci
2022-09-21 17:57:04 +02:00
parent bbced92f57
commit 5938771eb6
517 changed files with 8 additions and 3128 deletions

View File

@@ -1867,19 +1867,7 @@ public static class Program
writer.WriteLine("[MethodImpl(MethodImplOptions.AggressiveInlining)]");
using (writer.PushBlock("get"))
{
writer.WriteLineUndindented("#if NET7_0_OR_GREATER");
writer.WriteLine($"return ref {parentMemberAccess.Name}.{fieldName};");
writer.WriteLineUndindented("#else");
if (fieldTypeName.EndsWith("*"))
{
writer.WriteLine($"return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref this, 1)).{parentMemberAccess.Name}.{fieldName};");
}
else
{
writer.WriteLine($"return ref MemoryMarshal.GetReference(MemoryMarshal.CreateSpan(ref {parentMemberAccess.Name}.{fieldName}, 1));");
}
writer.WriteLineUndindented("#endif");
}
}
}