Be careful removing items from rule sets
Fixes #3098. It is possible to have multiple `<Rule>` elements with the same ID in a rule set file, so long as they specify the same Action. This is likely to happen with former FxCop rules--you'll end up with one copy under the "Microsoft.Analyzers.ManagedCodeAnalysis" analyzer (from FxCop) and one under "Microsoft.AnalyzerPowerPack.CSharp" (from a Roslyn-based analyzer). When the user selects one of these rules in Solution Explorer and sets the severity to "Default" we need to find each rule with the matching ID, and remove them all from the rule set file. However, we remove the rules while we're in the middle of the enumeration, tripping up the enumerator and leading to `NullReferenceException`s. The fix is to first flatten the enumeration of items to be removed to a list, and then remove them.
Showing
想要评论请 注册 或 登录