This should not raise a diagnostic:
class MyObject
{
public string MyObjectString;
}
class MyClass
{
private readonly List<MyObject> _items = new List<MyObject>
{
new MyObject {MyObjectString = "ItemA"},
new MyObject {MyObjectString = "ItemB"},
new MyObject {MyObjectString = "ItemC"}
};
private void MyMethod(string suffix)
{
foreach (MyObject o in _items)
{
o.MyObjectString += suffix; // CC0039 fires on this line
o.MyObjectString = o.MyObjectString + suffix; // but not on this one
}
}
}
The code fix makes no sense at all in this context.
The same issue occurs in a VB equivalent situation
The analyzer should check if the symbol being used is in context only within the foreach. Otherwise, it makes no sense.
The PR should go into the v1.0.x branch.
This should not raise a diagnostic:
The code fix makes no sense at all in this context.
The same issue occurs in a VB equivalent situation
The analyzer should check if the symbol being used is in context only within the
foreach. Otherwise, it makes no sense.The PR should go into the
v1.0.xbranch.