Open LesRamer opened 5 years ago
(edited request to revise formatting.)
I note that the examples in my request are simplistic. Production-code is likely to contain complexities that would render doing this analyzer & fix in a robust/comprehensive manner difficult or impractical. However, working for the simplest scenarios like simple property access that I show in the method call could still be immensely useful.
Product and Version Used: Roslynator Analyzers (New as-of 2.1.0)
Before
After
The scope with a method call is obvious, but it seems like this should be applicable across various scopes where 'person' is not reassigned. Also, this could be triggered by other expressions that indicate that a null is possible -- for instance:
Before / Alternate Scope Example
After Fix