Skip to content

Commit

Permalink
Merge pull request #371 from pic-Nick/fix-issue_115
Browse files Browse the repository at this point in the history
Fixed #115:
  • Loading branch information
ericnewton76 authored Dec 18, 2018
2 parents 408ba67 + 55bf655 commit 47269dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/CommandLine/Core/InstanceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,13 @@ public static ParserResult<T> Build<T>(
{
var ctor = typeInfo.GetTypeInfo().GetConstructor((from sp in specProps select sp.Property.PropertyType).ToArray());
var values = (from prms in ctor.GetParameters()
join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToLower()
join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToLower() into spv
from sp in spv.DefaultIfEmpty()
select
sp.Value.GetValueOrDefault(
sp == null
? specProps.First(s => String.Equals(s.Property.Name, prms.Name, StringComparison.CurrentCultureIgnoreCase))
.Property.PropertyType.GetDefaultValue()
: sp.Value.GetValueOrDefault(
sp.Specification.DefaultValue.GetValueOrDefault(
sp.Specification.ConversionType.CreateDefaultForImmutable()))).ToArray();
var immutable = (T)ctor.Invoke(values);
Expand Down

0 comments on commit 47269dd

Please sign in to comment.