roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Expose constructor that allows for AnalysisOptions and a CancellationToken.

Open CyrusNajmabadi opened this issue 3 years ago • 5 comments

Fixes https://github.com/dotnet/roslyn/issues/41522.

The API here is definitely screwy. You can either provider AnalyzerOptions? options and a CancellationToken, or you can provide CompilationWithAnalyzersOptions analysisOptions but no cancellation token.

@jasonmalinowski @mavasani on this. Unless it was intentionaly that you not be allowed to pass a CT here, this seems broken. If we don't want people passing a CT here, we should doc why.

CyrusNajmabadi avatar Oct 27 '22 16:10 CyrusNajmabadi

@dotnet/roslyn-compiler ptal. Thanks!

CyrusNajmabadi avatar Nov 16 '22 20:11 CyrusNajmabadi

This adds a public API. Why isn't CI requiring this to be registered in the publicAPI tracking files?

no clue. @jasonmalinowski do we still do the publicapi thingy? or was that discontinued?

CyrusNajmabadi avatar Nov 16 '22 21:11 CyrusNajmabadi

API Review

  • API is approved.
public class CompilationWithAnalyzers
{

       public CompilationWithAnalyzers(
           Compilation compilation,
           ImmutableArray<DiagnosticAnalyzer> analyzers,
           CompilationWithAnalyzersOptions analysisOptions,
           CancellationToken cancellationToken);
}

333fred avatar Dec 08 '22 21:12 333fred

API was approved. @dotnet/roslyn-compiler @jcouv ptal. Thanks!

CyrusNajmabadi avatar Dec 13 '22 19:12 CyrusNajmabadi

Converting this to a draft. Looking into ths more, we're actually very skeptical about this existing API to begin with. Namely, it allows a CT to be passed in, that is then never observed by anything in the system. So it feels like a better approach might be to deprecate the CT overloads and make it clear that it is unused.

CyrusNajmabadi avatar Dec 13 '22 20:12 CyrusNajmabadi

Closing out in favor of https://github.com/dotnet/roslyn/pull/69108.

CyrusNajmabadi avatar Jul 19 '23 15:07 CyrusNajmabadi