@@ -80,22 +80,23 @@ public static ParserResult<T> Build<T>(
8080 var specPropsWithValue =
8181 optionSpecPropsResult . SucceededWith ( ) . Concat ( valueSpecPropsResult . SucceededWith ( ) ) ;
8282
83- Func < T > buildMutable = ( ) =>
83+ var setPropertyErrors = new List < Error > ( ) ;
84+
85+ Func < T > buildMutable = ( ) =>
8486 {
8587 var mutable = factory . MapValueOrDefault ( f => f ( ) , Activator . CreateInstance < T > ( ) ) ;
86- mutable =
87- mutable . SetProperties ( specPropsWithValue , sp => sp . Value . IsJust ( ) , sp => sp . Value . FromJustOrFail ( ) )
88- . SetProperties (
89- specPropsWithValue ,
90- sp => sp . Value . IsNothing ( ) && sp . Specification . DefaultValue . IsJust ( ) ,
91- sp => sp . Specification . DefaultValue . FromJustOrFail ( ) )
92- . SetProperties (
93- specPropsWithValue ,
94- sp =>
95- sp . Value . IsNothing ( ) && sp . Specification . TargetType == TargetType . Sequence
96- && sp . Specification . DefaultValue . MatchNothing ( ) ,
97- sp => sp . Property . PropertyType . GetTypeInfo ( ) . GetGenericArguments ( ) . Single ( ) . CreateEmptyArray ( ) ) ;
98- return mutable ;
88+ setPropertyErrors . AddRange ( mutable . SetProperties ( specPropsWithValue , sp => sp . Value . IsJust ( ) , sp => sp . Value . FromJustOrFail ( ) ) ) ;
89+ setPropertyErrors . AddRange ( mutable . SetProperties (
90+ specPropsWithValue ,
91+ sp => sp . Value . IsNothing ( ) && sp . Specification . DefaultValue . IsJust ( ) ,
92+ sp => sp . Specification . DefaultValue . FromJustOrFail ( ) ) ) ;
93+ setPropertyErrors . AddRange ( mutable . SetProperties (
94+ specPropsWithValue ,
95+ sp =>
96+ sp . Value . IsNothing ( ) && sp . Specification . TargetType == TargetType . Sequence
97+ && sp . Specification . DefaultValue . MatchNothing ( ) ,
98+ sp => sp . Property . PropertyType . GetTypeInfo ( ) . GetGenericArguments ( ) . Single ( ) . CreateEmptyArray ( ) ) ) ;
99+ return mutable ;
99100 } ;
100101
101102 Func < T > buildImmutable = ( ) =>
@@ -121,6 +122,7 @@ join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToL
121122 . Concat ( optionSpecPropsResult . SuccessfulMessages ( ) )
122123 . Concat ( valueSpecPropsResult . SuccessfulMessages ( ) )
123124 . Concat ( validationErrors )
125+ . Concat ( setPropertyErrors )
124126 . Memorize ( ) ;
125127
126128 var warnings = from e in allErrors where nonFatalErrors . Contains ( e . Tag ) select e ;
0 commit comments