Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
vcsjones opened this issue Feb 26, 2025 · 0 comments
Open

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

vcsjones opened this issue Feb 26, 2025 · 0 comments
Milestone

Comments

@vcsjones
Copy link
Member

vcsjones commented Feb 26, 2025

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

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-GenAPI untriaged Request triage from a team member labels Feb 26, 2025
@ViktorHofer ViktorHofer added this to the Backlog milestone Mar 10, 2025
@ViktorHofer ViktorHofer removed the untriaged Request triage from a team member label Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants