@@ -111,8 +111,8 @@ type private SingleFileCacheEntry =
111111
112112module internal PEReferenceVersion =
113113
114- // Source generators come only from analyzer references. Which of those carry one is known to Roslyn's
115- // out-of-process host alone : asking here would load the generators into Visual Studio.
114+ // A source generator can turn an edit below the declaration level into other declarations. Only Roslyn's
115+ // out-of-process host knows which analyzer references carry one : asking here would load them into Visual Studio.
116116 let private mayRunSourceGenerators ( project : Project ) =
117117 let solution = project.Solution
118118
@@ -125,38 +125,33 @@ module internal PEReferenceVersion =
125125 || solution.GetProjectDependencyGraph() .GetProjectsThatThisProjectTransitivelyDependsOn( project.Id)
126126 |> Seq.exists hasAnalyzerReferences
127127
128- /// The version a referenced project's in-memory PE reference is kept for. A source generator can turn an
129- /// edit that leaves the dependent semantic version standing into different declarations.
130128 let getAsync ( referencedProject : Project ) ( ct : CancellationToken ) =
131129 if mayRunSourceGenerators referencedProject then
132130 referencedProject.GetDependentVersionAsync( ct)
133131 else
134132 referencedProject.GetDependentSemanticVersionAsync( ct)
135133
136134/// <summary >
137- /// The in-memory PE reference of a referenced project, kept while the project's
138- /// <c >PEReferenceVersion</c > is unchanged. Roslyn recreates
139- /// <see cref =" T:Microsoft.CodeAnalysis.Compilation " /> instances freely - on every solution fork,
140- /// and under memory pressure because it holds the final compilation weakly - and a reference
141- /// created per instance carries a fresh stamp that invalidates every FCS cache keyed on it.
135+ /// The in-memory PE reference of a referenced project, kept while its <c >PEReferenceVersion</c > is unchanged.
136+ /// Roslyn recreates a <see cref =" T:Microsoft.CodeAnalysis.Compilation " /> on every solution fork, and a reference per
137+ /// instance has a fresh stamp, which invalidates every FCS cache keyed on it.
142138/// </summary >
143139[<Sealed>]
144140type private PEReferenceCacheEntry ( version : VersionStamp , compilation : Compilation ) =
145- // Pinned until the first emit result, so the reader can always be materialised.
146- let mutable pinned = compilation
141+ let mutable pinnedUntilEmitted = compilation
147142 let latest = WeakReference< Compilation>( compilation)
148143
149144 member _.Version = version
150145
151146 member _.TryGetCompilation () =
152- match pinned with
147+ match pinnedUntilEmitted with
153148 | null ->
154149 match latest.TryGetTarget() with
155150 | true , compilation -> ValueSome compilation
156151 | _ -> ValueNone
157152 | pinned -> ValueSome pinned
158153
159- member _.Emitted () = pinned <- null
154+ member _.Emitted () = pinnedUntilEmitted <- null
160155
161156[<RequireQualifiedAccess>]
162157type private FSharpProjectOptionsMessage =
@@ -198,8 +193,7 @@ type private FSharpProjectOptionsReactor(checker: FSharpChecker) =
198193 let projectId = referencedProject.Id
199194 let mutable stamp = DateTime.UtcNow
200195
201- // Getting a C# reference assembly can fail if there are compilation errors that cannot be resolved.
202- // To mitigate this, we store the last successful compilation of a C# project and re-use it until we get a new successful compilation.
196+ // Emitting can fail on unresolvable compilation errors: fall back to the project's last successful compilation.
203197 let getStream =
204198 fun ct ->
205199 let tryStream ( comp : Compilation ) =
0 commit comments