Stylecopanalyzers: Update SA1312 code fix to replace `var _` with `_`

Created on 8 Mar 2018  路  3Comments  路  Source: DotNetAnalyzers/StyleCopAnalyzers

Similar to #2599, which is for SA1313.

SA1312: Variable '_' should begin with lower-case letter

For example, some test code verifies a mock's property wasn't called:

c# var _ = mock.DidNotReceive().SomeProperty;

enhancement up for grabs

Most helpful comment

How aboud this issue?
I met the same problem when I want to ignore a local variable with using declration in c# 8.0.

using var _ = new DisposableObject();

All 3 comments

:bulb: You can drop var if you are using C# 7. That will turn the code into a discard syntax instead of declaring a local variable.

Thanks, that works perfectly.

Feel free to close this, but I think it might be nice to have the analyzer know how to fix this where possible.

How aboud this issue?
I met the same problem when I want to ignore a local variable with using declration in c# 8.0.

using var _ = new DisposableObject();
Was this page helpful?
0 / 5 - 0 ratings