Dereference of a possibly null reference x10
continuous-integration/drone/push Build is passing Details

test_old_branch
Jules LASCRET 11 months ago
parent 76271c06a7
commit b35512d8b1

@ -1,13 +1,5 @@
using System; using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Collections;
using System.Collections.Immutable;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using QwirkleClassLibrary.Tiles; using QwirkleClassLibrary.Tiles;
using QwirkleClassLibrary.Boards; using QwirkleClassLibrary.Boards;
@ -270,7 +262,7 @@ namespace QwirkleClassLibrary.Games
{ {
if (bag != null && p.Tiles.Count < 6) if (bag != null && p.Tiles.Count < 6)
{ {
int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag.Count); int val = RandomNumberGenerator.GetInt32(0, bag.TilesBag!.Count);
p.AddTileToPlayer(bag.TilesBag[val]); p.AddTileToPlayer(bag.TilesBag[val]);
bag.RemoveTileInBag(bag.TilesBag[val]); bag.RemoveTileInBag(bag.TilesBag[val]);
@ -362,7 +354,7 @@ namespace QwirkleClassLibrary.Games
{ {
while (player.Tiles.Count < 6) while (player.Tiles.Count < 6)
{ {
if (bag!.TilesBag.Count == 0) if (bag!.TilesBag!.Count == 0)
{ {
return false; return false;
} }
@ -396,7 +388,7 @@ namespace QwirkleClassLibrary.Games
return false; return false;
} }
if (bag!.TilesBag.Count < tilesToSwap.Count) if (bag!.TilesBag!.Count < tilesToSwap.Count)
{ {
OnSwapTiles(new SwapTilesNotifiedEventArgs("Not enough tiles in the bag to swap !")); OnSwapTiles(new SwapTilesNotifiedEventArgs("Not enough tiles in the bag to swap !"));
return false; return false;
@ -733,7 +725,7 @@ namespace QwirkleClassLibrary.Games
{ {
List<int> playerTilesBagPos = []; List<int> playerTilesBagPos = [];
if (bag!.TilesBag.Count == 0) if (bag!.TilesBag!.Count == 0)
{ {
for (int i = 0; i < players.Count; i++) for (int i = 0; i < players.Count; i++)
{ {
@ -785,7 +777,7 @@ namespace QwirkleClassLibrary.Games
{ {
List<int> playerTilesBagPos = CheckTilesBag(); List<int> playerTilesBagPos = CheckTilesBag();
if (playerTilesBagPos.Count != 0 && !CheckPlacementPossibilities(playerTilesBagPos) || bag!.TilesBag.Count == 0 && players[GetPlayingPlayerPosition()].Tiles.Count==0) if (playerTilesBagPos.Count != 0 && !CheckPlacementPossibilities(playerTilesBagPos) || bag!.TilesBag!.Count == 0 && players[GetPlayingPlayerPosition()].Tiles.Count==0)
{ {
OnEndOfGame(new EndOfGameNotifiedEventArgs(player)); OnEndOfGame(new EndOfGameNotifiedEventArgs(player));
GameRunning = false; GameRunning = false;

@ -11,10 +11,10 @@ public class TestPlayers
{ {
if (!isValid) if (!isValid)
{ {
Assert.Throws<ArgumentNullException>(() => new Player(playertag)); Assert.Throws<ArgumentNullException>(() => new Player(playertag!));
return; return;
} }
Player player = new Player(playertag); Player player = new Player(playertag!);
Assert.Equal(playertag, player.NameTag); Assert.Equal(playertag, player.NameTag);
} }

@ -16,7 +16,7 @@ public class TestTileBag
return; return;
} }
TileBag bag = new TileBag(nbset); TileBag bag = new TileBag(nbset);
Assert.Equal(bag.TilesBag.Count, nbset * 36); Assert.Equal(bag.TilesBag!.Count, nbset * 36);
} }
@ -30,11 +30,11 @@ public class TestTileBag
if (except) if (except)
{ {
Assert.True(bag.RemoveTileInBag(bag.TilesBag[1])); Assert.True(bag.RemoveTileInBag(bag.TilesBag![1]));
return; return;
} }
Tile tile = bag.TilesBag[0]; Tile tile = bag.TilesBag![0];
bag.RemoveTileInBag(tile); bag.RemoveTileInBag(tile);
Assert.False(bag.RemoveTileInBag(tile)); Assert.False(bag.RemoveTileInBag(tile));

Loading…
Cancel
Save