mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Clean up
This commit is contained in:
@@ -9,15 +9,15 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.4.5" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.26.5" PrivateAssets="all" />
|
||||
<PackageReference Include="Basic.Reference.Assemblies.Net80" Version="1.7.2" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2" PrivateAssets="all" />
|
||||
<PackageReference Include="CSharpier.MsBuild" Version="0.28.2" PrivateAssets="all" />
|
||||
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" PrivateAssets="all" />
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" />
|
||||
<PackageReference Include="xunit" Version="2.8.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,8 +13,7 @@ public class GeneralSpecs
|
||||
{
|
||||
// Arrange
|
||||
var analyzers = typeof(AnalyzerBase)
|
||||
.Assembly
|
||||
.GetTypes()
|
||||
.Assembly.GetTypes()
|
||||
.Where(t => !t.IsAbstract && t.IsAssignableTo(typeof(DiagnosticAnalyzer)))
|
||||
.Select(t => (DiagnosticAnalyzer)Activator.CreateInstance(t)!)
|
||||
.ToArray();
|
||||
|
||||
@@ -20,7 +20,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption(null)]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -40,7 +40,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -60,7 +60,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -79,7 +79,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -19,10 +19,10 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
[CommandOption("foo")]
|
||||
public string? Bar { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -42,10 +42,10 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
[CommandOption("bar")]
|
||||
public string? Bar { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -65,7 +65,7 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -84,7 +84,7 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -20,10 +20,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
[CommandOption('f')]
|
||||
public string? Bar { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -43,10 +43,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
[CommandOption('b')]
|
||||
public string? Bar { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -66,10 +66,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
[CommandOption('F')]
|
||||
public string? Bar { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -89,7 +89,7 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -108,7 +108,7 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -19,7 +19,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("f")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -39,7 +39,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("1foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -59,7 +59,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -79,7 +79,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -98,7 +98,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -20,7 +20,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('1')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -40,7 +40,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption('f')]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -60,7 +60,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -79,7 +79,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -19,13 +19,13 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
|
||||
{
|
||||
public void Validate(string value) {}
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
[CommandOption("foo", Validators = new[] { typeof(MyValidator) })]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -44,13 +44,13 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
|
||||
{
|
||||
public override BindingValidationError Validate(int value) => Ok();
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
[CommandOption("foo", Validators = new[] { typeof(MyValidator) })]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -69,13 +69,13 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
|
||||
{
|
||||
public override BindingValidationError Validate(string value) => Ok();
|
||||
}
|
||||
|
||||
|
||||
[Command]
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
[CommandOption("foo", Validators = new[] { typeof(MyValidator) })]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -95,7 +95,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
|
||||
{
|
||||
[CommandOption("foo")]
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
@@ -114,7 +114,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public string? Foo { get; init; }
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SystemConsoleShouldBeAvoidedAnalyzerSpecs
|
||||
public class MyCommand : ICommand
|
||||
{
|
||||
public void SomeOtherMethod() => Console.WriteLine("Test");
|
||||
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console) => default;
|
||||
}
|
||||
""";
|
||||
|
||||
@@ -30,8 +30,7 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
|
||||
|
||||
// Get default CliFx namespaces
|
||||
var defaultCliFxNamespaces = typeof(ICommand)
|
||||
.Assembly
|
||||
.GetTypes()
|
||||
.Assembly.GetTypes()
|
||||
.Where(t => t.IsPublic)
|
||||
.Select(t => t.Namespace)
|
||||
.Distinct()
|
||||
@@ -54,10 +53,9 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
|
||||
var compilation = CSharpCompilation.Create(
|
||||
"CliFxTests_DynamicAssembly_" + Guid.NewGuid(),
|
||||
[ast],
|
||||
Net80
|
||||
.References
|
||||
.All
|
||||
.Append(MetadataReference.CreateFromFile(typeof(ICommand).Assembly.Location)),
|
||||
Net80.References.All.Append(
|
||||
MetadataReference.CreateFromFile(typeof(ICommand).Assembly.Location)
|
||||
),
|
||||
// DLL to avoid having to define the Main() method
|
||||
new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
|
||||
);
|
||||
@@ -105,8 +103,7 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
|
||||
== expectedDiagnosticIds.Length;
|
||||
|
||||
Execute
|
||||
.Assertion
|
||||
.ForCondition(isSuccessfulAssertion)
|
||||
.Assertion.ForCondition(isSuccessfulAssertion)
|
||||
.FailWith(() =>
|
||||
{
|
||||
var buffer = new StringBuilder();
|
||||
@@ -150,8 +147,7 @@ internal class AnalyzerAssertions(DiagnosticAnalyzer analyzer)
|
||||
var isSuccessfulAssertion = !producedDiagnostics.Any();
|
||||
|
||||
Execute
|
||||
.Assertion
|
||||
.ForCondition(isSuccessfulAssertion)
|
||||
.Assertion.ForCondition(isSuccessfulAssertion)
|
||||
.FailWith(() =>
|
||||
{
|
||||
var buffer = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user