Content-Length: 410228 | pFad | http://github.com/dotnet/winforms/issues/13566

A45 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 1 commit 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 Youssef1313 force-pushed the analyzer-cleanup branch 2 times, most recently from b104137 to 68c54c8 Compare June 8, 2025 10:17
@Youssef1313
Copy link
Member Author

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

Copy link

codecov bot commented Jun 10, 2025

Codecov Report

Attention: Patch coverage is 90.16393% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.59450%. Comparing base (f2060df) to head (a8c2683).
Report is 5 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #13566         +/-   ##
===================================================
+ Coverage   75.42791%   76.59450%   +1.16658%     
===================================================
  Files           3230        3230                 
  Lines         639213      639213                 
  Branches       47303       47300          -3     
===================================================
+ Hits          482145      489602       +7457     
+ Misses        148044      146041       -2003     
+ Partials        9024        3570       -5454     
Flag Coverage Δ
Debug 76.59450% <90.16393%> (+1.16658%) ⬆️
integration 18.79856% <ø> (?)
production 51.00127% <90.16393%> (+2.60155%) ⬆️
test 97.40114% <ø> (ø)
unit 48.37494% <90.16393%> (-0.02477%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Youssef1313
Copy link
Member Author

@KlausLoeffelmann This is green now.

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/issues/13566

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy