Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<Uri>https://github.com/dotnet/roslyn</Uri>
<Sha>d7a4cad21c39e18f3d5e1f7fa7dd3f93668066b4</Sha>
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.22564.1">
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.23219.2">
Copy link
Member

Choose a reason for hiding this comment

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

We need to bump the version to be in sync with dotnet/sdk#33157

Suggested change
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.23219.2">
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.23307.1">

<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>350a618ab44932c568ae2392d7a571281baed59a</Sha>
<Sha>87704ce036fb23a4174b8290f249706aa35ab255</Sha>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Sha>87704ce036fb23a4174b8290f249706aa35ab255</Sha>
<Sha>02fe27cd6a9b001c8feb7938e6ef4b3799745759</Sha>

</Dependency>
<Dependency Name="System.CommandLine.Rendering" Version="0.4.0-alpha.22564.1">
<Dependency Name="System.CommandLine.Rendering" Version="0.4.0-alpha.23219.2">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Dependency Name="System.CommandLine.Rendering" Version="0.4.0-alpha.23219.2">
<Dependency Name="System.CommandLine.Rendering" Version="0.4.0-alpha.23307.1">

<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>350a618ab44932c568ae2392d7a571281baed59a</Sha>
<Sha>87704ce036fb23a4174b8290f249706aa35ab255</Sha>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<Sha>87704ce036fb23a4174b8290f249706aa35ab255</Sha>
<Sha>02fe27cd6a9b001c8feb7938e6ef4b3799745759</Sha>

</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</PropertyGroup>
<PropertyGroup>
<!-- command-line-api -->
<SystemCommandLineVersion>2.0.0-beta4.22564.1</SystemCommandLineVersion>
<SystemCommandLineRenderingVersion>0.4.0-alpha.22564.1</SystemCommandLineRenderingVersion>
<SystemCommandLineVersion>2.0.0-beta4.23219.2</SystemCommandLineVersion>
<SystemCommandLineRenderingVersion>0.4.0-alpha.23219.2</SystemCommandLineRenderingVersion>
Comment on lines +20 to +21
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<SystemCommandLineVersion>2.0.0-beta4.23219.2</SystemCommandLineVersion>
<SystemCommandLineRenderingVersion>0.4.0-alpha.23219.2</SystemCommandLineRenderingVersion>
<SystemCommandLineVersion>2.0.0-beta4.23307.1</SystemCommandLineVersion>
<SystemCommandLineRenderingVersion>0.4.0-alpha.23307.1</SystemCommandLineRenderingVersion>

<!-- corefx -->
<MicrosoftVisualBasicVersion>10.3.0</MicrosoftVisualBasicVersion>
<!-- msbuild -->
Expand Down
102 changes: 0 additions & 102 deletions src/CommandLineExtensions.cs

This file was deleted.

27 changes: 13 additions & 14 deletions src/Commands/FormatAnalyzersCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

using System.Collections.Immutable;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.CommandLine.Parsing;
using System.CommandLine.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using static Microsoft.CodeAnalysis.Tools.FormatCommandCommon;
Expand All @@ -14,52 +14,51 @@ internal static class FormatAnalyzersCommand
{
private static readonly FormatAnalyzersHandler s_analyzerHandler = new();

internal static Command GetCommand()
internal static CliCommand GetCommand()
{
var command = new Command("analyzers", Resources.Run_3rd_party_analyzers__and_apply_fixes)
var command = new CliCommand("analyzers", Resources.Run_3rd_party_analyzers__and_apply_fixes)
{
DiagnosticsOption,
ExcludeDiagnosticsOption,
SeverityOption,
};
command.AddCommonOptions();
command.Handler = s_analyzerHandler;
command.Action = s_analyzerHandler;
return command;
}

private class FormatAnalyzersHandler : ICommandHandler
private class FormatAnalyzersHandler : CliAction
{
public int Invoke(InvocationContext context) => InvokeAsync(context).GetAwaiter().GetResult();
public override int Invoke(ParseResult parseResult) => InvokeAsync(parseResult, CancellationToken.None).GetAwaiter().GetResult();

public async Task<int> InvokeAsync(InvocationContext context)
public override async Task<int> InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)
{
var parseResult = context.ParseResult;
var formatOptions = parseResult.ParseVerbosityOption(FormatOptions.Instance);
var logger = context.Console.SetupLogging(minimalLogLevel: formatOptions.LogLevel, minimalErrorLevel: LogLevel.Warning);
var logger = new SystemConsole().SetupLogging(minimalLogLevel: formatOptions.LogLevel, minimalErrorLevel: LogLevel.Warning);
formatOptions = parseResult.ParseCommonOptions(formatOptions, logger);
formatOptions = parseResult.ParseWorkspaceOptions(formatOptions);

if (parseResult.HasOption(SeverityOption) &&
if (parseResult.GetResult(SeverityOption) is not null &&
parseResult.GetValue(SeverityOption) is string { Length: > 0 } analyzerSeverity)
{
formatOptions = formatOptions with { AnalyzerSeverity = GetSeverity(analyzerSeverity) };
}

if (parseResult.HasOption(DiagnosticsOption) &&
if (parseResult.GetResult(DiagnosticsOption) is not null &&
parseResult.GetValue(DiagnosticsOption) is string[] { Length: > 0 } diagnostics)
{
formatOptions = formatOptions with { Diagnostics = diagnostics.ToImmutableHashSet() };
}

if (parseResult.HasOption(ExcludeDiagnosticsOption) &&
if (parseResult.GetResult(ExcludeDiagnosticsOption) is not null &&
parseResult.GetValue(ExcludeDiagnosticsOption) is string[] { Length: > 0 } excludeDiagnostics)
{
formatOptions = formatOptions with { ExcludeDiagnostics = excludeDiagnostics.ToImmutableHashSet() };
}

formatOptions = formatOptions with { FixCategory = FixCategory.Analyzers };

return await FormatAsync(formatOptions, logger, context.GetCancellationToken()).ConfigureAwait(false);
return await FormatAsync(formatOptions, logger, cancellationToken).ConfigureAwait(false);
}
}
}
Expand Down
Loading