Skip to content

Modreq usage of UnmanagedType type should be documented #7783

Open
@hamarb123

Description

@hamarb123

Issue description

The code following C# code

public void UnmanagedT<T>() where T : unmanaged { }

generates the following IL code:

.method public hidebysig 
instance void UnmanagedT<valuetype .ctor (class [mscorlib]System.ValueType modreq([mscorlib]System.Runtime.InteropServices.UnmanagedType)) T> () cil managed 
{
.param type T
    .custom instance void System.Runtime.CompilerServices.IsUnmanagedAttribute::.ctor() = (
        01 00 00 00
    )
.maxstack 8
IL_0000: ret
}

which expect any compilers wanting to use the method to know that the type parameter T has to meet certain requirements.

With the System.Runtime.CompilerServices.IsVolatile type it is documented how & what the modreq does, it should be the same here. It would also be good if System.Runtime.CompilerServices.IsExternalInit (and any others missing it) got the same documentation.

I'm looking on https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.unmanagedtype?view=net-6.0.

Target framework

  • .NET Core 1.0+
  • .NET Framework 1.1+
  • .NET Standard 1.1+

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions