Code Cleanup: "Use 'var' in declaration' for foreach not working

v[4.5.1288.2]

I have created a simple cleanup template with 2 options besides default:

[-] Use 'var' in declaration
......'foreach' iteran declaration... Always use 'var' <---
<...>
Reformat code [X]

I notice the following for this template:
1) The "foreach" option doesn't show in the "Code cleanup" dialog, i.e. below string is always displayed:
Use 'var' in declaration: -->Do not change<---

However the option "Reformat code:" correctly states "Yes".

When I run this cleanup in a file with explicit declared foreach loops, they aren't converted to "var".

-------------------------------------------
Related suggested enhancement:
Since foreach implicitly do the casts when not using "var", it would be nice having Resharper being able to flag a warning for such foreach loops if one does not use the "var" keyword.

E.g. so I can choose to have Resharper notify me for below code (which compiler happily swallows without warning):

IList<double> doubles = new List<double> {22.123, 400.12, 100.22};
foreach (int number in doubles)
{
Console.WriteLine("The Current Number Is : {0}", number);
}
-------------------------------------------

Thanks.

0

Please sign in to leave a comment.