Skip to content

Commit a294ae9

Browse files
authored
Fix all warnings in solution and begin treating warnings as errors (#780)
I'm a bit skeptical of treating warnings as error in the database project until Postgres is complete, but we'll see how that goes. Most of the warnings in source generated code seem to resolve if you disable nullables in the file, so I've done that for all models that were causing warnings. Worst case, we can disable this for `Refresh.Database` if it starts causing issues.
2 parents 3ecc958 + 7693fcd commit a294ae9

28 files changed

Lines changed: 66 additions & 18 deletions

Refresh.Common/Refresh.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
78
</PropertyGroup>
89

910
<ItemGroup>

Refresh.Database/GameDatabaseProvider.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,4 @@ protected override void Migrate(Migration migration, ulong oldVersion)
841841
// }
842842
}
843843
#endif
844-
845-
public void Dispose()
846-
{
847-
GC.SuppressFinalize(this);
848-
}
849844
}

Refresh.Database/Models/Assets/GameAssetType.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ public enum GameAssetType
410410

411411
public static class GameAssetTypeExtensions
412412
{
413-
private static readonly Dictionary<int, GameAssetType> _lbpMagics = new()
413+
private static readonly Dictionary<int, GameAssetType> LbpMagics = new()
414414
{
415415
{ BinaryPrimitives.ReadInt32BigEndian("TEX\0"u8), GameAssetType.Texture },
416416
{ BinaryPrimitives.ReadInt32BigEndian("GTF\0"u8), GameAssetType.GameDataTexture },
@@ -477,13 +477,13 @@ public static class GameAssetTypeExtensions
477477
{
478478
int magicInt = magic[0] << 24 | magic[1] << 16 | magic[2] << 8;
479479

480-
if (!_lbpMagics.TryGetValue(magicInt, out GameAssetType assetType))
480+
if (!LbpMagics.TryGetValue(magicInt, out GameAssetType assetType))
481481
return null;
482482

483483
return assetType;
484484
}
485485

486-
public static string Magic(this GameAssetType type)
486+
public static string? LbpMagic(this GameAssetType type)
487487
{
488488
return type switch
489489
{
@@ -546,6 +546,9 @@ public static string Magic(this GameAssetType type)
546546
GameAssetType.CachedCostumeData => "CCD",
547547
GameAssetType.DataLabels => "DLA",
548548
GameAssetType.AdventureMaps => "ADM",
549+
GameAssetType.GriefSongState => "MATT",
550+
GameAssetType.ChallengeGhost => "<ghost>",
551+
_ => null,
549552
};
550553
}
551554
}

Refresh.Database/Models/Comments/GameLevelComment.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace Refresh.Database.Models.Comments;
55

6+
#nullable disable
7+
68
public partial class GameLevelComment : IRealmObject, IGameComment, ISequentialId
79
{
810
[PrimaryKey] public int SequentialId { get; set; }

Refresh.Database/Models/Comments/GameProfileComment.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Refresh.Database.Models.Comments;
44

5+
#nullable disable
6+
57
public partial class GameProfileComment : IRealmObject, IGameComment, ISequentialId
68
{
79
[PrimaryKey] public int SequentialId { get; set; }

Refresh.Database/Models/Photos/GamePhotoSubject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ namespace Refresh.Database.Models.Photos;
77
[XmlType("subject")]
88
public class GamePhotoSubject
99
{
10+
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring as nullable.
11+
[Obsolete("used for serialization. XML stuff should be moved to SerializedGamePhotoSubject", true)]
1012
public GamePhotoSubject() {}
1113

1214
public GamePhotoSubject(GameUser? user, string displayName, IList<float> bounds)

Refresh.Database/Models/Playlists/GamePlaylist.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Refresh.Database.Models.Playlists;
44

5+
#nullable disable
6+
57
/// <summary>
68
/// A user-curated list of levels.
79
/// </summary>

Refresh.Database/Models/Relations/LevelCommentRelation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Refresh.Database.Models.Relations;
66

7+
#nullable disable
8+
79
public partial class LevelCommentRelation : IRealmObject, ICommentRelation<GameLevelComment>
810
{
911
public ObjectId CommentRelationId { get; set; } = ObjectId.GenerateNewId();

Refresh.Database/Models/Relations/ProfileCommentRelation.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Refresh.Database.Models.Relations;
66

7+
#nullable disable
8+
79
public partial class ProfileCommentRelation : IRealmObject, ICommentRelation<GameProfileComment>
810
{
911
public ObjectId CommentRelationId { get; set; } = ObjectId.GenerateNewId();

Refresh.Database/Models/Relations/RateReviewRelation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
namespace Refresh.Database.Models.Relations;
55

6+
#nullable disable
7+
68
public partial class RateReviewRelation : IRealmObject
79
{
810
// we could just reuse RatingType from GameLevel rating logic
@@ -13,6 +15,7 @@ public RatingType RatingType
1315
set => this._ReviewRatingType = (int)value;
1416
}
1517

18+
// ReSharper disable once InconsistentNaming
1619
public int _ReviewRatingType { get; set; }
1720
public GameReview Review { get; set; }
1821

0 commit comments

Comments
 (0)