Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DearVa committed Dec 23, 2023
1 parent 2d38dd8 commit 0b1be8c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<Company>Antelcat</Company>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>1.2.3</FileVersion>
<AssemblyVersion>1.2.4</AssemblyVersion>
<FileVersion>1.2.4</FileVersion>
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ParsedArgument
{
public string Name { get; }
public object? Value => value;
public virtual object? Value => value;
public bool HasValue => hasValue;
protected object? value;
Expand Down Expand Up @@ -52,7 +52,7 @@ public ParsedArrayArgument(string name) : base(name)
value = new List<T>(1);
}
public T[] ToArray() => ((List<T>)value!).ToArray();
public override object? Value => ((List<T>)value!).ToArray();
public override void SetValue(object? value)
{
Expand Down Expand Up @@ -157,31 +157,13 @@ public static void ParseArguments(
public static T ConvertArgument<T>(ParsedArgument parsed)
{
if (!parsed.HasValue) throw new ArgumentException($"Argument \"{parsed.Name}\" is not specified.");
object? value;
if (parsed is ParsedArrayArgument<T> parsedArray)
{
value = parsedArray.ToArray();
}
else
{
value = parsed.Value;
}
return value is T result ? result : throw new ArgumentException($"Argument \"{parsed.Name}\" is not of type {typeof(T).FullName}.");
return parsed.Value is T result ? result : throw new ArgumentException($"Argument \"{parsed.Name}\" is not of type {typeof(T).FullName}.");
}
public static T ConvertArgument<T>(ParsedArgument parsed, T defaultValue)
{
if (!parsed.HasValue) return defaultValue;
object? value;
if (parsed is ParsedArrayArgument<T> parsedArray)
{
value = parsedArray.ToArray();
}
else
{
value = parsed.Value;
}
return value is T result ? result : throw new ArgumentException($"Argument \"{parsed.Name}\" is not of type {typeof(T).FullName}.");
return parsed.Value is T result ? result : throw new ArgumentException($"Argument \"{parsed.Name}\" is not of type {typeof(T).FullName}.");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<Version>1.2.3</Version>
<Version>1.2.4</Version>
<Company>Antelcat</Company>
<AssemblyVersion>1.2.3</AssemblyVersion>
<FileVersion>1.2.3</FileVersion>
<AssemblyVersion>1.2.4</AssemblyVersion>
<FileVersion>1.2.4</FileVersion>
<Title>Effortless Command-Line Application Builder</Title>
<Description>A powerful source generator designed to revolutionize the way you create command-line applications. This tool simplifies the process of building CLI applications by automatically generating parsing methods with just attribute marking on classes and methods.</Description>
<PackageProjectUrl>https://github.com/Antelcat/Antelcat.Parameterization</PackageProjectUrl>
Expand Down

0 comments on commit 0b1be8c

Please sign in to comment.