Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Update doc for OpCodes.Constrained to "support" static abstract interface members. #9139

Copy link
Copy link
Open
@gurustron

Description

@gurustron
Issue body actions

The doc explicitly says that this opcode can appear only a callvirt instruction:

The constrained prefix is permitted only on a callvirt instruction.

But according to sharplab the following:

public interface ITestable {
    public abstract static void Test();
}

public class MyTester<T> where T : ITestable {
    public void RunTest() {
        T.Test();
    }
}

Leads to the following IL:

    .method public hidebysig 
        instance void RunTest () cil managed 
    {
        // Method begins at RVA 0x208e
        // Code size 12 (0xc)
        .maxstack 8

        IL_0000: constrained. !T
        IL_0006: call void ITestable::Test()
        IL_000b: ret
    } // end of method MyTester`1::RunTest

Assuming that sharplab is right and this is intended behaviour it seems that update for docs can be needed.

Tacodiva

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityIndicates issues/PRs that are low priorityarea-System.Reflection.Emitdoc-bugProblem with the content; needs to be fixedProblem with the content; needs to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.