Skip to content

Commit 47269dd

Browse files
authored
Merge pull request #371 from pic-Nick/fix-issue_115
Fixed #115:
2 parents 408ba67 + 55bf655 commit 47269dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/CommandLine/Core/InstanceBuilder.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ public static ParserResult<T> Build<T>(
106106
{
107107
var ctor = typeInfo.GetTypeInfo().GetConstructor((from sp in specProps select sp.Property.PropertyType).ToArray());
108108
var values = (from prms in ctor.GetParameters()
109-
join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToLower()
109+
join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToLower() into spv
110+
from sp in spv.DefaultIfEmpty()
110111
select
111-
sp.Value.GetValueOrDefault(
112+
sp == null
113+
? specProps.First(s => String.Equals(s.Property.Name, prms.Name, StringComparison.CurrentCultureIgnoreCase))
114+
.Property.PropertyType.GetDefaultValue()
115+
: sp.Value.GetValueOrDefault(
112116
sp.Specification.DefaultValue.GetValueOrDefault(
113117
sp.Specification.ConversionType.CreateDefaultForImmutable()))).ToArray();
114118
var immutable = (T)ctor.Invoke(values);

0 commit comments

Comments
 (0)