Skip to content

Commit

Permalink
Add some more tests for RID related types
Browse files Browse the repository at this point in the history
  • Loading branch information
ericstj committed Mar 24, 2021
1 parent 7916e11 commit c537d55
Show file tree
Hide file tree
Showing 7 changed files with 1,380 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ private void AddInferredRuntimeIdentifiers(ICollection<RuntimeGroup> runtimeGrou
continue;
}

if (!rid.HasVersion())
{
closestGroup = candidate;
continue;
}

foreach(var version in candidate.Versions)
{
if (closestVersion == null ||
Expand Down Expand Up @@ -344,7 +350,7 @@ private void AddInferredRuntimeIdentifiers(ICollection<RuntimeGroup> runtimeGrou
candidateRuntimeGroups.Add(runtimeGroup);

}
else if (closestVersion != rid.Version)
else if (rid.HasVersion() && closestVersion != rid.Version)
{
closestGroup.Versions.Add(rid.Version);
}
Expand Down
10 changes: 8 additions & 2 deletions src/Microsoft.DotNet.Build.Tasks.Packaging/src/RuntimeVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public int CompareTo(object obj)

public int CompareTo(RuntimeVersion other)
{
int versionResult = version.CompareTo(other.version);
if (other == null)
{
return 1;
}

int versionResult = version.CompareTo(other?.version);

if (versionResult == 0)
{
Expand All @@ -73,7 +78,8 @@ public int CompareTo(RuntimeVersion other)
public bool Equals(RuntimeVersion other)
{
return object.ReferenceEquals(other, this) ||
versionString.Equals(other.versionString, StringComparison.Ordinal);
(other != null &&
versionString.Equals(other.versionString, StringComparison.Ordinal));
}

public override bool Equals(object obj)
Expand Down
Loading

0 comments on commit c537d55

Please sign in to comment.