Skip to content

Commit

Permalink
Merge pull request #11228 from TIHan/analysis-fix
Browse files Browse the repository at this point in the history
Remove re-analysis check for non-scripts in VS - Fixed a cross-project reference regression
  • Loading branch information
dsyme authored Mar 24, 2021
2 parents 3a4aa51 + 48cfe41 commit 36b286b
Show file tree
Hide file tree
Showing 48 changed files with 348 additions and 316 deletions.
25 changes: 12 additions & 13 deletions src/fsharp/service/IncrementalBuild.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,14 @@ type IncrementalBuilder(tcGlobals,
return { state with finalizedBoundModel = Some result }, result
}

let tryGetSlot (state: IncrementalBuilderState) slot =
match state.boundModels.[slot] with
| Some boundModel ->
(boundModel, state.stampedFileNames.[slot])
|> Some
| _ ->
None

let tryGetBeforeSlot (state: IncrementalBuilderState) slot =
match slot with
| 0 (* first file *) ->
Expand All @@ -1089,12 +1097,7 @@ type IncrementalBuilder(tcGlobals,
| _ ->
None
| _ ->
match state.boundModels.[slot - 1] with
| Some boundModel ->
(boundModel, state.stampedFileNames.[slot - 1])
|> Some
| _ ->
None
tryGetSlot state (slot - 1)

let evalUpToTargetSlot state (cache: TimeStampCache) ctok targetSlot =
cancellable {
Expand Down Expand Up @@ -1192,13 +1195,6 @@ type IncrementalBuilder(tcGlobals,
match result with
| Some (boundModel, timestamp) -> Some (PartialCheckResults (boundModel, timestamp))
| _ -> None


member builder.AreCheckResultsBeforeFileInProjectReady filename =
let slotOfFile = builder.GetSlotOfFileName filename
match tryGetBeforeSlot currentState slotOfFile with
| Some _ -> true
| _ -> false

member builder.TryGetCheckResultsBeforeFileInProject (filename) =
let cache = TimeStampCache defaultTimeStamp
Expand All @@ -1211,6 +1207,9 @@ type IncrementalBuilder(tcGlobals,
| Some(boundModel, timestamp) -> PartialCheckResults(boundModel, timestamp) |> Some
| _ -> None

member builder.AreCheckResultsBeforeFileInProjectReady filename =
(builder.TryGetCheckResultsBeforeFileInProject filename).IsSome

member private _.GetCheckResultsBeforeSlotInProject (ctok: CompilationThreadToken, slotOfFile, enablePartialTypeChecking) =
cancellable {
let cache = TimeStampCache defaultTimeStamp
Expand Down
21 changes: 13 additions & 8 deletions src/fsharp/service/Reactor.fs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Reactor() =
// so that when the reactor picks up a thread from the thread pool we can set the culture
let mutable culture = CultureInfo(CultureInfo.CurrentUICulture.Name)

let gate = obj()
let mutable bgOpCts = new CancellationTokenSource()

let sw = new System.Diagnostics.Stopwatch()
Expand Down Expand Up @@ -86,9 +87,11 @@ type Reactor() =
match bgOpOpt with
| None -> None
| Some (bgUserOpName, bgOpName, bgOpArg, bgOp) ->
let oldBgOpCts = bgOpCts
bgOpCts <- new CancellationTokenSource()
oldBgOpCts.Dispose()
lock gate (fun () ->
let oldBgOpCts = bgOpCts
bgOpCts <- new CancellationTokenSource()
oldBgOpCts.Dispose()
)
Some (bgUserOpName, bgOpName, bgOpArg, bgOp ctok)

//Trace.TraceInformation("Reactor: --> set background op, remaining {0}", inbox.CurrentQueueLength)
Expand All @@ -113,9 +116,11 @@ type Reactor() =
| None -> ()
| Some (bgUserOpName, bgOpName, bgOpArg, bgOp) ->
Trace.TraceInformation("Reactor: {0:n3} --> wait for background {1}.{2} ({3}), remaining {4}", DateTime.Now.TimeOfDay.TotalSeconds, bgUserOpName, bgOpName, bgOpArg, inbox.CurrentQueueLength)
let oldBgOpCts = bgOpCts
bgOpCts <- new CancellationTokenSource()
oldBgOpCts.Dispose()
lock gate (fun () ->
let oldBgOpCts = bgOpCts
bgOpCts <- new CancellationTokenSource()
oldBgOpCts.Dispose()
)

try
Eventually.force bgOpCts.Token bgOp |> ignore
Expand Down Expand Up @@ -179,12 +184,12 @@ type Reactor() =
// [Foreground Mailbox Accessors] -----------------------------------------------------------
member _.SetBackgroundOp(bgOpOpt) =
Trace.TraceInformation("Reactor: {0:n3} enqueue start background, length {1}", DateTime.Now.TimeOfDay.TotalSeconds, builder.CurrentQueueLength)
bgOpCts.Cancel()
lock gate (fun () -> bgOpCts.Cancel())
builder.Post(SetBackgroundOp bgOpOpt)

member _.CancelBackgroundOp() =
Trace.TraceInformation("FCS: trying to cancel any active background work")
bgOpCts.Cancel()
lock gate (fun () -> bgOpCts.Cancel())

member _.EnqueueOp(userOpName, opName, opArg, op) =
Trace.TraceInformation("Reactor: {0:n3} enqueue {1}.{2} ({3}), length {4}", DateTime.Now.TimeOfDay.TotalSeconds, userOpName, opName, opArg, builder.CurrentQueueLength)
Expand Down
Loading

0 comments on commit 36b286b

Please sign in to comment.