Skip to content

Commit 1f9b0ce

Browse files
Cancellable: remove UsingToken usages in tests (#18276)
* Remove Cancellable.UsingToken from tests The token is now always set inside the cancellable computation * Release notes --------- Co-authored-by: Kevin Ransom (msft) <[email protected]>
1 parent bacc160 commit 1f9b0ce

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.300.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515

1616
* FSharpCheckFileResults.ProjectContext.ProjectOptions will not be available when using the experimental Transparent Compiler feature. ([PR #18205](https://github.com/dotnet/fsharp/pull/18205))
1717
* Update `Obsolete` attribute checking to account for `DiagnosticId` and `UrlFormat` properties. ([PR #18224](https://github.com/dotnet/fsharp/pull/18224))
18+
* Remove `Cancellable.UsingToken` from tests ([PR #18276](https://github.com/dotnet/fsharp/pull/18276))
1819

1920
### Breaking Changes

tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ let mutable private wasCancelled = false
2222
let runCancelFirstTime f =
2323
let mutable requestCount = 0
2424
fun () ->
25-
use _ = Cancellable.UsingToken cts.Token
2625
if requestCount = 0 then
2726
cts.Cancel()
2827

@@ -150,12 +149,17 @@ let referenceReaderProject getPreTypeDefs (cancelOnModuleAccess: bool) (options:
150149
let parseAndCheck path source options =
151150
cts <- new CancellationTokenSource()
152151
wasCancelled <- false
153-
use _ = Cancellable.UsingToken cts.Token
154152

155153
try
156-
match Async.RunSynchronously(checker.ParseAndCheckFileInProject(path, 0, SourceText.ofString source, options), cancellationToken = cts.Token) with
157-
| fileResults, FSharpCheckFileAnswer.Aborted -> None
158-
| fileResults, FSharpCheckFileAnswer.Succeeded results -> Some results
154+
let checkFileAsync = checker.ParseAndCheckFileInProject(path, 0, SourceText.ofString source, options)
155+
let result =
156+
match Async.RunSynchronously(checkFileAsync, cancellationToken = cts.Token) with
157+
| _, FSharpCheckFileAnswer.Aborted -> None
158+
| _, FSharpCheckFileAnswer.Succeeded results -> Some results
159+
160+
Cancellable.HasCancellationToken |> shouldEqual false
161+
result
162+
159163
with :? OperationCanceledException ->
160164
wasCancelled <- true
161165
None

0 commit comments

Comments
 (0)