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

Use explicit type instead of 'var' emitted on enum value assignment #75289

Open
just-ero opened this issue Sep 29, 2024 · 0 comments
Open

Use explicit type instead of 'var' emitted on enum value assignment #75289

just-ero opened this issue Sep 29, 2024 · 0 comments
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@just-ero
Copy link

just-ero commented Sep 29, 2024

Version Used

Compiler: 4.12.0-3.24470.4 (d799b05)
.NET: 9.0.100-rc.1.24452.12
Visual Studio Code: 1.93.1, 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, x64
C# Extension: v2.49.25
C# Dev Kit Extension: v1.11.11

Steps to Reproduce

  1. Create or open a C# project in Visual Studio Code (Visual Studio untested).
  2. Set or add the following properties to an .editorconfig file that applies to the project:
    csharp_style_var_elsewhere             = false:suggestion
    csharp_style_var_when_type_is_apparent = true:suggestion
    
  3. Add the following code wherever syntactically applicable:
    var e = E.A;
    enum E { A }
  4. Observe the suggestion Use explicit type instead of 'var' (IDE0008) on the var keyword.

Expected Behavior

The suggestion is not emitted, as the type is quite apparent.

Actual Behavior

The suggestion is emitted.

The suggestion is not emitted for these snippets:

var e = default(E);
var e = new E();
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant