-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added: Ability to restrict which games we ship the Application with for Release Builds #1401
Conversation
fixes #1367 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really dislike this design. The issue #1367, which this PR was supposed to resolve, is about not showing any other game than Stardew Valley in the UI. Why did you use compile constants to hack project references instead of just having a simple check in the UI to now show any other game besides Stardew Valley?
This could've been a one line PR, instead this is a hacky and unmaintainable solution which doesn't just exclude games from the UI, but from the entire build process.
I'm vehemently against this approach.
Edit: I need to note that I forgot to push a commit before PR-ing this, so I fixed that now. I will agree that
I've been hearing that we're going to be enabling games one by one. I know that has no bearing on the suggested approach, but it's part of the reason why I did things this way.
Why is this solution hacky and unmaintainable? The process of adding a game (compared to before) involves the following extra lines:
That's it. In addition we get to keep the previously undocumented overrides such as And no,
I chose to not compile the other projects, yes. I did it simply to avoid shipping dead code, so our precious end users trying the Alpha can get set up and running faster. If you really want to be pedantic about it however, I could:
Then the 'eyesore' of a bunch of
No, because there are certain places in the App where we may use the likes of dependency injection to obtain collections of entities. Or, otherwise operate on DI injected entities. Some examples:
And there may be more locations. The easiest way to prevent that is simply not adding the games in the first place, which I chose to do here. Yes, you may argue that the ticket text refers to the UI if you want to be really, really pedantic about it. However, the intent is:
If I were to leave such gaping holes in the implementation such as allowing people to interact with 'unsupported' games via the CLI, then I'm not doing a good enough job. |
@erri120 Can you go into more detail on the problems this will cause? Compile time switches for disabling modules is fairly common in a lot of applications. In the future we may want more options than just "Debug" or "Release" but that also is rather maintainable. Looking at this code, adding a new game will require adding abour 4-5 lines of code. I guess I'm not understanding where the hacks or unmaintainability comes into play here. |
The Our IDE isn't the only place where these issues will pop up. Our build pipelines all use different configurations. The CI that runs on each PR uses I'm calling conditional compilation unmaintainable because you have to test each and every compilation configuration to determine whether the code compiles correctly and does what it's supposed to do. In contrast, using C# As for this being "hacky", preprocessor directives are rarely a good choice, and never the only one. I regret adding Let's talk about alternatives. As mentioned before, this PR is trying to resolve #1367:
For the alpha release, we want an "on rails"-experience, meaning users can only interact and use the things we want them to test. In this case, we want users to manage Stardew Valley from the UI, not Skyrim, or Cyberpunk, or Sifu. To remove other games from the UI, it's a one-line change: NexusMods.App/src/NexusMods.App.UI/Pages/MyGames/MyGamesViewModel.cs Lines 59 to 60 in 0c8f1f9
var foundGames = gameRegistry.InstalledGames
.ToObservableChangeSet()
.Filter(x => x.Game.Domain != "stardewvalley"); Of course there should be a comment here linking to #1367, and similar with #1286, this could also have a setting. Either way, we only want Stardew Valley to appear in the UI, @Sewer56 mentioned that this affect the CLI, and I honestly don't think we care. If a user uses the CLI, then they're off the rails anyways. No point in adding restrictions there. If you really wanna keep conditional compilation, then I might be amenable to these changes if we remove all the custom Lastly, I believe the correct approach should be either settings, or feature flags using tools the other teams are already using, namely Unleash. Although, feature flags don't really make a ton of sense in non-web applications, we should definitely consider them if we run into something like this again. |
I have to note, that this was actually unrelated to the PR.
But at the top of the file, you have only
If you had your project set to It wasn't something I had to do, I just noticed it and fixed it. Not to detract from the statement made, because it's a good example of how improper use of conditional compilation can break stuff. In any case, the idea I had in mind when writing this code was that:
That means that Debug is a superset of Release. I would also recommend that any conditional code should also inline the namespaces if it introduces additional imports: // Namespace prevents invalid cleanup on 'remove unused using statements'
Games.BethesdaGameStudios.Services.AddBethesdaGameStudios() What we must not do is disable code using directives, because that creates additional combinations of flags that would have to be tested in CI. And doing that is in fact not fun to maintain as @erri120 stated, but I am not doing that here. I really do not want to be doing that. The number of combinations remains 2; and one is a superset of the other. I could also change the directives in the code to be in the form |
Just remove the |
Eh, sure. Gimme a moment. |
Thanks for the details @erri120, and I agree, stuff like this was the reason why we ditched Vogen. In that vein, we should proabably do the following: @Sewer56 so we're all on the same page
|
0d44229
to
4f4ee86
Compare
4f4ee86
to
1b4ba1b
Compare
This PR introduces the ability to selectively enable or disable games from our Release builds.
We do this by straight up not compiling them into the App with the use of compile-time constants.
Changes (Summary)
Added a new
Directory.Build.targets
file to define compile-time constants across projects.Updated the
NexusMods.App.csproj
file to only include project references when the relevant constants are defined.Moved conditionally enabled games to
AddSupportedGames
inServices
class to keep things cleaner.Removed some unused
using
directives in startup project.Resolved cases where NuGet package(s) of now conditionally enabled projects were being imported transitively in tests, rather than directly. (Fix Build Errors)
Added missing
DEBUG
conditional inMainThreadData.cs
which would cause compile errors if unused using(s) were removed.Note
We couldn't use
Directory.Build.props
, it seems the constants we define there are overwritten further down the road, so I instead added aDirectory.Build.targets
file as that comes later down the build logic.