RCS1264: Use 'var' or explicit type
Properties
| Property | Value |
|---|---|
| Default Severity | disabled by default |
| Minimum language version | - |
Examples
Example #1
.editorconfig
roslynator_use_var = always
diagnostic.cs
string s = GetValue();
List<string> items = new List<string>();
fix.cs
var s = GetValue();
var items = new List<string>();
Example #2
.editorconfig
roslynator_use_var = never
diagnostic.cs
var s = GetValue();
var items = new List<string>();
fix.cs
string s = GetValue();
List<string> items = new List<string>();
Example #3
.editorconfig
roslynator_use_var = when_type_is_obvious
diagnostic.cs
List<string> items = new List<string>();
TimeSpan timeSpan = TimeSpan.Parse(value);
var s = GetValue();
fix.cs
var items = new List<string>();
var timeSpan = TimeSpan.Parse(value);
string s = GetValue();
Configuration
info
Option roslynator_use_var is required to be set for this analyzer to work.
.editorconfig
# Use 'var' instead of explicit type
roslynator_use_var = always|never|when_type_is_obvious