未验证 提交 ed9c6976 编写于 作者: J Jb Evain 提交者: GitHub

Fix handling of retargeted fixed size fields (#47429)

上级 a4efc4a9
......@@ -118,6 +118,14 @@ internal override ImmutableArray<byte> MarshallingDescriptor
}
}
public override bool IsFixedSizeBuffer
{
get
{
return _underlyingField.IsFixedSizeBuffer;
}
}
internal override int? TypeLayoutOffset
{
get
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Retargeting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.UnitTests.Emit;
......@@ -1136,5 +1137,22 @@ .maxstack 1
IL_001f: ret
}");
}
[Fact]
[WorkItem(1141012, "https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1141012")]
public void FixedSizeBufferRetargeting()
{
var source = @"
public unsafe struct FixedBuffer
{
public fixed byte buffer[256];
}";
var comp = CreateCompilation(source, options: TestOptions.UnsafeReleaseDll, targetFramework: TargetFramework.Mscorlib40, assemblyName: "fixedBuffer");
comp.VerifyDiagnostics();
var comp3 = CreateCompilation("", references: new[] { comp.ToMetadataReference() }, targetFramework: TargetFramework.Mscorlib46);
var retargetingField = comp3.GlobalNamespace.GetMember<NamedTypeSymbol>("FixedBuffer").GetMember<RetargetingFieldSymbol>("buffer");
Assert.True(retargetingField.IsFixedSizeBuffer);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册