Skip to content

Fix TS lightbulb regression#58392

Merged
mavasani merged 1 commit intodotnet:mainfrom
mavasani:JSBugFix
Dec 17, 2021
Merged

Fix TS lightbulb regression#58392
mavasani merged 1 commit intodotnet:mainfrom
mavasani:JSBugFix

Conversation

@mavasani
Copy link
Copy Markdown
Contributor

Fixes AB#1450689

This regression was introduced with async lightbulb performance improvement PR: #56959. With that PR, we now optimize/reduce the number of analyzers to execute in the "Normal" priority bucket for async light bulb. We earlier executed all analyzers in this bucket, but now only try to execute analyzers which report at least one diagnostic ID which has a corresponding code fix provider that can fix that diagnostic ID.

To identify this reduced set of analyzers, we execute this newly added perf optimization to skip analyzers that don't have a code fix:

if (_shouldIncludeDiagnostic != null &&
!_owner.DiagnosticAnalyzerInfoCache.GetDiagnosticDescriptors(stateSet.Analyzer).Any(a => _shouldIncludeDiagnostic(a.Id)))
{
continue;
}

_owner.DiagnosticAnalyzerInfoCache.GetDiagnosticDescriptors call in this code is problematic for TS analyzers, because these are not regular DiagnosticAnalyzer sub-types, but instead derive from our internal DocumentDiagnosticAnalyzer and ProjectDiagnosticAnalyzer types, and this analyzer lies to us and returns 0 supported diagnostic descriptors:

public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray<DiagnosticDescriptor>.Empty;
and
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray<DiagnosticDescriptor>.Empty;
. So, we skip TS analyzers for "Normal" priority bucket.

This PR implements a short term fix to update the newly added code to special case DocumentDiagnosticAnalyzers and skip the newly added perf optimization for these analyzers. Note that ProjectDiagnosticAnalyzers are never executed in lightbulb/code fix path.

I will create a separate issue to track designing a better long term solution for TS analyzers to avoid such breaking changes in future.

…edit/1450689)

This regression was introduced with async lightbulb performance improvement PR: dotnet#56959. With that PR, we now optimize/reduce the number of analyzers to execute in the "Normal" priority bucket for async light bulb. We earlier executed all analyzers in this bucket, but now only try to execute analyzers which report at least one diagnostic ID which has a corresponding code fix provider that can fix that diagnostic ID.

To identify this reduced set of analyzers, we execute this newly added perf optimization to skip analyzers that don't have a code fix: https://github.com/dotnet/roslyn/blob/88f829939583d49d9e08104a71a7645d712bcfbc/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs#L151-L155

`_owner.DiagnosticAnalyzerInfoCache.GetDiagnosticDescriptors` call in this code is problematic for TS analyzers, because these are not regular DiagnosticAnalyzer sub-types, but instead derive from our internal DocumentDiagnosticAnalyzer and ProjectDiagnosticAnalyzer types, and this analyzer lies to us and returns 0 supported diagnostic descriptors: https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs#L16 and https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs#L16. So, we skip TS analyzers for "Normal" priority bucket.

This PR implements a short term fix to update the newly added code to special case DocumentDiagnosticAnalyzers and skip the newly added perf optimization for these analyzers. Note that ProjectDiagnosticAnalyzers are never executed in lightbulb/code fix path.

I will create a separate issue to track designing a better long term solution for TS analyzers to avoid such breaking changes in future.
@mavasani mavasani added this to the 17.1 milestone Dec 17, 2021
@mavasani mavasani requested review from a team and CyrusNajmabadi December 17, 2021 11:48
@mavasani
Copy link
Copy Markdown
Contributor Author

Tagging @vatsalyaagrawal @jinujoseph - do I need to target this PR to a specific release branch for next 17.1 preview OR targeting main branch will make it flow into next 17.1 preview?

@mavasani mavasani merged commit 834bc3c into dotnet:main Dec 17, 2021
@ghost ghost modified the milestones: 17.1, Next Dec 17, 2021
@mavasani mavasani deleted the JSBugFix branch December 17, 2021 18:13
@Cosifne Cosifne modified the milestones: Next, 17.1.P3 Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants