SergeyTeplyakov / ErrorProne.NET

Set of roslyn-based analyzers for catching common C# errors (inspired by Google's error-prone)
MIT License
886 stars 42 forks source link

Don't descend into attribute lists when looking for assignments to 'this' #250

Closed tg73 closed 2 years ago

tg73 commented 2 years ago

I've done some Roslyn development in the past, but am not an expert. To the best of my understanding, there's no way an attribute could cause an assignment to 'this'. My change ignores attributes, and this stops later code triggering an exception in Microsoft.CodeAnalysis.CSharp. It may be that a broader category of nodes should be skipped here, and/or that the same logic should be applied in other places, but that needs more experienced and expert input. Fixes #249.

SergeyTeplyakov commented 2 years ago

Thanks a lot for the fix!