Skip to content

Commit

Permalink
Try fix #576 (#577)
Browse files Browse the repository at this point in the history
* Try fix #576

* Update NuGet.Config
gfs authored Mar 23, 2021
1 parent 68c0dfa commit 504d072
Showing 3 changed files with 18 additions and 14 deletions.
9 changes: 6 additions & 3 deletions Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -693,16 +693,19 @@ public static List<BaseCompare> GetComparators()
}
else
{
if (c.Results.Count > 0)
if (!c.Results.IsEmpty)
{
foreach (var key in c.Results.Keys)
{
if (c.Results[key] is List<CompareResult> queue)
{
queue.AsParallel().ForAll(res =>
{
res.Rules = analyzer.Analyze(res);
res.Analysis = res.Rules.Count > 0 ? res.Rules.Max(x => x.Flag) : analyzer.DefaultLevels[res.ResultType];
if (res is not null)
{
res.Rules = analyzer.Analyze(res);
res.Analysis = res.Rules.Count > 0 ? res.Rules.Max(x => x.Flag) : analyzer.DefaultLevels[res.ResultType];
}
});
}
}
22 changes: 11 additions & 11 deletions Lib/Collectors/BaseCompare.cs
Original file line number Diff line number Diff line change
@@ -168,10 +168,10 @@ public void Compare(IEnumerable<(CollectObject, string)> differentObjects, IEnum
var firstVal = prop.GetValue(first);
var secondVal = prop.GetValue(second);

if (firstVal is List<string> && secondVal is List<string>)
if (firstVal is List<string> firstList && secondVal is List<string> secondList)
{
added = ((List<string>)secondVal).Except((List<string>)firstVal);
removed = ((List<string>)firstVal).Except((List<string>?)prop.GetValue(second));
added = secondList.Except(firstList);
removed = firstList.Except(secondList);
if (!((IEnumerable<string>)added).Any())
{
added = null;
@@ -181,10 +181,10 @@ public void Compare(IEnumerable<(CollectObject, string)> differentObjects, IEnum
removed = null;
}
}
else if (firstVal is List<KeyValuePair<string, string>> && secondVal is List<KeyValuePair<string, string>>)
else if (firstVal is List<KeyValuePair<string, string>> firstListKvp && secondVal is List<KeyValuePair<string, string>> secondListKvp)
{
added = ((List<KeyValuePair<string, string>>)secondVal).Except((List<KeyValuePair<string, string>>)firstVal);
removed = ((List<KeyValuePair<string, string>>)firstVal).Except((List<KeyValuePair<string, string>>)secondVal);
added = secondListKvp.Except(firstListKvp);
removed = firstListKvp.Except(secondListKvp);
if (!((IEnumerable<KeyValuePair<string, string>>)added).Any())
{
added = null;
@@ -194,14 +194,14 @@ public void Compare(IEnumerable<(CollectObject, string)> differentObjects, IEnum
removed = null;
}
}
else if (firstVal is Dictionary<string, string> && secondVal is Dictionary<string, string>)
else if (firstVal is Dictionary<string, string> firstDict && secondVal is Dictionary<string, string> secondDict)
{
added = ((Dictionary<string, string>)secondVal)
.Except((Dictionary<string, string>)firstVal)
added = secondDict
.Except(firstDict)
.ToDictionary(x => x.Key, x => x.Value);

removed = ((Dictionary<string, string>)firstVal)
.Except((Dictionary<string, string>)secondVal)
removed = firstDict
.Except(secondDict)
.ToDictionary(x => x.Key, x => x.Value);
if (!((IEnumerable<KeyValuePair<string, string>>)added).Any())
{
1 change: 1 addition & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>

0 comments on commit 504d072

Please sign in to comment.