Skip to content

GenAPI: Does not preserve allows ref struct "unconstraint" #47113

Open
@vcsjones

Description

@vcsjones

Consider an assembly with a type like this:

namespace Scratch {
    public class Potato {
        public T Carrot<T>(T t) where T : allows ref struct
        {
            return t;
        }
    }
}

Using Microsoft.DotNet.GenAPI.Tool, it generates this:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Scratch
{
    public partial class Potato
    {
        public Potato() { }

        public T Carrot<T>(T t) { throw null; }
    }
}

The allows ref struct constraint on T has been lost.

Invocation of the tool was performed as dotnet Microsoft.DotNet.GenAPI.Tool.dll --assembly ~/Projects/scratch/bin/Debug/net9.0/scratch.dll

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions