Skip to content

Commit f2af06f

Browse files
authored
[Xamarin.Android.Tools.AndroidSdk] Fix a few nullability warnings (#97)
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.
1 parent 5718cd2 commit f2af06f

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

src/Xamarin.Android.Tools.AndroidSdk/AndroidVersions.cs

-22
Original file line numberDiff line numberDiff line change
@@ -184,26 +184,4 @@ static bool MatchesId (AndroidVersion version, string id)
184184
},
185185
};
186186
}
187-
188-
class EqualityComparer<T> : IEqualityComparer<T>
189-
{
190-
Func<T, T, bool> equals;
191-
Func<T, int> getHashCode;
192-
193-
public EqualityComparer (Func<T, T, bool> equals, Func<T, int>? getHashCode = null)
194-
{
195-
this.equals = equals;
196-
this.getHashCode = getHashCode ?? (v => v?.GetHashCode () ?? 0);
197-
}
198-
199-
public bool Equals (T x, T y)
200-
{
201-
return equals (x, y);
202-
}
203-
204-
public int GetHashCode (T obj)
205-
{
206-
return getHashCode (obj);
207-
}
208-
}
209187
}

src/Xamarin.Android.Tools.AndroidSdk/JdkInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -492,9 +492,9 @@ class JdkInfoVersionComparer : IComparer<JdkInfo>
492492
{
493493
public static readonly IComparer<JdkInfo> Default = new JdkInfoVersionComparer ();
494494

495-
public int Compare (JdkInfo x, JdkInfo y)
495+
public int Compare ([AllowNull]JdkInfo x, [AllowNull]JdkInfo y)
496496
{
497-
if (x.Version != null && y.Version != null)
497+
if (x?.Version != null && y?.Version != null)
498498
return x.Version.CompareTo (y.Version);
499499
return 0;
500500
}

0 commit comments

Comments
 (0)