You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]publicvoidExternEvent(){varsource=""" using System; using System.Runtime.InteropServices; public static class C { [method: DllImport("something.dll")] public static extern event EventHandler E; } """;CompileAndVerify(source,symbolValidator:verify,verify:Verification.Skipped).VerifyDiagnostics();staticvoidverify(ModuleSymbolmodule){varev=module.GlobalNamespace.GetMember<EventSymbol>("C.E");Assert.True(ev.GetPublicSymbol().IsExtern);verifyAccessor(ev.AddMethod!);verifyAccessor(ev.RemoveMethod!);}staticvoidverifyAccessor(MethodSymbolaccessor){Assert.True(accessor.GetPublicSymbol().IsExtern);varimportData=accessor.GetDllImportData()!;Assert.Equal("something.dll",importData.ModuleName);Assert.Equal(accessor.MetadataName,importData.EntryPointName);// 'add_E' or 'remove_E' expected}}
Or simply compile the following program and inspect the IL:
Expected Behavior: Both add_E and remove_E accessors to be similar.
Actual Behavior: add_E accessor emitted with pinvokeimpl("something.dll" as "remove_E" winapi):
.class public auto ansi abstractsealedbeforefieldinitCextends[System.Runtime]System.Object
{// Methods.methodpublic hidebysig specialname static pinvokeimpl("something.dll"as"remove_E" winapi)voidadd_E(class[System.Runtime]System.EventHandler 'value')cilmanaged preservesig
{.custominstancevoid[System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()=(01000000)}// end of method C::add_E.methodpublichidebysigspecialname static pinvokeimpl("something.dll" winapi)voidremove_E(class[System.Runtime]System.EventHandler 'value'
) cil managed preservesig
{.custom instance void[System.Runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor()=(01000000)}// end of method C::remove_E// Events.event[System.Runtime]System.EventHandlerE{.addon void C::add_E(class[System.Runtime]System.EventHandler).removeon void C::remove_E(class[System.Runtime]System.EventHandler)}}// end of class C
The text was updated successfully, but these errors were encountered:
Version Used: 347e576
Steps to Reproduce:
Run the following test:
Or simply compile the following program and inspect the IL:
Expected Behavior: Both
add_E
andremove_E
accessors to be similar.Actual Behavior:
add_E
accessor emitted withpinvokeimpl("something.dll" as "remove_E" winapi)
:The text was updated successfully, but these errors were encountered: