@@ -262,17 +262,17 @@ private static ASA_ERROR RunExportGuidedCommand(ExportGuidedCommandOptions opts)
262262 return ExportCompareResults ( results , exportOptions , AsaHelpers . MakeValidFileName ( $ "{ first } _vs_{ second } ") , analysesHash , options . AnalysesFile . Rules ) ;
263263 }
264264
265- static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > AnalyzeGuided ( GuidedModeCommandOptions opts , RuleFile analysisFile )
265+ static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > AnalyzeGuided ( GuidedModeCommandOptions opts , RuleFile analysisFile )
266266 {
267267 if ( opts . RunId is null )
268268 {
269269 Log . Warning ( Strings . Get ( "Err_RunIdNull" ) ) ;
270- return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ;
270+ return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ;
271271 }
272272 if ( ! analysisFile . Rules . Any ( ) )
273273 {
274274 Log . Warning ( Strings . Get ( "Err_NoRules" ) ) ;
275- return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ;
275+ return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ;
276276 }
277277
278278 var firstCollectRunId = GuidedRunIdToFirstCollectRunId ( opts . RunId ) ;
@@ -318,22 +318,22 @@ private static ASA_ERROR RunExportGuidedCommand(ExportGuidedCommandOptions opts)
318318 return results ;
319319 }
320320
321- public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > AnalyzeMonitored ( CompareCommandOptions opts )
321+ public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > AnalyzeMonitored ( CompareCommandOptions opts )
322322 {
323323 if ( DatabaseManager is null )
324324 {
325325 Log . Error ( "Err_DatabaseManagerNull" , "InsertCompareResults" ) ;
326- return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ;
326+ return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ;
327327 }
328- if ( opts is null || opts . SecondRunId is null ) { return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ; }
328+ if ( opts is null || opts . SecondRunId is null ) { return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ; }
329329 var analyzer = new AsaAnalyzer ( new AnalyzerOptions ( opts . RunScripts ) ) ;
330330 return AnalyzeMonitored ( opts , analyzer , DatabaseManager . GetMonitorResults ( opts . SecondRunId ) , opts . AnalysesFile ?? throw new ArgumentNullException ( nameof ( opts . AnalysesFile ) ) ) ;
331331 }
332332
333- public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > AnalyzeMonitored ( CompareCommandOptions opts , AsaAnalyzer analyzer , IEnumerable < MonitorObject > collectObjects , RuleFile ruleFile )
333+ public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > AnalyzeMonitored ( CompareCommandOptions opts , AsaAnalyzer analyzer , IEnumerable < MonitorObject > collectObjects , RuleFile ruleFile )
334334 {
335- if ( opts is null ) { return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ; }
336- var results = new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ;
335+ if ( opts is null ) { return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ; }
336+ var results = new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ;
337337 var analysesHash = ruleFile . GetHash ( ) ;
338338 Parallel . ForEach ( collectObjects , monitorResult =>
339339 {
@@ -362,7 +362,7 @@ private static ASA_ERROR RunExportGuidedCommand(ExportGuidedCommandOptions opts)
362362 }
363363
364364 shellResult . Analysis = shellResult . Rules . Count > 0 ? shellResult . Rules . Max ( x => ( ( AsaRule ) x ) . Flag ) : ruleFile . GetDefaultLevel ( shellResult . ResultType ) ;
365- results . TryAdd ( ( monitorResult . ResultType , monitorResult . ChangeType ) , new List < CompareResult > ( ) ) ;
365+ results . TryAdd ( ( monitorResult . ResultType , monitorResult . ChangeType ) , new ConcurrentBag < CompareResult > ( ) ) ;
366366 results [ ( monitorResult . ResultType , monitorResult . ChangeType ) ] . Add ( shellResult ) ;
367367 } ) ;
368368 return results ;
@@ -389,7 +389,7 @@ private static ASA_ERROR RunVerifyRulesCommand(VerifyOptions opts)
389389 return ASA_ERROR . NONE ;
390390 }
391391
392- internal static void InsertCompareResults ( ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > results , string ? FirstRunId , string SecondRunId , string AnalysesHash )
392+ internal static void InsertCompareResults ( ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > results , string ? FirstRunId , string SecondRunId , string AnalysesHash )
393393 {
394394 if ( DatabaseManager is null )
395395 {
@@ -399,9 +399,9 @@ internal static void InsertCompareResults(ConcurrentDictionary<(RESULT_TYPE, CHA
399399 DatabaseManager . InsertCompareRun ( FirstRunId , SecondRunId , AnalysesHash , RUN_STATUS . RUNNING ) ;
400400 foreach ( var key in results . Keys )
401401 {
402- if ( results . TryGetValue ( key , out List < CompareResult > ? obj ) )
402+ if ( results . TryGetValue ( key , out ConcurrentBag < CompareResult > ? obj ) )
403403 {
404- if ( obj is List < CompareResult > Queue )
404+ if ( obj is ConcurrentBag < CompareResult > Queue )
405405 {
406406 foreach ( var result in Queue )
407407 {
@@ -627,7 +627,7 @@ private static ASA_ERROR RunExportCollectCommand(ExportCollectCommandOptions opt
627627 return ExportCompareResults ( results , opts , AsaHelpers . MakeValidFileName ( opts . FirstRunId + "_vs_" + opts . SecondRunId ) , analysesHash , ruleFile . Rules ) ;
628628 }
629629
630- internal static ASA_ERROR ExportCompareResults ( ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > resultsIn , ExportOptions opts , string baseFileName , string analysesHash , IEnumerable < AsaRule > rules )
630+ internal static ASA_ERROR ExportCompareResults ( ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > resultsIn , ExportOptions opts , string baseFileName , string analysesHash , IEnumerable < AsaRule > rules )
631631 {
632632 var results = resultsIn . Select ( x => new KeyValuePair < string , object > ( $ "{ x . Key . Item1 } _{ x . Key . Item2 } ", x . Value ) ) . ToDictionary ( x => x . Key , x => x . Value ) ;
633633 JsonSerializer serializer = JsonSerializer . Create ( new JsonSerializerSettings ( )
@@ -1125,7 +1125,7 @@ public static List<BaseCompare> GetComparators()
11251125 return comparators ;
11261126 }
11271127
1128- public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > CompareRuns ( CompareCommandOptions opts )
1128+ public static ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > CompareRuns ( CompareCommandOptions opts )
11291129 {
11301130 if ( opts is null )
11311131 {
@@ -1134,7 +1134,7 @@ public static List<BaseCompare> GetComparators()
11341134 if ( DatabaseManager is null )
11351135 {
11361136 Log . Error ( "Err_DatabaseManagerNull" , "CompareRuns" ) ;
1137- return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , List < CompareResult > > ( ) ;
1137+ return new ConcurrentDictionary < ( RESULT_TYPE , CHANGE_TYPE ) , ConcurrentBag < CompareResult > > ( ) ;
11381138 }
11391139 comparators = new List < BaseCompare > ( ) ;
11401140
@@ -1177,8 +1177,12 @@ public static List<BaseCompare> GetComparators()
11771177 {
11781178 foreach ( ( RESULT_TYPE , CHANGE_TYPE ) key in c . Results . Keys )
11791179 {
1180- if ( c . Results [ key ] is List < CompareResult > queue )
1180+ if ( c . Results [ key ] is IEnumerable < CompareResult > queue )
11811181 {
1182+ if ( queue . Any ( x => x is null ) )
1183+ {
1184+ Console . WriteLine ( "found em" ) ;
1185+ }
11821186 IEnumerable < AsaRule > platformRules = opts . AnalysesFile . Rules . Where ( rule => rule . Platforms == null || rule . Platforms . Contains ( platform ) ) ;
11831187 if ( opts . SingleThreadAnalysis )
11841188 {
@@ -1200,6 +1204,10 @@ void PopulateAnalysisForResult(CompareResult res)
12001204 var selectedRules = platformRules . Where ( ( rule ) =>
12011205 ( rule . ChangeTypes == null || rule . ChangeTypes . Contains ( res . ChangeType ) )
12021206 && ( rule . ResultType == res . ResultType ) ) ;
1207+ if ( res is null )
1208+ {
1209+ return ;
1210+ }
12031211 Log . Verbose ( "Type: {0}" , res . ResultType ) ;
12041212 Log . Verbose ( "Base: {0}" , JsonConvert . SerializeObject ( res . Base ) ) ;
12051213 Log . Verbose ( "Compare: {0}" , JsonConvert . SerializeObject ( res . Compare ) ) ;
0 commit comments