Make ModelExtensions nullable enabled

This commit is contained in:
Dean Herbert 2021-11-15 14:38:01 +09:00
parent 0b4822b552
commit 18f73b985b

View File

@ -7,6 +7,8 @@ using osu.Game.Rulesets;
using osu.Game.Scoring;
using osu.Game.Users;
#nullable enable
namespace osu.Game.Extensions
{
public static class ModelExtensions
@ -23,9 +25,9 @@ namespace osu.Game.Extensions
/// extension method type inference rules cause this method to call itself and cause a stack overflow.
/// </para>
/// </remarks>
public static string GetDisplayString(this object model)
public static string GetDisplayString(this object? model)
{
string result = null;
string? result = null;
switch (model)
{
@ -65,8 +67,11 @@ namespace osu.Game.Extensions
/// <param name="instance">The instance to compare.</param>
/// <param name="other">The other instance to compare against.</param>
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
public static bool MatchesOnlineID(this IHasOnlineID<long> instance, IHasOnlineID<long> other)
public static bool MatchesOnlineID(this IHasOnlineID<long>? instance, IHasOnlineID<long>? other)
{
if (instance == null || other == null)
return false;
if (instance.OnlineID < 0 || other.OnlineID < 0)
return false;
@ -79,8 +84,11 @@ namespace osu.Game.Extensions
/// <param name="instance">The instance to compare.</param>
/// <param name="other">The other instance to compare against.</param>
/// <returns>Whether online IDs match. If either instance is missing an online ID, this will return false.</returns>
public static bool MatchesOnlineID(this IHasOnlineID<int> instance, IHasOnlineID<int> other)
public static bool MatchesOnlineID(this IHasOnlineID<int>? instance, IHasOnlineID<int>? other)
{
if (instance == null || other == null)
return false;
if (instance.OnlineID < 0 || other.OnlineID < 0)
return false;