Skip to content

Commit

Permalink
add null checks to constructors to ensure valid data
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjaylward committed May 22, 2020
1 parent ad50269 commit 3094bfb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/CommandLine/ParserResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ public abstract class ParserResult<T>
internal ParserResult(IEnumerable<Error> errors, TypeInfo typeInfo)
{
this.tag = ParserResultType.NotParsed;
this.typeInfo = typeInfo;
Errors = errors;
this.typeInfo = typeInfo ?? TypeInfo.Create(typeof(T));
Errors = errors ?? new Error[0];
Value = default;
}

internal ParserResult(T value, TypeInfo typeInfo)
{
Value = value ?? throw new ArgumentNullException(nameof(value));
this.tag = ParserResultType.Parsed;
this.typeInfo = typeInfo;
this.typeInfo = typeInfo ?? TypeInfo.Create(value.GetType());
Errors = new Error[0];
Value = value;
}

/// <summary>
Expand Down

0 comments on commit 3094bfb

Please sign in to comment.