@@ -80,22 +80,23 @@ public static ParserResult<T> Build<T>(
80
80
var specPropsWithValue =
81
81
optionSpecPropsResult . SucceededWith ( ) . Concat ( valueSpecPropsResult . SucceededWith ( ) ) ;
82
82
83
- Func < T > buildMutable = ( ) =>
83
+ var setPropertyErrors = new List < Error > ( ) ;
84
+
85
+ Func < T > buildMutable = ( ) =>
84
86
{
85
87
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 ;
99
100
} ;
100
101
101
102
Func < T > buildImmutable = ( ) =>
@@ -121,6 +122,7 @@ join sp in specPropsWithValue on prms.Name.ToLower() equals sp.Property.Name.ToL
121
122
. Concat ( optionSpecPropsResult . SuccessfulMessages ( ) )
122
123
. Concat ( valueSpecPropsResult . SuccessfulMessages ( ) )
123
124
. Concat ( validationErrors )
125
+ . Concat ( setPropertyErrors )
124
126
. Memorize ( ) ;
125
127
126
128
var warnings = from e in allErrors where nonFatalErrors . Contains ( e . Tag ) select e ;
0 commit comments