Where is "always use var in foreach" in RS 9?

With RS 7.1 we could choose as part of cleanup to change "foreach (int i in ints)" to be "foreach (var i in ints)" but with RS9, after changing "Use 'var' when evident" in "var usage declartions", RS will always use "int" and not "var". I can't seem to find the "Use var in foreach" setting anywhere, am I missing something?



The "use in foreach" setting has been replaced with the 'var' usage options in the Code Style dialog. New and suggested language constructs in C#6 mean that there are more places to use var, and instead of providing separate configuration for each location, the 'var' settings have been consolidated to allow usage of 'var' for built in types (int, string, etc), simple types (classes) and 'elsewhere' (arrays, pointers, etc.). You can change if 'var' should be used for each of these usages separately, from always use 'var', use 'var' when evident (e.g. new statements) and 'use explicit type'. So, the settings have been simplified - to get 'var' in 'foreach', you should set the option to 'use var'.


int foo = 0; //here we don't want var (mainly due to we had it like that before, and want to avoid altering lines just because RS 9 cannot upgrade the "code layout" settings)
foreach(var item in collection) { //Here we ALWAYS want to use var to avoid incorrect casting, no matter if it is "evident" or not (i.e. also var in (foreach var item in getItems<Foo>)
int foo = Load(); //here we don't want to use var
object obj = GetObject(); //Here we don't want to use var

var foo = Load<Foo>(); //Here we want to use var
var foo2 = new Foo(); //Here we want to use var.

Sorry but I don't understand how I can alter the 3 settings in order to keep the above logic we had in RS 7.1.


( https://youtrack.jetbrains.com/issue/RSRP-433029 )
Sigh... You introduce a breaking change and won't even give us a workaround and keep pushing fix of it in future major versions (now scheduled in v10 :()

Come' on guys.


Please sign in to leave a comment.