diff --git a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md index 7b1942196b9..683c8dc0f5c 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/9.0.300.md @@ -15,5 +15,6 @@ * FSharpCheckFileResults.ProjectContext.ProjectOptions will not be available when using the experimental Transparent Compiler feature. ([PR #18205](https://github.com/dotnet/fsharp/pull/18205)) * Update `Obsolete` attribute checking to account for `DiagnosticId` and `UrlFormat` properties. ([PR #18224](https://github.com/dotnet/fsharp/pull/18224)) +* Remove `Cancellable.UsingToken` from tests ([PR #18276](https://github.com/dotnet/fsharp/pull/18276)) ### Breaking Changes diff --git a/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs b/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs index 62e36de58b9..981c4dda14b 100644 --- a/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/ModuleReaderCancellationTests.fs @@ -22,7 +22,6 @@ let mutable private wasCancelled = false let runCancelFirstTime f = let mutable requestCount = 0 fun () -> - use _ = Cancellable.UsingToken cts.Token if requestCount = 0 then cts.Cancel() @@ -150,12 +149,17 @@ let referenceReaderProject getPreTypeDefs (cancelOnModuleAccess: bool) (options: let parseAndCheck path source options = cts <- new CancellationTokenSource() wasCancelled <- false - use _ = Cancellable.UsingToken cts.Token try - match Async.RunSynchronously(checker.ParseAndCheckFileInProject(path, 0, SourceText.ofString source, options), cancellationToken = cts.Token) with - | fileResults, FSharpCheckFileAnswer.Aborted -> None - | fileResults, FSharpCheckFileAnswer.Succeeded results -> Some results + let checkFileAsync = checker.ParseAndCheckFileInProject(path, 0, SourceText.ofString source, options) + let result = + match Async.RunSynchronously(checkFileAsync, cancellationToken = cts.Token) with + | _, FSharpCheckFileAnswer.Aborted -> None + | _, FSharpCheckFileAnswer.Succeeded results -> Some results + + Cancellable.HasCancellationToken |> shouldEqual false + result + with :? OperationCanceledException -> wasCancelled <- true None