Skip to content

Commit

Permalink
[Xamarin.Android.Tools.AndroidSdk] Fix a few nullability warnings (#97)
Browse files Browse the repository at this point in the history
Fixes a few Nullable Reference Type (NRT) warnings in
`JdkInfoVersionComparer`.

There are also some NRT warnings in `EqualityComparer<T>`, but this
class is `private` and not used anywhere; remove it instead.
  • Loading branch information
jpobst committed Sep 25, 2020
1 parent 5718cd2 commit f2af06f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
22 changes: 0 additions & 22 deletions src/Xamarin.Android.Tools.AndroidSdk/AndroidVersions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,4 @@ static bool MatchesId (AndroidVersion version, string id)
},
};
}

class EqualityComparer<T> : IEqualityComparer<T>
{
Func<T, T, bool> equals;
Func<T, int> getHashCode;

public EqualityComparer (Func<T, T, bool> equals, Func<T, int>? getHashCode = null)
{
this.equals = equals;
this.getHashCode = getHashCode ?? (v => v?.GetHashCode () ?? 0);
}

public bool Equals (T x, T y)
{
return equals (x, y);
}

public int GetHashCode (T obj)
{
return getHashCode (obj);
}
}
}
4 changes: 2 additions & 2 deletions src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ class JdkInfoVersionComparer : IComparer<JdkInfo>
{
public static readonly IComparer<JdkInfo> Default = new JdkInfoVersionComparer ();

public int Compare (JdkInfo x, JdkInfo y)
public int Compare ([AllowNull]JdkInfo x, [AllowNull]JdkInfo y)
{
if (x.Version != null && y.Version != null)
if (x?.Version != null && y?.Version != null)
return x.Version.CompareTo (y.Version);
return 0;
}
Expand Down

0 comments on commit f2af06f

Please sign in to comment.