@@ -40,12 +40,12 @@ namespace Microsoft.CodeAnalysis.CodeFixes;
40
40
internal sealed partial class CodeFixService : ICodeFixService
41
41
{
42
42
private readonly ImmutableArray < Lazy < CodeFixProvider , CodeChangeProviderMetadata > > _fixers ;
43
- private readonly ImmutableDictionary < string , ImmutableArray < Lazy < CodeFixProvider , CodeChangeProviderMetadata > > > _fixersPerLanguageMap ;
43
+ private readonly Lazy < ImmutableDictionary < string , ImmutableArray < Lazy < CodeFixProvider , CodeChangeProviderMetadata > > > > _fixersPerLanguageMap ;
44
44
45
45
private readonly ConditionalWeakTable < IReadOnlyList < AnalyzerReference > , ImmutableDictionary < DiagnosticId , ImmutableArray < CodeFixProvider > > > _projectFixersMap = new ( ) ;
46
46
47
47
// Shared by project fixers and workspace fixers.
48
- private readonly ImmutableDictionary < LanguageKind , Lazy < ImmutableArray < IConfigurationFixProvider > > > _configurationProvidersMap ;
48
+ private readonly Lazy < ImmutableDictionary < LanguageKind , Lazy < ImmutableArray < IConfigurationFixProvider > > > > _configurationProvidersMap ;
49
49
private readonly ImmutableArray < Lazy < IErrorLoggerService > > _errorLoggers ;
50
50
51
51
private ImmutableDictionary < LanguageKind , Lazy < ImmutableDictionary < DiagnosticId , ImmutableArray < CodeFixProvider > > > > ? _lazyWorkspaceFixersMap ;
@@ -65,9 +65,9 @@ public CodeFixService(
65
65
_errorLoggers = [ .. loggers ] ;
66
66
67
67
_fixers = [ .. fixers ] ;
68
- _fixersPerLanguageMap = _fixers . ToPerLanguageMapWithMultipleLanguages ( ) ;
68
+ _fixersPerLanguageMap = new ( ( ) => _fixers . ToPerLanguageMapWithMultipleLanguages ( ) ) ;
69
69
70
- _configurationProvidersMap = GetConfigurationProvidersPerLanguageMap ( configurationProviders ) ;
70
+ _configurationProvidersMap = new ( ( ) => GetConfigurationProvidersPerLanguageMap ( configurationProviders ) ) ;
71
71
}
72
72
73
73
private Func < string , bool > ? GetShouldIncludeDiagnosticPredicate (
@@ -455,7 +455,7 @@ private async IAsyncEnumerable<CodeFixCollection> StreamFixesAsync(
455
455
var hasAnySharedFixer = TryGetWorkspaceFixersMap ( document , out var fixerMap ) ;
456
456
457
457
var projectFixersMap = GetProjectFixers ( document ) ;
458
- var hasAnyProjectFixer = projectFixersMap . Any ( ) ;
458
+ var hasAnyProjectFixer = ! projectFixersMap . IsEmpty ;
459
459
460
460
if ( ! hasAnySharedFixer && ! hasAnyProjectFixer )
461
461
yield break ;
@@ -715,7 +715,7 @@ private async IAsyncEnumerable<CodeFixCollection> StreamConfigurationFixesAsync(
715
715
{
716
716
cancellationToken . ThrowIfCancellationRequested ( ) ;
717
717
718
- if ( ! _configurationProvidersMap . TryGetValue ( document . Project . Language , out var lazyConfigurationProviders ) ||
718
+ if ( ! _configurationProvidersMap . Value . TryGetValue ( document . Project . Language , out var lazyConfigurationProviders ) ||
719
719
lazyConfigurationProviders . Value == null )
720
720
{
721
721
yield break ;
@@ -812,7 +812,7 @@ await diagnosticsWithSameSpan.OrderByDescending(d => d.Severity)
812
812
/// <summary> Looks explicitly for an <see cref="AbstractSuppressionCodeFixProvider"/>.</summary>
813
813
public CodeFixProvider ? GetSuppressionFixer ( string language , IEnumerable < string > diagnosticIds )
814
814
{
815
- if ( ! _configurationProvidersMap . TryGetValue ( language , out var lazyConfigurationProviders ) ||
815
+ if ( ! _configurationProvidersMap . Value . TryGetValue ( language , out var lazyConfigurationProviders ) ||
816
816
lazyConfigurationProviders . Value . IsDefault )
817
817
{
818
818
return null ;
@@ -881,7 +881,7 @@ private ImmutableDictionary<LanguageKind, Lazy<ImmutableDictionary<DiagnosticId,
881
881
{
882
882
var fixerMap = ImmutableDictionary . Create < LanguageKind , Lazy < ImmutableDictionary < DiagnosticId , ImmutableArray < CodeFixProvider > > > > ( ) ;
883
883
var extensionManager = services . GetService < IExtensionManager > ( ) ;
884
- foreach ( var ( diagnosticId , lazyFixers ) in _fixersPerLanguageMap )
884
+ foreach ( var ( diagnosticId , lazyFixers ) in _fixersPerLanguageMap . Value )
885
885
{
886
886
var lazyMap = new Lazy < ImmutableDictionary < DiagnosticId , ImmutableArray < CodeFixProvider > > > ( ( ) =>
887
887
{
@@ -942,7 +942,7 @@ static ImmutableArray<IConfigurationFixProvider> GetConfigurationFixProviders(Im
942
942
private ImmutableDictionary < LanguageKind , Lazy < ImmutableDictionary < CodeFixProvider , int > > > GetFixerPriorityPerLanguageMap ( SolutionServices services )
943
943
{
944
944
var languageMap = ImmutableDictionary . CreateBuilder < LanguageKind , Lazy < ImmutableDictionary < CodeFixProvider , int > > > ( ) ;
945
- foreach ( var ( diagnosticId , lazyFixers ) in _fixersPerLanguageMap )
945
+ foreach ( var ( diagnosticId , lazyFixers ) in _fixersPerLanguageMap . Value )
946
946
{
947
947
var lazyMap = new Lazy < ImmutableDictionary < CodeFixProvider , int > > ( ( ) =>
948
948
{
0 commit comments