Skip to content

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented May 27, 2025

APICompat was exiting at the first time it needed to go async.

This was because Commandline was treating the SetAction call as synchronous since it didn't accept a CancellationToken. Fix this and plumb basic cancellation.

I also noticed that the usage of Option was incorrect and corrected it to be consistent with the way we use in other tools.

APICompat was exiting at the first time it needed to go async.

This was because Commandline was treating the SetAction call as
synchronous since it didn't accept a CancellationToken.  Fix this and
plumb basic cancellation.

I also noticed that the usage of Option<T> was incorrect and corrected
it to be consistent with the way we use in other tools.
@ericstj ericstj requested review from ViktorHofer, Copilot and jozkee May 27, 2025 17:47
@ericstj ericstj requested a review from a team as a code owner May 27, 2025 17:47
rootCommand.Options.Add(optionAttachDebugger);

rootCommand.SetAction(async (ParseResult result) =>
rootCommand.SetAction(async (ParseResult result, CancellationToken cancellationToken) =>
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only functional fix here. The rest is cleanup after a5fe497

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the API diff tool’s async handling by plumbing a CancellationToken through the asynchronous call chain and correcting Option usage for consistency.

  • Updated RunAsync methods to accept a CancellationToken and added early cancellation checks
  • Improved Option initialization in command-line options to match other tools
  • Adjusted the root command’s SetAction signature to support cancellation token propagation

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Compatibility/ApiDiff/Microsoft.DotNet.ApiDiff/MemoryOutputDiffGenerator.cs Added CancellationToken parameter and inserted cancellation checks in loops
src/Compatibility/ApiDiff/Microsoft.DotNet.ApiDiff/IDiffGenerator.cs Updated interface to require a CancellationToken in RunAsync
src/Compatibility/ApiDiff/Microsoft.DotNet.ApiDiff/FileOutputDiffGenerator.cs Added cancellation checks and passed CancellationToken to inner RunAsync calls
src/Compatibility/ApiDiff/Microsoft.DotNet.ApiDiff.Tool/Program.cs Updated command line option definitions and SetAction callback to accept a CancellationToken

@ericstj ericstj merged commit 1dd8c27 into dotnet:main May 28, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants