refactor: remove some warnings

This commit is contained in:
2022-12-17 18:58:37 +04:00
parent a9be230960
commit 13044357a5
2 changed files with 67 additions and 65 deletions
+3 -2
View File
@@ -1,11 +1,12 @@
using System.Diagnostics.CodeAnalysis;
using Ragon.Core.Game; using Ragon.Core.Game;
namespace Ragon.Core.Lobby; namespace Ragon.Core.Lobby;
public interface ILobby public interface ILobby
{ {
public bool FindRoomById(string roomId, out Room room); public bool FindRoomById(string roomId, [MaybeNullWhen(false)] out Room room);
public bool FindRoomByMap(string map, out Room room); public bool FindRoomByMap(string map, [MaybeNullWhen(false)] out Room room);
public void Persist(Room room); public void Persist(Room room);
public void Remove(Room room); public void Remove(Room room);
} }
+5 -4
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using NLog; using NLog;
using Ragon.Core.Game; using Ragon.Core.Game;
@@ -9,7 +10,7 @@ public class LobbyInMemory: ILobby
private readonly List<Room> _rooms = new(); private readonly List<Room> _rooms = new();
private readonly Logger _logger = LogManager.GetCurrentClassLogger(); private readonly Logger _logger = LogManager.GetCurrentClassLogger();
public bool FindRoomById(string roomId, out Room room) public bool FindRoomById(string roomId, [MaybeNullWhen(false)] out Room room)
{ {
foreach (var existRoom in _rooms) foreach (var existRoom in _rooms)
{ {
@@ -21,11 +22,11 @@ public class LobbyInMemory: ILobby
} }
} }
room = null; room = default;
return false; return false;
} }
public bool FindRoomByMap(string map, out Room room) public bool FindRoomByMap(string map, [MaybeNullWhen(false)] out Room room)
{ {
foreach (var existRoom in _rooms) foreach (var existRoom in _rooms)
{ {
@@ -37,7 +38,7 @@ public class LobbyInMemory: ILobby
} }
} }
room = null; room = default;
return false; return false;
} }