-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove
Refresh.Analyzers
project (#531)
Closes #528 and closes #88. `Refresh.Analyzers` has been causing issues since it was implemented. Whether it be `CodeAnalysis.CSharp` updating and breaking workflows, the challenge that comes with implementing new events, or causing hacky naming in `EventType`, it's never been good and probably never will be. It was intended to alleviate copy+pasting when making new events but it's caused more pain than it's helped. So, let's just remove it. To do this I copied the output of the generated classes, cleaned them up a bit to keep things more in-line with the rest of the codebase, moved the database partials for recent activity to their own subfolder, and then deleted the `Refresh.Analyzers` project entirely. I also took the opportunity to fix the somewhat cursed naming of the `EventType` enum for consistency.
- Loading branch information
Showing
13 changed files
with
331 additions
and
274 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Refresh.GameServer/Database/Activity/GameDatabaseContext.ActivityRead.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Diagnostics; | ||
using Refresh.GameServer.Types.Activity; | ||
using Refresh.GameServer.Types.Levels; | ||
using Refresh.GameServer.Types.Relations; | ||
using Refresh.GameServer.Types.UserData; | ||
using Refresh.GameServer.Types.UserData.Leaderboard; | ||
|
||
namespace Refresh.GameServer.Database; | ||
|
||
public partial class GameDatabaseContext // ActivityRead | ||
{ | ||
public GameUser? GetUserFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.User) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.User)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this.GetUserByObjectId(e.StoredObjectId); | ||
} | ||
|
||
public GameLevel? GetLevelFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.Level) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.Level)})"); | ||
|
||
Debug.Assert(e.StoredSequentialId != null); | ||
|
||
return this.GetLevelById(e.StoredSequentialId.Value); | ||
} | ||
|
||
public GameSubmittedScore? GetScoreFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.Score) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.Score)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this.GetScoreByObjectId(e.StoredObjectId); | ||
} | ||
|
||
public RateLevelRelation? GetRateLevelRelationFromEvent(Event e) | ||
{ | ||
if (e.StoredDataType != EventDataType.RateLevelRelation) | ||
throw new InvalidOperationException($"Event does not store the correct data type (expected {nameof(EventDataType.RateLevelRelation)})"); | ||
|
||
Debug.Assert(e.StoredObjectId != null); | ||
|
||
return this._realm.All<RateLevelRelation>() | ||
.FirstOrDefault(l => l.RateLevelRelationId == e.StoredObjectId); | ||
} | ||
} |
Oops, something went wrong.