Skip to content

A handful of S.CL-related cleanups and reorgs from the OTel branch to minimize diffs #50164

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

baronfel
Copy link
Member

This slices off a few S.CL usability refactors off of #49409 to minimize the diff on that monstrosity.

This set of changes

  • leans into S.CL's Action pipeline for cross-cutting options that have behaviors attached to them
  • re-organizes Program.cs into sub-methods that have specific intents for easier reading
  • removes some unused S.CL extension methods
  • has a little bit of nullability-adoption that went along with that stuff

Copy link
Contributor

@Copilot 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 refactors the dotnet CLI to improve System.CommandLine (S.CL) usage patterns and code organization. The changes prepare the codebase for OpenTelemetry integration by removing performance measurement handling from the main command processing flow and adopting S.CL's Action pipeline for cross-cutting behaviors.

Key Changes:

  • Reorganizes Program.cs into focused sub-methods for better readability and maintainability
  • Adopts S.CL's Action pipeline for options like --version, --info, and --diagnostic that have behaviors attached
  • Removes performance measurement tracking from telemetry tests and command processing
  • Adopts nullable reference types across several files to improve type safety

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/dotnet.Tests/TelemetryCommandTest.cs Removes performance measurement testing and simplifies test assertions
src/Cli/dotnet/Telemetry/Telemetry.cs Adopts nullable reference types for telemetry properties and parameters
src/Cli/dotnet/Program.cs Major reorganization into focused methods with nullable adoption and Activity-based tracing
src/Cli/dotnet/PerformanceLogEventSource.cs Adopts nullable reference types for startup information parameters
src/Cli/dotnet/Parser.cs Implements S.CL Action classes for --version and --info options
src/Cli/dotnet/Extensions/ParseResultExtensions.cs Simplifies extension methods and removes unused functionality
src/Cli/dotnet/CommonOptionsFactory.cs Implements S.CL Action for diagnostic mode option
src/Cli/Microsoft.DotNet.Cli.Utils/Activities.cs Adds tracing constants for cross-process activity tracking

Comment on lines +20 to +31
/// <summary>
/// The environment variable used to transfer the chain of parent activity IDs.
/// This should be used when constructing new sub-processes in order to
/// track spans across calls.
/// </summary>
public const string TRACEPARENT = nameof(TRACEPARENT);
/// <summary>
/// The environment variable used to transfer the trace state of the parent activities.
/// This should be used when constructing new sub-processes in order to
/// track spans across calls.
/// </summary>
public const string TRACESTATE = nameof(TRACESTATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

TRACEPARENT and TRACESTATE are added in #50163 too. I'd prefer having them added in only one pull request.

Do you intend to insert any new entries into Activity.TraceStateString, or just pass it through unchanged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants