This commit is contained in:
Tyrrrz
2021-12-08 23:43:35 +02:00
parent 9990387cfa
commit 2feeb21270
132 changed files with 8021 additions and 8154 deletions

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class CommandMustBeAnnotatedAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new CommandMustBeAnnotatedAnalyzer();
@@ -69,4 +69,3 @@ public class Foo
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class CommandMustImplementInterfaceAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new CommandMustImplementInterfaceAnalyzer();
@@ -55,4 +55,3 @@ public class Foo
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -4,8 +4,8 @@ using FluentAssertions;
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class GeneralSpecs
{
[Fact]
@@ -28,4 +28,3 @@ namespace CliFx.Analyzers.Tests
diagnosticIds.Should().OnlyHaveUniqueItems();
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustBeInsideCommandAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustBeInsideCommandAnalyzer();
@@ -77,4 +77,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveNameOrShortNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveNameOrShortNameAnalyzer();
@@ -83,4 +83,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveUniqueNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveUniqueNameAnalyzer();
@@ -89,4 +89,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveUniqueShortNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveUniqueShortNameAnalyzer();
@@ -111,4 +111,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveValidConverterAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveValidConverterAnalyzer();
@@ -93,4 +93,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveValidNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveValidNameAnalyzer();
@@ -102,4 +102,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveValidShortNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveValidShortNameAnalyzer();
@@ -83,4 +83,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class OptionMustHaveValidValidatorsAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new OptionMustHaveValidValidatorsAnalyzer();
@@ -93,4 +93,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustBeInsideCommandAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustBeInsideCommandAnalyzer();
@@ -77,4 +77,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustBeLastIfNonScalarAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustBeLastIfNonScalarAnalyzer();
@@ -92,4 +92,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustBeSingleIfNonScalarAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustBeSingleIfNonScalarAnalyzer();
@@ -92,4 +92,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustHaveUniqueNameAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustHaveUniqueNameAnalyzer();
@@ -70,4 +70,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustHaveUniqueOrderAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustHaveUniqueOrderAnalyzer();
@@ -70,4 +70,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustHaveValidConverterAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustHaveValidConverterAnalyzer();
@@ -93,4 +93,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class ParameterMustHaveValidValidatorsAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new ParameterMustHaveValidValidatorsAnalyzer();
@@ -93,4 +93,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -2,8 +2,8 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Xunit;
namespace CliFx.Analyzers.Tests
{
namespace CliFx.Analyzers.Tests;
public class SystemConsoleShouldBeAvoidedAnalyzerSpecs
{
private static DiagnosticAnalyzer Analyzer { get; } = new SystemConsoleShouldBeAvoidedAnalyzer();
@@ -124,4 +124,3 @@ public class MyCommand : ICommand
Analyzer.Should().NotProduceDiagnostics(code);
}
}
}

View File

@@ -11,8 +11,8 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
namespace CliFx.Analyzers.Tests.Utils
{
namespace CliFx.Analyzers.Tests.Utils;
internal class AnalyzerAssertions : ReferenceTypeAssertions<DiagnosticAnalyzer, AnalyzerAssertions>
{
protected override string Identifier { get; } = "analyzer";
@@ -165,4 +165,3 @@ namespace CliFx.Analyzers.Tests.Utils
{
public static AnalyzerAssertions Should(this DiagnosticAnalyzer analyzer) => new(analyzer);
}
}

View File

@@ -3,8 +3,8 @@ using CliFx.Analyzers.Utils.Extensions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
public abstract class AnalyzerBase : DiagnosticAnalyzer
{
public DiagnosticDescriptor SupportedDiagnostic { get; }
@@ -37,4 +37,3 @@ namespace CliFx.Analyzers
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class CommandMustBeAnnotatedAnalyzer : AnalyzerBase
{
@@ -51,4 +51,3 @@ namespace CliFx.Analyzers
context.HandleClassDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class CommandMustImplementInterfaceAnalyzer : AnalyzerBase
{
@@ -45,4 +45,3 @@ namespace CliFx.Analyzers
context.HandleClassDeclaration(Analyze);
}
}
}

View File

@@ -3,8 +3,8 @@ using Microsoft.CodeAnalysis;
using System.Linq;
using CliFx.Analyzers.Utils.Extensions;
namespace CliFx.Analyzers.ObjectModel
{
namespace CliFx.Analyzers.ObjectModel;
internal partial class CommandOptionSymbol
{
public string? Name { get; }
@@ -80,4 +80,3 @@ namespace CliFx.Analyzers.ObjectModel
public static bool IsOptionProperty(IPropertySymbol property) =>
TryGetOptionAttribute(property) is not null;
}
}

View File

@@ -3,8 +3,8 @@ using System.Linq;
using CliFx.Analyzers.Utils.Extensions;
using Microsoft.CodeAnalysis;
namespace CliFx.Analyzers.ObjectModel
{
namespace CliFx.Analyzers.ObjectModel;
internal partial class CommandParameterSymbol
{
public int Order { get; }
@@ -79,4 +79,3 @@ namespace CliFx.Analyzers.ObjectModel
public static bool IsParameterProperty(IPropertySymbol property) =>
TryGetParameterAttribute(property) is not null;
}
}

View File

@@ -1,5 +1,5 @@
namespace CliFx.Analyzers.ObjectModel
{
namespace CliFx.Analyzers.ObjectModel;
internal static class SymbolNames
{
public const string CliFxCommandInterface = "CliFx.ICommand";
@@ -12,4 +12,3 @@
public const string CliFxBindingValidatorInterface = "CliFx.Extensibility.IBindingValidator";
public const string CliFxBindingValidatorClass = "CliFx.Extensibility.BindingValidator<T>";
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustBeInsideCommandAnalyzer : AnalyzerBase
{
@@ -48,4 +48,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveNameOrShortNameAnalyzer : AnalyzerBase
{
@@ -37,4 +37,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -6,8 +6,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveUniqueNameAnalyzer : AnalyzerBase
{
@@ -62,4 +62,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveUniqueShortNameAnalyzer : AnalyzerBase
{
@@ -61,4 +61,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveValidConverterAnalyzer : AnalyzerBase
{
@@ -47,4 +47,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveValidNameAnalyzer : AnalyzerBase
{
@@ -40,4 +40,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveValidShortNameAnalyzer : AnalyzerBase
{
@@ -40,4 +40,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class OptionMustHaveValidValidatorsAnalyzer : AnalyzerBase
{
@@ -49,4 +49,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustBeInsideCommandAnalyzer : AnalyzerBase
{
@@ -48,4 +48,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustBeLastIfNonScalarAnalyzer : AnalyzerBase
{
@@ -65,4 +65,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustBeSingleIfNonScalarAnalyzer : AnalyzerBase
{
@@ -63,4 +63,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -6,8 +6,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustHaveUniqueNameAnalyzer : AnalyzerBase
{
@@ -62,4 +62,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustHaveUniqueOrderAnalyzer : AnalyzerBase
{
@@ -55,4 +55,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustHaveValidConverterAnalyzer : AnalyzerBase
{
@@ -47,4 +47,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -5,8 +5,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class ParameterMustHaveValidValidatorsAnalyzer : AnalyzerBase
{
@@ -49,4 +49,3 @@ namespace CliFx.Analyzers
context.HandlePropertyDeclaration(Analyze);
}
}
}

View File

@@ -6,8 +6,8 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers
{
namespace CliFx.Analyzers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class SystemConsoleShouldBeAvoidedAnalyzer : AnalyzerBase
{
@@ -75,4 +75,3 @@ namespace CliFx.Analyzers
context.RegisterSyntaxNodeAction(Analyze, SyntaxKind.SimpleMemberAccessExpression);
}
}
}

View File

@@ -4,8 +4,8 @@ using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
namespace CliFx.Analyzers.Utils.Extensions
{
namespace CliFx.Analyzers.Utils.Extensions;
internal static class RoslynExtensions
{
public static bool DisplayNameMatches(this ISymbol symbol, string name) =>
@@ -50,4 +50,3 @@ namespace CliFx.Analyzers.Utils.Extensions
}, SyntaxKind.PropertyDeclaration);
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Analyzers.Utils.Extensions
{
namespace CliFx.Analyzers.Utils.Extensions;
internal static class StringExtensions
{
public static string TrimEnd(
@@ -15,4 +15,3 @@ namespace CliFx.Analyzers.Utils.Extensions
return str;
}
}
}

View File

@@ -4,8 +4,8 @@ using BenchmarkDotNet.Attributes;
using CliFx.Attributes;
using CliFx.Infrastructure;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
[Command]
@@ -30,4 +30,3 @@ namespace CliFx.Benchmarks
.Build()
.RunAsync(Arguments, new Dictionary<string, string>());
}
}

View File

@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using clipr;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class CliprCommand
@@ -24,4 +24,3 @@ namespace CliFx.Benchmarks
[Benchmark(Description = "Clipr")]
public void ExecuteWithClipr() => CliParser.Parse<CliprCommand>(Arguments).Execute();
}
}

View File

@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using Cocona;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class CoconaCommand
@@ -21,4 +21,3 @@ namespace CliFx.Benchmarks
[Benchmark(Description = "Cocona")]
public void ExecuteWithCocona() => CoconaApp.Run<CoconaCommand>(Arguments);
}
}

View File

@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using CommandLine;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class CommandLineParserCommand
@@ -27,4 +27,3 @@ namespace CliFx.Benchmarks
.ParseArguments(Arguments, typeof(CommandLineParserCommand))
.WithParsed<CommandLineParserCommand>(c => c.Execute());
}
}

View File

@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using McMaster.Extensions.CommandLineUtils;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class McMasterCommand
@@ -22,4 +22,3 @@ namespace CliFx.Benchmarks
[Benchmark(Description = "McMaster.Extensions.CommandLineUtils")]
public int ExecuteWithMcMaster() => CommandLineApplication.Execute<McMasterCommand>(Arguments);
}
}

View File

@@ -1,8 +1,8 @@
using BenchmarkDotNet.Attributes;
using PowerArgs;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class PowerArgsCommand
@@ -24,4 +24,3 @@ namespace CliFx.Benchmarks
[Benchmark(Description = "PowerArgs")]
public void ExecuteWithPowerArgs() => Args.InvokeMain<PowerArgsCommand>(Arguments);
}
}

View File

@@ -3,8 +3,8 @@ using System.CommandLine.Invocation;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
public partial class Benchmarks
{
public class SystemCommandLineCommand
@@ -41,4 +41,3 @@ namespace CliFx.Benchmarks
public async Task<int> ExecuteWithSystemCommandLine() =>
await new SystemCommandLineCommand().ExecuteAsync(Arguments);
}
}

View File

@@ -3,8 +3,8 @@ using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Order;
using BenchmarkDotNet.Running;
namespace CliFx.Benchmarks
{
namespace CliFx.Benchmarks;
[RankColumn]
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
public partial class Benchmarks
@@ -17,4 +17,3 @@ namespace CliFx.Benchmarks
.WithOptions(ConfigOptions.DisableOptimizationsValidator)
);
}
}

View File

@@ -6,8 +6,8 @@ using CliFx.Demo.Utils;
using CliFx.Exceptions;
using CliFx.Infrastructure;
namespace CliFx.Demo.Commands
{
namespace CliFx.Demo.Commands;
[Command("book add", Description = "Add a book to the library.")]
public partial class BookAddCommand : ICommand
{
@@ -67,4 +67,3 @@ namespace CliFx.Demo.Commands
Random.Next(0, 9)
);
}
}

View File

@@ -5,8 +5,8 @@ using CliFx.Demo.Utils;
using CliFx.Exceptions;
using CliFx.Infrastructure;
namespace CliFx.Demo.Commands
{
namespace CliFx.Demo.Commands;
[Command("book", Description = "Retrieve a book from the library.")]
public class BookCommand : ICommand
{
@@ -32,4 +32,3 @@ namespace CliFx.Demo.Commands
return default;
}
}
}

View File

@@ -4,8 +4,8 @@ using CliFx.Demo.Domain;
using CliFx.Demo.Utils;
using CliFx.Infrastructure;
namespace CliFx.Demo.Commands
{
namespace CliFx.Demo.Commands;
[Command("book list", Description = "List all books in the library.")]
public class BookListCommand : ICommand
{
@@ -34,4 +34,3 @@ namespace CliFx.Demo.Commands
return default;
}
}
}

View File

@@ -4,8 +4,8 @@ using CliFx.Demo.Domain;
using CliFx.Exceptions;
using CliFx.Infrastructure;
namespace CliFx.Demo.Commands
{
namespace CliFx.Demo.Commands;
[Command("book remove", Description = "Remove a book from the library.")]
public class BookRemoveCommand : ICommand
{
@@ -33,4 +33,3 @@ namespace CliFx.Demo.Commands
return default;
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Demo.Domain
{
namespace CliFx.Demo.Domain;
public class Book
{
public string Title { get; }
@@ -20,4 +20,3 @@ namespace CliFx.Demo.Domain
Isbn = isbn;
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Demo.Domain
{
namespace CliFx.Demo.Domain;
public partial class Isbn
{
public int EanPrefix { get; }
@@ -42,4 +42,3 @@ namespace CliFx.Demo.Domain
);
}
}
}

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;
namespace CliFx.Demo.Domain
{
namespace CliFx.Demo.Domain;
public partial class Library
{
public IReadOnlyList<Book> Books { get; }
@@ -33,4 +33,3 @@ namespace CliFx.Demo.Domain
{
public static Library Empty { get; } = new(Array.Empty<Book>());
}
}

View File

@@ -2,8 +2,8 @@
using System.Linq;
using Newtonsoft.Json;
namespace CliFx.Demo.Domain
{
namespace CliFx.Demo.Domain;
public class LibraryProvider
{
private static string StorageFilePath { get; } = Path.Combine(Directory.GetCurrentDirectory(), "Library.json");
@@ -38,4 +38,3 @@ namespace CliFx.Demo.Domain
StoreLibrary(updatedLibrary);
}
}
}

View File

@@ -4,8 +4,8 @@ using CliFx.Demo.Commands;
using CliFx.Demo.Domain;
using Microsoft.Extensions.DependencyInjection;
namespace CliFx.Demo
{
namespace CliFx.Demo;
public static class Program
{
private static IServiceProvider GetServiceProvider()
@@ -33,4 +33,3 @@ namespace CliFx.Demo
.Build()
.RunAsync();
}
}

View File

@@ -2,8 +2,8 @@
using CliFx.Demo.Domain;
using CliFx.Infrastructure;
namespace CliFx.Demo.Utils
{
namespace CliFx.Demo.Utils;
internal static class ConsoleExtensions
{
public static void WriteBook(this ConsoleWriter writer, Book book)
@@ -34,4 +34,3 @@ namespace CliFx.Demo.Utils
writer.WriteLine(book.Isbn);
}
}
}

View File

@@ -3,8 +3,8 @@ using System.Threading.Tasks;
using CliFx.Attributes;
using CliFx.Infrastructure;
namespace CliFx.Tests.Dummy.Commands
{
namespace CliFx.Tests.Dummy.Commands;
[Command("console-test")]
public class ConsoleTestCommand : ICommand
{
@@ -21,4 +21,3 @@ namespace CliFx.Tests.Dummy.Commands
return default;
}
}
}

View File

@@ -2,8 +2,8 @@
using CliFx.Attributes;
using CliFx.Infrastructure;
namespace CliFx.Tests.Dummy.Commands
{
namespace CliFx.Tests.Dummy.Commands;
[Command("env-test")]
public class EnvironmentTestCommand : ICommand
{
@@ -17,4 +17,3 @@ namespace CliFx.Tests.Dummy.Commands
return default;
}
}
}

View File

@@ -1,8 +1,7 @@
using System.Reflection;
using System.Threading.Tasks;
namespace CliFx.Tests.Dummy
{
namespace CliFx.Tests.Dummy;
// This dummy application is used in tests for scenarios
// that require an external process to properly verify.
@@ -21,4 +20,3 @@ namespace CliFx.Tests.Dummy
.Build()
.RunAsync();
}
}

View File

@@ -6,8 +6,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class ApplicationSpecs : SpecsBase
{
public ApplicationSpecs(ITestOutputHelper testOutput)
@@ -83,4 +83,3 @@ namespace CliFx.Tests
stdErr.Should().Contain("not a valid command");
}
}
}

View File

@@ -6,8 +6,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class CancellationSpecs : SpecsBase
{
public CancellationSpecs(ITestOutputHelper testOutput)
@@ -64,4 +64,3 @@ public class Command : ICommand
stdOut.Trim().Should().Be("Cancelled");
}
}
}

View File

@@ -11,8 +11,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class ConsoleSpecs : SpecsBase
{
public ConsoleSpecs(ITestOutputHelper testOutput)
@@ -156,4 +156,3 @@ public class Command : ICommand
output.Should().Be("Hello world");
}
}
}

View File

@@ -6,8 +6,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class ConversionSpecs : SpecsBase
{
public ConversionSpecs(ITestOutputHelper testOutput)
@@ -990,4 +990,3 @@ public class Command : ICommand
stdErr.Should().Contain("Hello world");
}
}
}

View File

@@ -10,8 +10,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class DirectivesSpecs : SpecsBase
{
public DirectivesSpecs(ITestOutputHelper testOutput)
@@ -109,4 +109,3 @@ public class Command : ICommand
);
}
}
}

View File

@@ -10,8 +10,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class EnvironmentSpecs : SpecsBase
{
public EnvironmentSpecs(ITestOutputHelper testOutput)
@@ -257,4 +257,3 @@ public class Command : ICommand
result.StandardOutput.Trim().Should().Be("Hello Mars!");
}
}
}

View File

@@ -7,8 +7,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class ErrorReportingSpecs : SpecsBase
{
public ErrorReportingSpecs(ITestOutputHelper testOutput)
@@ -202,4 +202,3 @@ public class Command : ICommand
stdErr.Trim().Should().Be("Something went wrong");
}
}
}

View File

@@ -7,8 +7,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class HelpTextSpecs : SpecsBase
{
public HelpTextSpecs(ITestOutputHelper testOutput)
@@ -965,4 +965,3 @@ public class SecondCommandSecondChildCommand : ICommand
stdOut.Trim().Should().Be("v6.9");
}
}
}

View File

@@ -7,8 +7,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class OptionBindingSpecs : SpecsBase
{
public OptionBindingSpecs(ITestOutputHelper testOutput)
@@ -705,4 +705,3 @@ public class Command : ICommand
stdErr.Should().Contain("expects a single argument, but provided with multiple");
}
}
}

View File

@@ -6,8 +6,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class ParameterBindingSpecs : SpecsBase
{
public ParameterBindingSpecs(ITestOutputHelper testOutput)
@@ -230,4 +230,3 @@ public class Command : ICommand
stdErr.Should().Contain("Unexpected parameter(s)");
}
}
}

View File

@@ -6,8 +6,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class RoutingSpecs : SpecsBase
{
public RoutingSpecs(ITestOutputHelper testOutput)
@@ -183,4 +183,3 @@ public class NamedChildCommand : ICommand
stdOut.Trim().Should().Be("cmd child");
}
}
}

View File

@@ -3,8 +3,8 @@ using CliFx.Infrastructure;
using CliFx.Tests.Utils.Extensions;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public abstract class SpecsBase : IDisposable
{
public ITestOutputHelper TestOutput { get; }
@@ -20,4 +20,3 @@ namespace CliFx.Tests
FakeConsole.Dispose();
}
}
}

View File

@@ -7,8 +7,8 @@ using FluentAssertions;
using Xunit;
using Xunit.Abstractions;
namespace CliFx.Tests
{
namespace CliFx.Tests;
public class TypeActivationSpecs : SpecsBase
{
public TypeActivationSpecs(ITestOutputHelper testOutput)
@@ -162,4 +162,3 @@ public class Command : ICommand
stdErr.Should().Contain("Failed to create an instance of type");
}
}
}

View File

@@ -8,8 +8,8 @@ using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.Text;
namespace CliFx.Tests.Utils
{
namespace CliFx.Tests.Utils;
// This class uses Roslyn to compile commands dynamically.
//
// It allows us to collocate commands with tests more
@@ -133,4 +133,3 @@ namespace CliFx.Tests.Utils
return commandTypes.Single();
}
}
}

View File

@@ -4,8 +4,8 @@ using FluentAssertions;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;
namespace CliFx.Tests.Utils.Extensions
{
namespace CliFx.Tests.Utils.Extensions;
internal static class AssertionExtensions
{
public static void ConsistOfLines(
@@ -49,4 +49,3 @@ namespace CliFx.Tests.Utils.Extensions
params string[] values) =>
assertions.ContainAllInOrder((IEnumerable<string>) values);
}
}

View File

@@ -1,8 +1,8 @@
using CliFx.Infrastructure;
using Xunit.Abstractions;
namespace CliFx.Tests.Utils.Extensions
{
namespace CliFx.Tests.Utils.Extensions;
internal static class ConsoleExtensions
{
public static void DumpToTestOutput(this FakeInMemoryConsole console, ITestOutputHelper testOutputHelper)
@@ -14,4 +14,3 @@ namespace CliFx.Tests.Utils.Extensions
testOutputHelper.WriteLine(console.ReadErrorString());
}
}
}

View File

@@ -2,11 +2,10 @@
using CliFx.Attributes;
using CliFx.Infrastructure;
namespace CliFx.Tests.Utils
{
namespace CliFx.Tests.Utils;
[Command]
public class NoOpCommand : ICommand
{
public ValueTask ExecuteAsync(IConsole console) => default;
}
}

View File

@@ -1,8 +1,8 @@
using System;
using System.Collections.Generic;
namespace CliFx
{
namespace CliFx;
/// <summary>
/// Configuration of an application.
/// </summary>
@@ -36,4 +36,3 @@ namespace CliFx
IsPreviewModeAllowed = isPreviewModeAllowed;
}
}
}

View File

@@ -1,5 +1,5 @@
namespace CliFx
{
namespace CliFx;
/// <summary>
/// Metadata associated with an application.
/// </summary>
@@ -40,4 +40,3 @@
Description = description;
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Attributes
{
namespace CliFx.Attributes;
/// <summary>
/// Annotates a type that defines a command.
/// </summary>
@@ -40,4 +40,3 @@ namespace CliFx.Attributes
{
}
}
}

View File

@@ -1,8 +1,8 @@
using System;
using CliFx.Extensibility;
namespace CliFx.Attributes
{
namespace CliFx.Attributes;
/// <summary>
/// Annotates a property that defines a command option.
/// </summary>
@@ -97,4 +97,3 @@ namespace CliFx.Attributes
{
}
}
}

View File

@@ -1,8 +1,8 @@
using System;
using CliFx.Extensibility;
namespace CliFx.Attributes
{
namespace CliFx.Attributes;
/// <summary>
/// Annotates a property that defines a command parameter.
/// </summary>
@@ -64,4 +64,3 @@ namespace CliFx.Attributes
Order = order;
}
}
}

View File

@@ -11,8 +11,8 @@ using CliFx.Schema;
using CliFx.Utils;
using CliFx.Utils.Extensions;
namespace CliFx
{
namespace CliFx;
/// <summary>
/// Command line application facade.
/// </summary>
@@ -238,4 +238,3 @@ namespace CliFx
.ToArray()
);
}
}

View File

@@ -8,8 +8,8 @@ using CliFx.Infrastructure;
using CliFx.Schema;
using CliFx.Utils.Extensions;
namespace CliFx
{
namespace CliFx;
/// <summary>
/// Builder for <see cref="CliApplication"/>.
/// </summary>
@@ -249,4 +249,3 @@ namespace CliFx
? "v" + EntryAssembly.GetName().Version.ToSemanticString()
: "v1.0";
}
}

View File

@@ -10,8 +10,8 @@ using CliFx.Input;
using CliFx.Schema;
using CliFx.Utils.Extensions;
namespace CliFx
{
namespace CliFx;
internal class CommandBinder
{
private readonly ITypeActivator _typeActivator;
@@ -363,4 +363,3 @@ namespace CliFx
BindOptions(commandInput, commandSchema, commandInstance);
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Exceptions
{
namespace CliFx.Exceptions;
/// <summary>
/// Exception thrown when there is an error during application execution.
/// </summary>
@@ -51,4 +51,3 @@ namespace CliFx.Exceptions
internal static CliFxException UserError(string message, Exception? innerException = null) =>
new(message, DefaultExitCode, true, innerException);
}
}

View File

@@ -1,7 +1,7 @@
using System;
namespace CliFx.Exceptions
{
namespace CliFx.Exceptions;
/// <summary>
/// Exception thrown when a command cannot proceed with its normal execution due to an error.
/// Use this exception to report an error to the console and return a specific exit code.
@@ -20,4 +20,3 @@ namespace CliFx.Exceptions
{
}
}
}

