File tree Expand file tree Collapse file tree
src/reactive/Reactive.Compiler/Features/Required Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,17 +24,24 @@ private static void AnalyzeInitializer(SyntaxNodeAnalysisContext context) {
2424 var assigned = node . Initializer . ChildNodes ( )
2525 . OfType < AssignmentExpressionSyntax > ( )
2626 . Where ( x => x . Left is IdentifierNameSyntax )
27- . Select ( x => semanticModel . GetSymbolInfo ( x . Left ) . Symbol ) ;
27+ . Select ( x => semanticModel . GetSymbolInfo ( x . Left ) . Symbol )
28+ . ToArray ( ) ;
2829
30+ // Properties set by another properties with SetsRequired attributes
2931 var setNames = assigned
3032 . Select ( x => x ! . GetAttribute < SetsRequiredAttribute > ( semanticModel ) )
3133 . OfType < AttributeData > ( )
3234 . Select ( x => x . GetNamedArgument ( nameof ( SetsRequiredAttribute . Names ) ) )
3335 . SelectMany ( x => x ? . Values . Select ( y => y . Value ) )
3436 . OfType < string > ( ) ;
37+
38+ // Required properties set directly
39+ var reqNames = assigned
40+ . Where ( x => x ! . GetAttribute < RequiredAttribute > ( semanticModel ) != null )
41+ . Select ( x => x ! . Name ) ;
3542
3643 // If property is assigned we remove it from the required list
37- foreach ( var name in setNames ) {
44+ foreach ( var name in setNames . Concat ( reqNames ) ) {
3845 required . Remove ( name ) ;
3946 }
4047 }
You can’t perform that action at this time.
0 commit comments