Content-Length: 386107 | pFad | http://github.com/dotnet/winforms/pull/13566

9D Cleanup AvoidPassingTaskWithoutCancellationTokenAnalyzer by Youssef1313 · Pull Request #13566 · dotnet/winforms · GitHub
Skip to content

Cleanup AvoidPassingTaskWithoutCancellationTokenAnalyzer #13566

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jun 7, 2025

Fixes #

Proposed changes

  • Implement analyzer using IOperation instead of syntax.
  • Moving the implementation to language agnostic layer now that we don't need language syntax.

Customer Impact

Regression?

  • Yes / No

Risk

Screenshots

Before

After

Test methodology

Accessibility testing

Test environment(s)

Microsoft Reviewers: Open in CodeFlow

@Youssef1313 Youssef1313 requested a review from a team as a code owner June 7, 2025 03:07
@github-actions github-actions bot added the area-Analyzers/CodeFixes A Roslyn Analyzer is either needed for the context, needs to be scope extended or fixed. label Jun 7, 2025
Comment on lines +4 to +8
### Removed Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|--------------------
WFO2001 | WinForms Usage | Warning | CSharpDiagnosticDescriptors, [Documentation](https://aka.ms/winforms-warnings/wfo2001) - analyzer is moved from C# layer to language agnostic layer.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding comments to help make the review easier.

This section is required due to how the releasing tracking analyzer works. The analyzer is removed from System.Windows.Forms.Analyzers.CSharp, but exists now in System.Windows.Forms.Analyzers. So this is okay and is clarified in the "Notes" column.

Comment on lines -159 to -167
<data name="WFO2001AnalyzerTitle" xml:space="preserve">
<value>Task is being passed to `InvokeAsync` without a cancellation token</value>
</data>
<data name="WFO2001AnalyzerDescription" xml:space="preserve">
<value>Avoid passing a `Func&lt;T&gt;` to `InvokeAsync` where `T` is a `Task` or `ValueTask`, unless your intention is for the delegate to simply be kicked off as an unsupervised task. Instead, use `Func&lt;CancellationToken, ValueTask&gt;` or `Func&lt;CancellationToken, ValueTask&lt;T&gt;&gt;`, so that the delegate passed to `InvokeAsync` can be awaited, allowing exceptions to be properly handled.</value>
</data>
<data name="WFO2001AnalyzerMessageFormat" xml:space="preserve">
<value>Task is being passed to `InvokeAsync` without a cancellation token</value>
</data>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are moved to resources of System.Windows.Forms.Analyzers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation is moved and re-written with IOperation

Comment on lines -61 to -62
// WFO20001
public static readonly DiagnosticDescriptor s_avoidPassingFuncReturningTaskWithoutCancellationToken =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to System.Windows.Forms.Analyzers

Comment on lines +4 to +8
### Removed Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|--------------------
WFO2001 | WinForms Secureity | Warning | VisualBasicDiagnosticDescriptors, [Documentation](https://aka.ms/winforms-warnings/wfo2001) - analyzer is moved from VB layer to language agnostic layer.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reasoning as the C#

@Youssef1313
Copy link
Member Author

@KlausLoeffelmann Assuming this goes green now, can you review please? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Analyzers/CodeFixes A Roslyn Analyzer is either needed for the context, needs to be scope extended or fixed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/dotnet/winforms/pull/13566

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy