mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Fix warnings in tests
This commit is contained in:
@@ -43,7 +43,7 @@ namespace CliFx.Tests
|
||||
.UseVersionText("test")
|
||||
.UseDescription("test")
|
||||
.UseConsole(new VirtualConsole(Stream.Null))
|
||||
.UseTypeActivator(Activator.CreateInstance)
|
||||
.UseTypeActivator(Activator.CreateInstance!)
|
||||
.Build();
|
||||
|
||||
// Assert
|
||||
@@ -212,7 +212,7 @@ namespace CliFx.Tests
|
||||
new[]
|
||||
{
|
||||
new CommandParameterSchema(
|
||||
typeof(HiddenPropertiesCommand).GetProperty(nameof(HiddenPropertiesCommand.Parameter)),
|
||||
typeof(HiddenPropertiesCommand).GetProperty(nameof(HiddenPropertiesCommand.Parameter))!,
|
||||
13,
|
||||
"param",
|
||||
"Param description")
|
||||
@@ -220,7 +220,7 @@ namespace CliFx.Tests
|
||||
new[]
|
||||
{
|
||||
new CommandOptionSchema(
|
||||
typeof(HiddenPropertiesCommand).GetProperty(nameof(HiddenPropertiesCommand.Option)),
|
||||
typeof(HiddenPropertiesCommand).GetProperty(nameof(HiddenPropertiesCommand.Option))!,
|
||||
"option",
|
||||
'o',
|
||||
"ENV",
|
||||
|
||||
@@ -17,20 +17,14 @@ namespace CliFx.Tests
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
public StringConstructable(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
public StringConstructable(string value) => Value = value;
|
||||
}
|
||||
|
||||
private class StringParseable
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private StringParseable(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
private StringParseable(string value) => Value = value;
|
||||
|
||||
public static StringParseable Parse(string value) => new StringParseable(value);
|
||||
}
|
||||
@@ -39,10 +33,7 @@ namespace CliFx.Tests
|
||||
{
|
||||
public string Value { get; }
|
||||
|
||||
private StringParseableWithFormatProvider(string value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
private StringParseableWithFormatProvider(string value) => Value = value;
|
||||
|
||||
public static StringParseableWithFormatProvider Parse(string value, IFormatProvider formatProvider) =>
|
||||
new StringParseableWithFormatProvider(value + " " + formatProvider);
|
||||
@@ -54,9 +45,7 @@ namespace CliFx.Tests
|
||||
|
||||
public class CustomEnumerable<T> : IEnumerable<T>
|
||||
{
|
||||
private readonly T[] _arr = new T[0];
|
||||
|
||||
public IEnumerator<T> GetEnumerator() => ((IEnumerable<T>) _arr).GetEnumerator();
|
||||
public IEnumerator<T> GetEnumerator() => ((IEnumerable<T>) Array.Empty<T>()).GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using CliFx.Attributes;
|
||||
|
||||
@@ -20,7 +21,7 @@ namespace CliFx.Tests
|
||||
private class ConcatCommand : ICommand
|
||||
{
|
||||
[CommandOption('i', IsRequired = true, Description = "Input strings.")]
|
||||
public IReadOnlyList<string> Inputs { get; set; }
|
||||
public IReadOnlyList<string> Inputs { get; set; } = Array.Empty<string>();
|
||||
|
||||
[CommandOption('s', Description = "String separator.")]
|
||||
public string Separator { get; set; } = "";
|
||||
@@ -36,10 +37,10 @@ namespace CliFx.Tests
|
||||
private class DivideCommand : ICommand
|
||||
{
|
||||
[CommandOption("dividend", 'D', IsRequired = true, Description = "The number to divide.")]
|
||||
public double Dividend { get; set; }
|
||||
public double Dividend { get; set; } = 0;
|
||||
|
||||
[CommandOption("divisor", 'd', IsRequired = true, Description = "The number to divide by.")]
|
||||
public double Divisor { get; set; }
|
||||
public double Divisor { get; set; } = 0;
|
||||
|
||||
public ValueTask ExecuteAsync(IConsole console)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user