@@ -38,31 +38,30 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
38
38
39
39
IMethodSymbol methodSymbol = ( IMethodSymbol ) context . TargetSymbol ;
40
40
41
- // Produce the incremental models
42
- HierarchyInfo hierarchy = HierarchyInfo . From ( methodSymbol . ContainingType ) ;
43
- CommandInfo ? commandInfo = Execute . GetInfo ( methodSymbol , context . Attributes [ 0 ] , out ImmutableArray < DiagnosticInfo > diagnostics ) ;
41
+ // Get the hierarchy info for the target symbol, and try to gather the command info
42
+ HierarchyInfo ? hierarchy = HierarchyInfo . From ( methodSymbol . ContainingType ) ;
43
+
44
+ _ = Execute . TryGetInfo ( methodSymbol , context . Attributes [ 0 ] , out CommandInfo ? commandInfo , out ImmutableArray < DiagnosticInfo > diagnostics ) ;
44
45
45
46
return ( Hierarchy : hierarchy , new Result < CommandInfo ? > ( commandInfo , diagnostics ) ) ;
46
47
} )
47
- . Where ( static item => item . Hierarchy is not null ) ;
48
+ . Where ( static item => item . Hierarchy is not null ) ! ;
48
49
49
50
// Output the diagnostics
50
51
context . ReportDiagnostics ( commandInfoWithErrors . Select ( static ( item , _ ) => item . Info . Errors ) ) ;
51
52
52
53
// Get the filtered sequence to enable caching
53
- IncrementalValuesProvider < ( HierarchyInfo Hierarchy , CommandInfo Info ) > commandInfo =
54
+ IncrementalValuesProvider < ( HierarchyInfo Hierarchy , Result < CommandInfo > Info ) > commandInfo =
54
55
commandInfoWithErrors
55
- . Where ( static item => item . Info . Value is not null )
56
- . Select ( static ( item , _ ) => ( item . Hierarchy , item . Info . Value ! ) )
57
- . WithComparers ( HierarchyInfo . Comparer . Default , CommandInfo . Comparer . Default ) ;
56
+ . Where ( static item => item . Info . Value is not null ) ! ;
58
57
59
58
// Generate the commands
60
59
context . RegisterSourceOutput ( commandInfo , static ( context , item ) =>
61
60
{
62
- ImmutableArray < MemberDeclarationSyntax > memberDeclarations = Execute . GetSyntax ( item . Info ) ;
61
+ ImmutableArray < MemberDeclarationSyntax > memberDeclarations = Execute . GetSyntax ( item . Info . Value ) ;
63
62
CompilationUnitSyntax compilationUnit = item . Hierarchy . GetCompilationUnit ( memberDeclarations ) ;
64
63
65
- context . AddSource ( $ "{ item . Hierarchy . FilenameHint } .{ item . Info . MethodName } .g.cs", compilationUnit . GetText ( Encoding . UTF8 ) ) ;
64
+ context . AddSource ( $ "{ item . Hierarchy . FilenameHint } .{ item . Info . Value . MethodName } .g.cs", compilationUnit . GetText ( Encoding . UTF8 ) ) ;
66
65
} ) ;
67
66
}
68
67
}
0 commit comments