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
18.91k stars 4.01k forks source link

Analyzer feature telemetry #66784

Open arkalyanms opened 1 year ago

arkalyanms commented 1 year ago

This tracks improving analyzer feature telemetry and below was the original analysis by ManishV

arkalyanms commented 1 year ago

@mavasani Parking this on you for now to solicit discussion on further analyzer telemetry improvements. This is not an immediate call to action.

CyrusNajmabadi commented 1 year ago

Note: a core issue we have here (and which we likely need compiler team to help address) is that the nature of analyzers is fine for batch scenarios but not great for IDE/lightbulb work. Specifically, analyzers are hooked into while the compiler is running analysis on a file. Then, diagnostics are produced which then have to be fed into appropriate fixes to fix.

This invariably means that "Asking for a lightbulb" ends up performing a ton of work, much/most of which is not in any way useful for the actual core experience that the user is driving.

The original design here for the IDE (Back when these were called "smart tags") was that the experience was driven in teh reverse direction. Based on where the user was querying, the analyzers/fixers would determine quickly if they were even potentially involved, and would not do anything if they were not. This meant not having to do all the analysis and run everything, just to determine if they might end up mattering for the location the user was at.

I have a strong suspicion we need something similar here. The design of analyzers/fixers needs to be updated to be conscientious that "batch compiling mode" is just one mode they run in. But "targetted-location, latency-sensitive mode" is also something they should support. In other words, we should be able to flow in precisely what location we're querying about, and sidestep all unnecessary computation/analyzers/fixers that could not be involved in that request.