View File

@@ -1,5 +1,5 @@
namespace CliFx.Extensibility
{
namespace CliFx.Extensibility;
// Used internally to simplify usage from reflection
internal interface IBindingConverter
{
@@ -18,4 +18,3 @@
object? IBindingConverter.Convert(string? rawValue) => Convert(rawValue);
}
}

View File

@@ -1,5 +1,5 @@
namespace CliFx.Extensibility
{
namespace CliFx.Extensibility;
/// <summary>
/// Represents a validation error.
/// </summary>
@@ -15,4 +15,3 @@
/// </summary>
public BindingValidationError(string message) => Message = message;
}
}

View File

@@ -1,5 +1,5 @@
namespace CliFx.Extensibility
{
namespace CliFx.Extensibility;
// Used internally to simplify usage from reflection
internal interface IBindingValidator
{
@@ -33,4 +33,3 @@
BindingValidationError? IBindingValidator.Validate(object? value) => Validate((T) value!);
}
}

View File

@@ -4,8 +4,8 @@ using CliFx.Attributes;
using CliFx.Infrastructure;
using CliFx.Schema;
namespace CliFx
{
namespace CliFx;
// Fallback command used when the application doesn't have one configured.
// This command is only used as a stub for help text.
[Command]
@@ -18,4 +18,3 @@ namespace CliFx
[ExcludeFromCodeCoverage]
public ValueTask ExecuteAsync(IConsole console) => default;
}
}

View File

@@ -2,8 +2,8 @@
using CliFx.Infrastructure;
using CliFx.Input;
namespace CliFx.Formatting
{
namespace CliFx.Formatting;
internal class CommandInputConsoleFormatter : ConsoleFormatter
{
public CommandInputConsoleFormatter(ConsoleWriter consoleWriter)
@@ -95,4 +95,3 @@ namespace CliFx.Formatting
public static void WriteCommandInput(this ConsoleWriter consoleWriter, CommandInput commandInput) =>
new CommandInputConsoleFormatter(consoleWriter).WriteCommandInput(commandInput);
}
}

View File

@@ -1,8 +1,8 @@
using System;
using CliFx.Infrastructure;
namespace CliFx.Formatting
{
namespace CliFx.Formatting;
internal class ConsoleFormatter
{
private readonly ConsoleWriter _consoleWriter;
@@ -72,4 +72,3 @@ namespace CliFx.Formatting
WriteHorizontalMargin(offsetSize);
}
}
}

View File

@@ -4,8 +4,8 @@ using CliFx.Exceptions;
using CliFx.Infrastructure;
using CliFx.Utils;
namespace CliFx.Formatting
{
namespace CliFx.Formatting;
internal class ExceptionConsoleFormatter : ConsoleFormatter
{
public ExceptionConsoleFormatter(ConsoleWriter consoleWriter)
@@ -132,4 +132,3 @@ namespace CliFx.Formatting
public static void WriteException(this ConsoleWriter consoleWriter, Exception exception) =>
new ExceptionConsoleFormatter(consoleWriter).WriteException(exception);
}
}

View File

@@ -7,8 +7,8 @@ using CliFx.Infrastructure;
using CliFx.Schema;
using CliFx.Utils.Extensions;
namespace CliFx.Formatting
{
namespace CliFx.Formatting;
internal class HelpConsoleFormatter : ConsoleFormatter
{
private readonly HelpContext _context;
@@ -447,4 +447,3 @@ namespace CliFx.Formatting
public static void WriteHelpText(this ConsoleWriter consoleWriter, HelpContext context) =>
new HelpConsoleFormatter(consoleWriter, context).WriteHelpText();
}
}

Some files were not shown because too many files have changed in this diff Show More