@@ -90,85 +90,81 @@ public async Task RunAsync()
90
90
{
91
91
Stopwatch swRun = Stopwatch . StartNew ( ) ;
92
92
93
- // Needs to block so the _afterAssemblySymbols dictionary gets updated.
94
- await ProcessBeforeAndAfterAssembliesAsync ( ) . ConfigureAwait ( false ) ;
93
+ foreach ( ( string beforeAssemblyName , IAssemblySymbol beforeAssemblySymbol ) in _beforeAssemblySymbols )
94
+ {
95
+ // Needs to block so the _afterAssemblySymbols dictionary gets updated.
96
+ await ProcessBeforeAndAfterAssemblyAsync ( beforeAssemblyName , beforeAssemblySymbol ) . ConfigureAwait ( false ) ;
97
+ }
95
98
96
99
// Needs to happen after processing the before and after assemblies and filtering out the existing ones.
97
- await ProcessNewAssembliesAsync ( ) . ConfigureAwait ( false ) ;
100
+ foreach ( ( string afterAssemblyName , IAssemblySymbol afterAssemblySymbol ) in _afterAssemblySymbols )
101
+ {
102
+ await ProcessNewAssemblyAsync ( afterAssemblyName , afterAssemblySymbol ) . ConfigureAwait ( false ) ;
103
+ }
98
104
99
105
_log . LogMessage ( $ "FINAL TOTAL TIME: { swRun . Elapsed . TotalMilliseconds / 1000.0 / 60.0 : F2} mins.") ;
100
106
swRun . Stop ( ) ;
101
107
}
102
108
103
- private async Task ProcessBeforeAndAfterAssembliesAsync ( )
109
+ private async Task ProcessBeforeAndAfterAssemblyAsync ( string beforeAssemblyName , IAssemblySymbol beforeAssemblySymbol )
104
110
{
105
- foreach ( ( string beforeAssemblyName , IAssemblySymbol beforeAssemblySymbol ) in _beforeAssemblySymbols )
106
- {
107
- StringBuilder sb = new ( ) ;
108
-
109
- _log . LogMessage ( $ "Visiting assembly { beforeAssemblySymbol . Name } (before vs after)...") ;
110
-
111
- Stopwatch swAssembly = Stopwatch . StartNew ( ) ;
112
- ( SyntaxNode beforeAssemblyNode , SemanticModel beforeModel ) = await GetAssemblyRootNodeAndModelAsync ( _beforeLoader , beforeAssemblySymbol ) . ConfigureAwait ( false ) ;
113
- string finalMessage = $ "Finished visiting { beforeAssemblySymbol . Name } (before) in { swAssembly . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
111
+ StringBuilder sb = new ( ) ;
114
112
115
- // See if an assembly with the same name can be found in the diff folder.
116
- if ( _afterAssemblySymbols . TryGetValue ( beforeAssemblyName , out IAssemblySymbol ? afterAssemblySymbol ) )
117
- {
118
- swAssembly = Stopwatch . StartNew ( ) ;
119
- ( SyntaxNode afterAssemblyNode , SemanticModel afterModel ) = await GetAssemblyRootNodeAndModelAsync ( _afterLoader , afterAssemblySymbol ) . ConfigureAwait ( false ) ;
120
- finalMessage += $ "Finished visiting { afterAssemblySymbol . Name } (after) in { swAssembly . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
113
+ _log . LogMessage ( $ "Visiting assembly { beforeAssemblySymbol . Name } (before vs after)...") ;
121
114
122
- // We don't care about changed assembly attributes (for now).
123
- swAssembly = Stopwatch . StartNew ( ) ;
124
- sb . Append ( VisitChildren ( beforeAssemblyNode , afterAssemblyNode , beforeModel , afterModel , ChangeType . Unchanged , wereParentAttributesChanged : false ) ) ;
125
- finalMessage += $ "Finished generating diff for { afterAssemblySymbol . Name } (before vs after) in { swAssembly . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
115
+ Stopwatch swAssembly = Stopwatch . StartNew ( ) ;
116
+ ( SyntaxNode beforeAssemblyNode , SemanticModel beforeModel ) = await GetAssemblyRootNodeAndModelAsync ( _beforeLoader , beforeAssemblySymbol ) . ConfigureAwait ( false ) ;
117
+ string finalMessage = $ "Finished visiting { beforeAssemblySymbol . Name } (before) in { swAssembly . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
126
118
127
- _log . LogMessage ( finalMessage ) ;
128
- swAssembly . Stop ( ) ;
119
+ // See if an assembly with the same name can be found in the diff folder.
120
+ if ( _afterAssemblySymbols . TryGetValue ( beforeAssemblyName , out IAssemblySymbol ? afterAssemblySymbol ) )
121
+ {
122
+ string afterAssemblyString = await ProcessAfterAssemblyAsync ( afterAssemblySymbol , beforeAssemblyNode , beforeModel ) . ConfigureAwait ( false ) ;
123
+ sb . Append ( afterAssemblyString ) ;
129
124
130
- // Remove the found ones. The remaining ones will be processed at the end because they're new.
131
- _afterAssemblySymbols . Remove ( beforeAssemblyName , out _ ) ;
132
- }
133
- else
134
- {
135
- // The assembly was removed in the diff.
136
- //sb.Append(GenerateDeletedDiff(beforeAssemblyNode));
137
- sb . Append ( VisitChildren ( beforeAssemblyNode , afterParentNode : null , beforeModel , afterModel : null , ChangeType . Deleted , wereParentAttributesChanged : false ) ) ;
138
- }
125
+ // Remove the found ones. The remaining ones will be processed at the end because they're new.
126
+ _afterAssemblySymbols . Remove ( beforeAssemblyName , out _ ) ;
127
+ }
128
+ else
129
+ {
130
+ // The assembly was removed in the diff.
131
+ //sb.Append(GenerateDeletedDiff(beforeAssemblyNode));
132
+ sb . Append ( VisitChildren ( beforeAssemblyNode , afterParentNode : null , beforeModel , afterModel : null , ChangeType . Deleted , wereParentAttributesChanged : false ) ) ;
133
+ }
139
134
140
- if ( sb . Length > 0 )
141
- {
142
- _results . TryAdd ( beforeAssemblyName , GetFinalAssemblyDiff ( beforeAssemblyName , sb . ToString ( ) ) ) ;
143
- }
135
+ if ( sb . Length > 0 )
136
+ {
137
+ _results . TryAdd ( beforeAssemblyName , GetFinalAssemblyDiff ( beforeAssemblyName , sb . ToString ( ) ) ) ;
144
138
}
145
139
}
146
140
147
- private async Task ProcessNewAssembliesAsync ( )
141
+ private async Task ProcessNewAssemblyAsync ( string afterAssemblyName , IAssemblySymbol afterAssemblySymbol )
148
142
{
149
- // Process the remaining assemblies in the diff folder.
150
- foreach ( ( string afterAssemblyName , IAssemblySymbol afterAssemblySymbol ) in _afterAssemblySymbols )
143
+ string afterAssemblyString = await ProcessAfterAssemblyAsync ( afterAssemblySymbol ) . ConfigureAwait ( false ) ;
144
+ if ( afterAssemblyString . Length > 0 )
151
145
{
152
- StringBuilder sb = new ( ) ;
153
- _log . LogMessage ( $ "Visiting *new* assembly { afterAssemblySymbol . Name } ...") ;
146
+ _results . TryAdd ( afterAssemblyName , GetFinalAssemblyDiff ( afterAssemblyName , afterAssemblyString ) ) ;
147
+ }
148
+ }
154
149
155
- var swNew = Stopwatch . StartNew ( ) ;
156
- ( SyntaxNode afterAssemblyNode , SemanticModel afterModel ) = await GetAssemblyRootNodeAndModelAsync ( _afterLoader , afterAssemblySymbol ) . ConfigureAwait ( false ) ;
157
- string finalMessage = $ "Finished visiting *new* { afterAssemblySymbol . Name } in { swNew . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
150
+ private async Task < string > ProcessAfterAssemblyAsync ( IAssemblySymbol afterAssemblySymbol , SyntaxNode ? beforeParentNode = null , SemanticModel ? beforeModel = null )
151
+ {
152
+ StringBuilder sb = new ( ) ;
153
+ var swNew = Stopwatch . StartNew ( ) ;
154
+ ( SyntaxNode afterAssemblyNode , SemanticModel afterModel ) = await GetAssemblyRootNodeAndModelAsync ( _afterLoader , afterAssemblySymbol ) . ConfigureAwait ( false ) ;
155
+ string assemblyDescriptor = beforeParentNode == null ? "new" : "existing" ;
156
+ string finalMessage = $ "Finished visiting *{ assemblyDescriptor } * assembly { afterAssemblySymbol . Name } in { swNew . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
158
157
159
- // We don't care about changed assembly attributes (for now).
160
- swNew = Stopwatch . StartNew ( ) ;
161
- sb . Append ( VisitChildren ( beforeParentNode : null , afterAssemblyNode , beforeModel : null , afterModel , ChangeType . Inserted , wereParentAttributesChanged : false ) ) ;
162
- finalMessage += $ "Finished generating diff for *new* assembly { afterAssemblySymbol . Name } in { swNew . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
158
+ swNew = Stopwatch . StartNew ( ) ;
159
+ ChangeType parentChangeType = beforeParentNode == null ? ChangeType . Inserted : ChangeType . Unchanged ;
160
+ // We don't care about changed assembly attributes (for now).
161
+ sb . Append ( VisitChildren ( beforeParentNode , afterAssemblyNode , beforeModel , afterModel , parentChangeType , wereParentAttributesChanged : false ) ) ;
162
+ finalMessage += $ "Finished generating diff for *{ assemblyDescriptor } * assembly { afterAssemblySymbol . Name } in { swNew . Elapsed . TotalMilliseconds / 1000.0 : F2} s{ Environment . NewLine } ";
163
163
164
- _log . LogMessage ( finalMessage ) ;
165
- swNew . Stop ( ) ;
164
+ _log . LogMessage ( finalMessage ) ;
165
+ swNew . Stop ( ) ;
166
166
167
- if ( sb . Length > 0 )
168
- {
169
- _results . TryAdd ( afterAssemblyName , GetFinalAssemblyDiff ( afterAssemblyName , sb . ToString ( ) ) ) ;
170
- }
171
- }
167
+ return sb . ToString ( ) ;
172
168
}
173
169
174
170
private async Task < ( SyntaxNode rootNode , SemanticModel model ) > GetAssemblyRootNodeAndModelAsync ( IAssemblySymbolLoader loader , IAssemblySymbol assemblySymbol )
@@ -317,7 +313,7 @@ private static ConcurrentDictionary<string, MemberDeclarationSyntax> CollectChil
317
313
318
314
if ( parentNode is RecordDeclarationSyntax record && record . Members . Any ( ) )
319
315
{
320
- foreach ( MemberDeclarationSyntax memberNode in record . ChildNodes ( ) . Where ( n => n is MemberDeclarationSyntax m && IsPublicOrProtectedOrDestructor ( m ) ) . Cast < MemberDeclarationSyntax > ( ) )
316
+ foreach ( MemberDeclarationSyntax memberNode in record . ChildNodes ( ) . Where ( n => n is MemberDeclarationSyntax m && IsPublicOrProtectedOrDestructor ( m ) ) . Cast < MemberDeclarationSyntax > ( ) )
321
317
{
322
318
// Note that these could also be nested types
323
319
dictionary . TryAdd ( GetDocId ( memberNode , model ) , memberNode ) ;
0 commit comments