2
2
// Licensed under the MIT license. See License.txt in the project root for license information.
3
3
4
4
using System ;
5
- using System . Collections . Immutable ;
6
5
using System . Composition ;
7
6
using System . IO ;
8
7
using Microsoft . AspNetCore . Razor . Telemetry ;
@@ -30,23 +29,16 @@ internal sealed class FallbackProjectManager(
30
29
private readonly ProjectSnapshotManagerAccessor _projectSnapshotManagerAccessor = projectSnapshotManagerAccessor ;
31
30
private readonly ITelemetryReporter _telemetryReporter = telemetryReporter ;
32
31
33
- private ImmutableHashSet < ProjectId > _fallbackProjectIds = ImmutableHashSet < ProjectId > . Empty ;
34
-
35
32
internal void DynamicFileAdded ( ProjectId projectId , ProjectKey razorProjectKey , string projectFilePath , string filePath )
36
33
{
37
34
try
38
35
{
39
36
var project = _projectSnapshotManagerAccessor . Instance . GetLoadedProject ( razorProjectKey ) ;
40
- if ( _fallbackProjectIds . Contains ( projectId ) )
37
+ if ( project is ProjectSnapshot { HostProject : FallbackHostProject } )
41
38
{
42
- // The project might have started as a fallback project, but it might have been upgraded by our getting CPS info
43
- // about it. In that case, leave the CPS bits to do the work
44
- if ( project is ProjectSnapshot { HostProject : FallbackHostProject } )
45
- {
46
- // If this is a fallback project, then Roslyn may not track documents in the project, so these dynamic file notifications
47
- // are the only way to know about files in the project.
48
- AddFallbackDocument ( razorProjectKey , filePath , projectFilePath ) ;
49
- }
39
+ // If this is a fallback project, then Roslyn may not track documents in the project, so these dynamic file notifications
40
+ // are the only way to know about files in the project.
41
+ AddFallbackDocument ( razorProjectKey , filePath , projectFilePath ) ;
50
42
}
51
43
else if ( project is null )
52
44
{
@@ -62,11 +54,12 @@ internal void DynamicFileAdded(ProjectId projectId, ProjectKey razorProjectKey,
62
54
}
63
55
}
64
56
65
- internal void DynamicFileRemoved ( ProjectId projectId , string projectFilePath , string filePath )
57
+ internal void DynamicFileRemoved ( ProjectId projectId , ProjectKey razorProjectKey , string projectFilePath , string filePath )
66
58
{
67
59
try
68
60
{
69
- if ( _fallbackProjectIds . Contains ( projectId ) )
61
+ var project = _projectSnapshotManagerAccessor . Instance . GetLoadedProject ( razorProjectKey ) ;
62
+ if ( project is ProjectSnapshot { HostProject : FallbackHostProject } )
70
63
{
71
64
// If this is a fallback project, then Roslyn may not track documents in the project, so these dynamic file notifications
72
65
// are the only way to know about files in the project.
@@ -93,11 +86,6 @@ private void AddFallbackProject(ProjectId projectId, string filePath)
93
86
return ;
94
87
}
95
88
96
- if ( ! ImmutableInterlocked . Update ( ref _fallbackProjectIds , ( set , id ) => set . Add ( id ) , project . Id ) )
97
- {
98
- return ;
99
- }
100
-
101
89
var rootNamespace = project . DefaultNamespace ;
102
90
103
91
// We create this as a fallback project so that other parts of the system can reason about them - eg we don't do code
@@ -182,21 +170,4 @@ private void RemoveFallbackDocument(ProjectId projectId, string filePath, string
182
170
183
171
return project ;
184
172
}
185
-
186
- internal TestAccessor GetTestAccessor ( )
187
- {
188
- return new TestAccessor ( this ) ;
189
- }
190
-
191
- internal readonly struct TestAccessor
192
- {
193
- private readonly FallbackProjectManager _instance ;
194
-
195
- internal TestAccessor ( FallbackProjectManager instance )
196
- {
197
- _instance = instance ;
198
- }
199
-
200
- internal ImmutableHashSet < ProjectId > ProjectIds => _instance . _fallbackProjectIds ;
201
- }
202
173
}
0 commit comments