Repository navigation
Closed
Labels
area-Tools-ILVerificationIssues related to ilverify tool and IL verification in generalhelp wanted[up-for-grabs] Good issue for external contributorsuntriagedNew issue has not been triaged by the area owner
Description
Description
Assignments of an extension method to Action trips ILVerification.
Reproduction Steps
Compile the following C# code and verify it.
The verification fails with:
Unrecognized arguments for delegate .ctor. { Offset = 21 } // that's 0x15
Unrecognized arguments for delegate .ctor. { Offset = 59 } // that's 0x3B
using System;
static class Program
{
static void Main()
{
"ABC".Goo();
Action a = "123".Goo;
a();
a = new Action(a);
a();
a = new Action("xyz".Goo);
a();
}
static void Goo(this string x)
{
Console.WriteLine(x);
}
}// ILVerify:
// Unrecognized arguments for delegate .ctor. { Offset = 21 } // that's 0x15
// Unrecognized arguments for delegate .ctor. { Offset = 59 } // that's 0x3B
.class private auto ansi abstract sealed beforefieldinit Program
extends [netstandard]System.Object
{
.custom instance void [netstandard]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
01 00 00 00
)
// Methods
.method private hidebysig static
void Main () cil managed
{
// Method begins at RVA 0x2050
// Code size 70 (0x46)
.maxstack 2
.entrypoint
IL_0000: ldstr "ABC"
IL_0005: call void Program::Goo(string)
IL_000a: ldstr "123"
IL_000f: ldftn void Program::Goo(string)
IL_0015: newobj instance void [netstandard]System.Action::.ctor(object, native int)
IL_001a: dup
IL_001b: callvirt instance void [netstandard]System.Action::Invoke()
IL_0020: ldftn instance void [netstandard]System.Action::Invoke()
IL_0026: newobj instance void [netstandard]System.Action::.ctor(object, native int)
IL_002b: callvirt instance void [netstandard]System.Action::Invoke()
IL_0030: ldstr "xyz"
IL_0035: ldftn void Program::Goo(string)
IL_003b: newobj instance void [netstandard]System.Action::.ctor(object, native int)
IL_0040: callvirt instance void [netstandard]System.Action::Invoke()
IL_0045: ret
} // end of method Program::Main
.method private hidebysig static
void Goo (
string x
) cil managed
{
.custom instance void [netstandard]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = (
01 00 00 00
)
// Method begins at RVA 0x20a2
// Code size 7 (0x7)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call void [netstandard]System.Console::WriteLine(string)
IL_0006: ret
} // end of method Program::Goo
} // end of class ProgramThis was found in Roslyn, test: ExtensionMethodTests.ExtensionMethodInTheSameClass. Discussion
Expected behavior
No error (ie. same behavior as PEVerify)
Actual behavior
Unrecognized arguments for delegate .ctor. { Offset = 21 }
Unrecognized arguments for delegate .ctor. { Offset = 59 }
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
area-Tools-ILVerificationIssues related to ilverify tool and IL verification in generalhelp wanted[up-for-grabs] Good issue for external contributorsuntriagedNew issue has not been triaged by the area owner
Activity
Fix verification of open delegates
Fix verification of open delegates (#65425)