Open
Description
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
- Create or open a C# project in Visual Studio Code (Visual Studio untested).
- 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
- Add the following code wherever syntactically applicable:
var e = E.A; enum E { A }
- Observe the suggestion
Use explicit type instead of 'var' (IDE0008)
on thevar
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();