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

IDE0290 code fix is invalid in ref struct #73614

Open
meziantou opened this issue May 21, 2024 · 2 comments · May be fixed by #73869
Open

IDE0290 code fix is invalid in ref struct #73614

meziantou opened this issue May 21, 2024 · 2 comments · May be fixed by #73869
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Milestone

Comments

@meziantou
Copy link
Contributor

Version Used: '4.11.0-1.24229.8 (28985c0)'. Language version: 12.0

Steps to Reproduce:

https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoTAnApgMwAIBnAF2wFcBjUwgZQjAAcAbXTAb00J8KeygA3CKVyEASrggATAPIwWATzpMIMADxUAFhGwA+QgH0y2ANyZuvBAGZ6jVrgAUkmfKUq1mnfpLkAlJY8XBi8oUYmhAC8vmaBhAC+FiFWtggALIQAsgD2grgAcrgAHqSOAclBcaHC2CSqMFHh5OYVCZiJGEA

ref struct Sample
{
    private ReadOnlySpan<char> _str;

    public Sample(ReadOnlySpan<char> str)
    {
        _str = str;
    }

    public void MoveNext()
    {
        var span = _str;
    }
}

Use the fix to convert to primary constructor and remove field

ref struct Sample(ReadOnlySpan<char> str)
{
    public void MoveNext()
    {
        // ❌ CS9110 Cannot use primary constructor parameter 'str' that has ref-like type inside an instance member
        var span = str;
    }
}

Diagnostic Id: IDE0290 Use primary Constructor

Expected Behavior: The code fix is not suggested

Actual Behavior: The code fix is suggested

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 21, 2024
@CyrusNajmabadi CyrusNajmabadi added Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels May 21, 2024
@CyrusNajmabadi CyrusNajmabadi added this to InQueue in Small Fixes via automation May 21, 2024
@CyrusNajmabadi CyrusNajmabadi added this to the Backlog milestone May 21, 2024
@GiovanniBraconi
Copy link
Contributor

GiovanniBraconi commented Jun 4, 2024

If nobody is working on this issue, i'll happily take a look at it 😃

@CyrusNajmabadi
Copy link
Member

@GiovanniBraconi Absolutely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Small Fixes
  
InQueue
Development

Successfully merging a pull request may close this issue.

3 participants