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

False positive IDE0241 Nullable directive is unnecessary #75951

Open
TessenR opened this issue Nov 17, 2024 · 0 comments
Open

False positive IDE0241 Nullable directive is unnecessary #75951

TessenR opened this issue Nov 17, 2024 · 0 comments
Labels
Area-IDE Feature - IDE0241 untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@TessenR
Copy link

TessenR commented Nov 17, 2024

Version Used:

Microsoft Visual Studio Professional 2022
Version 17.13.0 Preview 1.0
VisualStudio.17.Preview/17.13.0-pre.1.0+35507.96
Microsoft .NET Framework
Version 4.8.09037

Steps to Reproduce:

Paste the following code into the editor

#nullable enable

public class Test
{
#nullable disable
  public Test() { }
#nullable enable

  public string Value { get; set; }
}

Diagnostic Id:

IDE0241 Nullable directive is unnecessary is reported for #nullable disable directive

Expected Behavior:
The directive is not reported as redundant as it turns off nullable analysis warnings in the constructor

Actual Behavior:
IDE0241 Nullable directive is unnecessary is reported for #nullable disable directive
The directive is highlighted as redundant
Removing the directive introduces a compiler warning CS8618: Non-nullable property Value must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature - IDE0241 untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

3 participants