dotnet/roslyn
在 GitHub 查看IDE0200 (remove unnecessary lambda expression) can change semantics when capturing writable members
Open
#73,259 创建于 2024年4月29日
Area-IDEBugFeature - IDE0200help wanted
仓库指标
- Star
- (20,414 star)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Version Used:
Steps to Reproduce:
public class Test {
private List<int> _list = [1];
public bool N() {
var func = M();
_list = [2];
return func(2);
}
private Func<int, bool> M() {
return x => _list.Contains(x); // IDE0200
}
}
Diagnostic Id:
IDE0200
Expected Behavior: The code fix should not be offered. It changes the semantics.
Actual Behavior:
After applying the code fix, N returns false instead of true
I saw that this was fixed when capturing locals in #69101