Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd12aad7

Browse files
dsymeKevinRansom
authored andcommitted
fix 3171 (#3182)
1 parent36a3f0f commitd12aad7

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

‎vsintegration/src/FSharp.Editor/Common/RoslynHelpers.fs‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ module internal RoslynHelpers =
9292
member__.Proceed=not isStopped
9393
member__.Stop()= isStopped<-true
9494

95-
// This is like Async.StartAsTask, but if cancellation occurs we explicitly associate the cancellation with cancellationToken
95+
// This is like Async.StartAsTask, but
96+
// 1. if cancellation occurs we explicitly associate the cancellation with cancellationToken
97+
// 2. if exception occurs then set result to Unchecked.defaultof<_>, i.e. swallow exceptions
98+
// and hope that Roslyn copes with the null
9699
letStartAsyncAsTask(cancellationToken:CancellationToken)computation=
97100
lettcs=new TaskCompletionSource<_>(TaskCreationOptions.None)
98101
letbarrier= VolatileBarrier()
@@ -102,10 +105,24 @@ module internal RoslynHelpers =
102105
Async.StartWithContinuations(
103106
async{do! Async.SwitchToThreadPool()
104107
return! computation},
105-
continuation=(fun result-> disposeReg(); tcs.TrySetResult(result)|> ignore),
106-
exceptionContinuation=(function:? OperationCanceledException-> disposeReg(); tcs.TrySetCanceled(cancellationToken)|> ignore
107-
| exn-> disposeReg(); tcs.TrySetException(exn)|> ignore),
108-
cancellationContinuation=(fun _oce-> disposeReg(); tcs.TrySetCanceled(cancellationToken)|> ignore),
108+
continuation=(fun result->
109+
disposeReg()
110+
tcs.TrySetResult(result)|> ignore
111+
),
112+
exceptionContinuation=(fun exn->
113+
disposeReg()
114+
match exnwith
115+
|:? OperationCanceledException->
116+
tcs.TrySetCanceled(cancellationToken)|> ignore
117+
| exn->
118+
System.Diagnostics.Trace.WriteLine("Visual F# Tools: exception swallowed and not passed to Roslyn: {0}", exn.Message)
119+
letres= Unchecked.defaultof<_>
120+
tcs.TrySetResult(res)|> ignore
121+
),
122+
cancellationContinuation=(fun _oce->
123+
disposeReg()
124+
tcs.TrySetCanceled(cancellationToken)|> ignore
125+
),
109126
cancellationToken=cancellationToken)
110127
task
111128

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp