@@ -9,8 +9,8 @@ internal abstract class AbstractProjectState : IProjectState
9
9
{
10
10
protected readonly UnconfiguredProject Project ;
11
11
12
- private readonly Dictionary < ProjectConfiguration , IPropertyPagesCatalog ? > _catalogCache ;
13
- private readonly Dictionary < ( ProjectConfiguration , string , QueryProjectPropertiesContext ) , IRule ? > _ruleCache ;
12
+ private readonly Dictionary < ProjectConfiguration , IPropertyPagesCatalog ? > _catalogCache = [ ] ;
13
+ private readonly Dictionary < ( ProjectConfiguration , string , QueryProjectPropertiesContext ) , IRule ? > _ruleCache = [ ] ;
14
14
15
15
private readonly AsyncLazy < IImmutableSet < ProjectConfiguration > ? > _knownProjectConfigurations ;
16
16
private readonly AsyncLazy < ProjectConfiguration ? > _defaultProjectConfiguration ;
@@ -20,10 +20,34 @@ protected AbstractProjectState(UnconfiguredProject project)
20
20
Project = project ;
21
21
JoinableTaskFactory joinableTaskFactory = project . Services . ThreadingPolicy . JoinableTaskFactory ;
22
22
23
- _knownProjectConfigurations = new AsyncLazy < IImmutableSet < ProjectConfiguration > ? > ( CreateKnownConfigurationsAsync , joinableTaskFactory ) ;
24
- _defaultProjectConfiguration = new AsyncLazy < ProjectConfiguration ? > ( CreateDefaultConfigurationAsync , joinableTaskFactory ) ;
25
- _catalogCache = new Dictionary < ProjectConfiguration , IPropertyPagesCatalog ? > ( ) ;
26
- _ruleCache = new Dictionary < ( ProjectConfiguration , string , QueryProjectPropertiesContext ) , IRule ? > ( ) ;
23
+ _knownProjectConfigurations = new AsyncLazy < IImmutableSet < ProjectConfiguration > ? > ( CreateKnownConfigurationsAsync , joinableTaskFactory )
24
+ {
25
+ SuppressRecursiveFactoryDetection = true
26
+ } ;
27
+
28
+ _defaultProjectConfiguration = new AsyncLazy < ProjectConfiguration ? > ( CreateDefaultConfigurationAsync , joinableTaskFactory )
29
+ {
30
+ SuppressRecursiveFactoryDetection = true
31
+ } ;
32
+
33
+ async Task < IImmutableSet < ProjectConfiguration > ? > CreateKnownConfigurationsAsync ( )
34
+ {
35
+ return Project . Services . ProjectConfigurationsService switch
36
+ {
37
+ IProjectConfigurationsService configurationsService => await configurationsService . GetKnownProjectConfigurationsAsync ( ) ,
38
+ _ => null
39
+ } ;
40
+ }
41
+
42
+ async Task < ProjectConfiguration ? > CreateDefaultConfigurationAsync ( )
43
+ {
44
+ return Project . Services . ProjectConfigurationsService switch
45
+ {
46
+ IProjectConfigurationsService2 configurationsService2 => await configurationsService2 . GetSuggestedProjectConfigurationAsync ( ) ,
47
+ IProjectConfigurationsService configurationsService => configurationsService . SuggestedProjectConfiguration ,
48
+ _ => null
49
+ } ;
50
+ }
27
51
}
28
52
29
53
/// <summary>
@@ -60,32 +84,6 @@ protected AbstractProjectState(UnconfiguredProject project)
60
84
/// </summary>
61
85
public Task < ProjectConfiguration ? > GetSuggestedConfigurationAsync ( ) => _defaultProjectConfiguration . GetValueAsync ( ) ;
62
86
63
- private async Task < ProjectConfiguration ? > CreateDefaultConfigurationAsync ( )
64
- {
65
- if ( Project . Services . ProjectConfigurationsService is IProjectConfigurationsService2 configurationsService2 )
66
- {
67
- return await configurationsService2 . GetSuggestedProjectConfigurationAsync ( ) ;
68
- }
69
- else if ( Project . Services . ProjectConfigurationsService is IProjectConfigurationsService configurationsService )
70
- {
71
- return configurationsService . SuggestedProjectConfiguration ;
72
- }
73
- else
74
- {
75
- return null ;
76
- }
77
- }
78
-
79
- private async Task < IImmutableSet < ProjectConfiguration > ? > CreateKnownConfigurationsAsync ( )
80
- {
81
- if ( Project . Services . ProjectConfigurationsService is IProjectConfigurationsService configurationsService )
82
- {
83
- return await configurationsService . GetKnownProjectConfigurationsAsync ( ) ;
84
- }
85
-
86
- return null ;
87
- }
88
-
89
87
/// <summary>
90
88
/// Retrieves the set of property pages that apply to the project level for the given <paramref
91
89
/// name="projectConfiguration"/>.
0 commit comments