dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.06k stars 4.04k forks source link

'Use pattern-matching' should be missing on writes from local function captures #29512

Open alrz opened 6 years ago

alrz commented 6 years ago

From https://github.com/dotnet/roslyn/pull/26097#discussion_r210728805

We should look for writes that are logically within the span, but syntactically are not.

var s = field as string;
WriteField();
if (s != null) { ... }

void WriteField () => field = null;

/cc @sharwell

CyrusNajmabadi commented 3 weeks ago

We would be willing to take a focused pr here.