-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Filter cancellation exceptions in generator driver #58843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0918664
d7a7c30
79e0a5f
f1613ec
7b053c2
4b4cfe6
ab09881
7ba4bbf
1c33b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| using System.Collections.Generic; | ||
| using System.Collections.Immutable; | ||
| using System.Threading; | ||
| using Microsoft.CodeAnalysis.ErrorReporting; | ||
| using Roslyn.Utilities; | ||
|
|
||
| namespace Microsoft.CodeAnalysis | ||
| { | ||
|
|
@@ -30,9 +30,7 @@ internal static Func<TInput, CancellationToken, TOutput> WrapUserFunction<TInput | |
| { | ||
| return userFunction(input, token); | ||
| } | ||
| #pragma warning disable CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete; tracked by https://github.com/dotnet/roslyn/issues/58375 | ||
| catch (Exception e) when (FatalError.ReportIfNonFatalAndCatchUnlessCanceled(e, token)) | ||
| #pragma warning restore CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete | ||
| catch (Exception e) when (!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, token)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ Are we still going to get NFW reporting if/when these occur inside the IDE
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a separate change we're going to add an API to the GeneratorDriver to let us hook and report these, which is similar to how we do this for analyzers. Having this via an internal only API that's mixed in for fault reporting is a bit funky.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @chsienki Do we have a tracking bug to actually do that? |
||
| { | ||
| throw new UserFunctionException(e); | ||
| } | ||
|
|
@@ -44,34 +42,30 @@ internal static Func<TInput, CancellationToken, ImmutableArray<TOutput>> WrapUse | |
| return (input, token) => userFunction.WrapUserFunction()(input, token).ToImmutableArray(); | ||
| } | ||
|
|
||
| internal static Action<TInput> WrapUserAction<TInput>(this Action<TInput> userAction) | ||
| internal static Action<TInput, CancellationToken> WrapUserAction<TInput>(this Action<TInput> userAction) | ||
| { | ||
| return input => | ||
| return (input, token) => | ||
| { | ||
| try | ||
| { | ||
| userAction(input); | ||
| } | ||
| #pragma warning disable CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete; tracked by https://github.com/dotnet/roslyn/issues/58375 | ||
| catch (Exception e) when (FatalError.ReportIfNonFatalAndCatchUnlessCanceled(e)) | ||
| #pragma warning restore CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete | ||
| catch (Exception e) when (!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, token)) | ||
| { | ||
| throw new UserFunctionException(e); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| internal static Action<TInput1, TInput2> WrapUserAction<TInput1, TInput2>(this Action<TInput1, TInput2> userAction) | ||
| internal static Action<TInput1, TInput2, CancellationToken> WrapUserAction<TInput1, TInput2>(this Action<TInput1, TInput2> userAction) | ||
| { | ||
| return (input1, input2) => | ||
| return (input1, input2, token) => | ||
| { | ||
| try | ||
| { | ||
| userAction(input1, input2); | ||
| } | ||
| #pragma warning disable CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete; tracked by https://github.com/dotnet/roslyn/issues/58375 | ||
| catch (Exception e) when (FatalError.ReportIfNonFatalAndCatchUnlessCanceled(e)) | ||
| #pragma warning restore CS0618 // ReportIfNonFatalAndCatchUnlessCanceled is obsolete | ||
| catch (Exception e) when (!ExceptionUtilities.IsCurrentOperationBeingCancelled(e, token)) | ||
| { | ||
| throw new UserFunctionException(e); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.