This commit is contained in:
Tyrrrz
2023-05-16 01:36:03 +03:00
parent 01f29a5375
commit e52781c25a
61 changed files with 1264 additions and 1345 deletions

View File

@@ -69,7 +69,7 @@ public class CommandMustBeAnnotatedAnalyzerSpecs
"""
public class Foo
{
public int Bar { get; set; } = 5;
public int Bar { get; init; } = 5;
}
""";

View File

@@ -53,7 +53,7 @@ public class CommandMustImplementInterfaceAnalyzerSpecs
"""
public class Foo
{
public int Bar { get; set; } = 5;
public int Bar { get; init; } = 5;
}
""";

View File

@@ -18,7 +18,7 @@ public class OptionMustBeInsideCommandAnalyzerSpecs
public class MyClass
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
}
""";
@@ -37,7 +37,7 @@ public class OptionMustBeInsideCommandAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -57,7 +57,7 @@ public class OptionMustBeInsideCommandAnalyzerSpecs
public abstract class MyCommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
}
""";
@@ -75,7 +75,7 @@ public class OptionMustBeInsideCommandAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,7 +19,7 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f', IsRequired = false)]
public required string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -39,8 +39,8 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
[CommandOption('f', IsRequired = true)]
public required string Foo { get; set; }
[CommandOption('f')]
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -61,7 +61,7 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f', IsRequired = false)]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -81,8 +81,8 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
[CommandOption('f', IsRequired = true)]
public string Foo { get; set; }
[CommandOption('f')]
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -102,7 +102,7 @@ public class OptionMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public required string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,7 +19,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption(null)]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -40,7 +40,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -61,7 +61,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -81,7 +81,7 @@ public class OptionMustHaveNameOrShortNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,10 +19,10 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandOption("foo")]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -43,10 +43,10 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandOption("bar")]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -67,7 +67,7 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -87,7 +87,7 @@ public class OptionMustHaveUniqueNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,10 +19,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandOption('f')]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -43,10 +43,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandOption('b')]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -67,10 +67,10 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandOption('F')]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -91,7 +91,7 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -111,7 +111,7 @@ public class OptionMustHaveUniqueShortNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -17,15 +17,15 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter
{
public string Convert(string rawValue) => rawValue;
public string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,15 +43,15 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<int>
{
public override int Convert(string rawValue) => 42;
public override int Convert(string? rawValue) => 42;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -69,15 +69,15 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<string>
{
public override string Convert(string rawValue) => rawValue;
public override string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -95,15 +95,15 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<int>
{
public override int Convert(string rawValue) => 42;
public override int Convert(string? rawValue) => 42;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public int? Foo { get; set; }
public int? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -121,15 +121,15 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<string>
{
public override string Convert(string rawValue) => rawValue;
public override string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public IReadOnlyList<string> Foo { get; set; }
public IReadOnlyList<string>? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -149,8 +149,8 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -169,8 +169,8 @@ public class OptionMustHaveValidConverterAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,7 +19,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("f")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -40,7 +40,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("1foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -61,7 +61,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -82,7 +82,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -102,7 +102,7 @@ public class OptionMustHaveValidNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,7 +19,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('1')]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -40,7 +40,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption('f')]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -61,7 +61,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -81,7 +81,7 @@ public class OptionMustHaveValidShortNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -24,7 +24,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo", Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -50,7 +50,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo", Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -76,7 +76,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo", Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -97,7 +97,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandOption("foo")]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -117,7 +117,7 @@ public class OptionMustHaveValidValidatorsAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -18,7 +18,7 @@ public class ParameterMustBeInsideCommandAnalyzerSpecs
public class MyClass
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
}
""";
@@ -37,8 +37,8 @@ public class ParameterMustBeInsideCommandAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -57,7 +57,7 @@ public class ParameterMustBeInsideCommandAnalyzerSpecs
public abstract class MyCommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
}
""";
@@ -75,8 +75,8 @@ public class ParameterMustBeInsideCommandAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,11 +19,11 @@ public class ParameterMustBeLastIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = false)]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandParameter(1)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustBeLastIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1, IsRequired = false)]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -67,11 +67,11 @@ public class ParameterMustBeLastIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
[CommandParameter(1, IsRequired = true)]
public string Bar { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -90,8 +90,8 @@ public class ParameterMustBeLastIfNonRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,11 +19,11 @@ public class ParameterMustBeLastIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string[] Foo { get; set; }
public required string[] Foo { get; init; }
[CommandParameter(1)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustBeLastIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public string[] Bar { get; set; }
public required string[] Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -67,11 +67,11 @@ public class ParameterMustBeLastIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -90,8 +90,8 @@ public class ParameterMustBeLastIfNonScalarAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,7 +19,7 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = false)]
public required string Foo { get; set; }
public required string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -39,8 +39,8 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = true)]
public required string Foo { get; set; }
[CommandParameter(0)]
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -61,7 +61,7 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = false)]
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -81,8 +81,8 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = true)]
public string Foo { get; set; }
[CommandParameter(0)]
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
@@ -102,7 +102,7 @@ public class ParameterMustBeRequiredIfPropertyRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public required string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}

View File

@@ -19,11 +19,11 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, IsRequired = false)]
public string Foo { get; set; }
public string? Foo { get; init; }
[CommandParameter(1, IsRequired = false)]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1, IsRequired = false)]
public string Bar { get; set; }
public string? Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -67,11 +67,11 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
[CommandParameter(1, IsRequired = true)]
public string Bar { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -90,8 +90,8 @@ public class ParameterMustBeSingleIfNonRequiredAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,11 +19,11 @@ public class ParameterMustBeSingleIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string[] Foo { get; set; }
public required string[] Foo { get; init; }
[CommandParameter(1)]
public string[] Bar { get; set; }
public required string[] Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustBeSingleIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public string[] Bar { get; set; }
public required string[] Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -67,11 +67,11 @@ public class ParameterMustBeSingleIfNonScalarAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -90,8 +90,8 @@ public class ParameterMustBeSingleIfNonScalarAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,11 +19,11 @@ public class ParameterMustHaveUniqueNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, Name = "foo")]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1, Name = "foo")]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustHaveUniqueNameAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0, Name = "foo")]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1, Name = "bar")]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -66,8 +66,8 @@ public class ParameterMustHaveUniqueNameAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,11 +19,11 @@ public class ParameterMustHaveUniqueOrderAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(0)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,11 +43,11 @@ public class ParameterMustHaveUniqueOrderAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
[CommandParameter(1)]
public string Bar { get; set; }
public required string Bar { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -66,8 +66,8 @@ public class ParameterMustHaveUniqueOrderAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -17,15 +17,15 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter
{
public string Convert(string rawValue) => rawValue;
public string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Converter = typeof(MyConverter))]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -43,15 +43,15 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<int>
{
public override int Convert(string rawValue) => 42;
public override int Convert(string? rawValue) => 42;
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Converter = typeof(MyConverter))]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -70,15 +70,15 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<string>
{
public override string Convert(string rawValue) => rawValue;
public override string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Converter = typeof(MyConverter))]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -96,15 +96,15 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<int>
{
public override int Convert(string rawValue) => 42;
public override int Convert(string? rawValue) => 42;
}
[Command]
public class MyCommand : ICommand
{
[CommandOption("foo", Converter = typeof(MyConverter))]
public int? Foo { get; set; }
public int? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -122,15 +122,15 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
"""
public class MyConverter : BindingConverter<string>
{
public override string Convert(string rawValue) => rawValue;
public override string Convert(string? rawValue) => rawValue;
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Converter = typeof(MyConverter))]
public IReadOnlyList<string> Foo { get; set; }
public required IReadOnlyList<string> Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -150,8 +150,8 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -170,8 +170,8 @@ public class ParameterMustHaveValidConverterAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";

View File

@@ -19,13 +19,13 @@ public class ParameterMustHaveValidValidatorsAnalyzerSpecs
{
public void Validate(string value) {}
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -45,13 +45,13 @@ public class ParameterMustHaveValidValidatorsAnalyzerSpecs
{
public override BindingValidationError Validate(int value) => Ok();
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -71,13 +71,13 @@ public class ParameterMustHaveValidValidatorsAnalyzerSpecs
{
public override BindingValidationError Validate(string value) => Ok();
}
[Command]
public class MyCommand : ICommand
{
[CommandParameter(0, Validators = new[] {typeof(MyValidator)})]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -97,8 +97,8 @@ public class ParameterMustHaveValidValidatorsAnalyzerSpecs
public class MyCommand : ICommand
{
[CommandParameter(0)]
public string Foo { get; set; }
public required string Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";
@@ -117,8 +117,8 @@ public class ParameterMustHaveValidValidatorsAnalyzerSpecs
[Command]
public class MyCommand : ICommand
{
public string Foo { get; set; }
public string? Foo { get; init; }
public ValueTask ExecuteAsync(IConsole console) => default;
}
""";