wabbajack-tools / wabbajack

An automated Modlist installer for various games.
https://www.wabbajack.org/
Other
737 stars 139 forks source link

Balzor Related Wiki Page #2196

Open EzioTheDeadPoet opened 1 year ago

EzioTheDeadPoet commented 1 year ago

Wabbajack has a code problem, mainly that most of the libraries require net5.0-windows instead of net5.0. In addition, most of our libraries are Windows specific to a very low level. This is a general plan/braindump of how to restructure the app to be more cross platform.

EzioTheDeadPoet commented 1 year ago

Since I don't know if this has still any relevance I moved it form the wiki into an issue that can be closed.

This is so that I can also add the wiki to the main repository, mainly because it is easier to find for most people if the wiki is located there.

erri120 commented 1 year ago

You can ditch netX.0-windows by using the [SupportedOSPlatform]("windows") attribute on classes/methods that are OS specific or RuntimeInformation.IsOSPlatform(OSPlatform.Windows) in functions to provide different behaviors.

This is what I've done with GameFinder and now every GameFinder package targets net6.0/net7.0. Instead of directly accessing the Windows registry I created an interface IRegistry and guarded the Windows specific implementation behind an [SupportedOSPlatform("windows")]: https://github.com/erri120/GameFinder/blob/2c39db4ca3c1eca255774f53db2dd9b75ffa95f6/GameFinder.RegistryUtils/WindowsRegistry.cs

This also made testing easier since I can now create an In-Memory registry without any issues.

I used RuntimeInformation.IsOSPlatform for the Steam package since Steam official supports Linux: https://github.com/erri120/GameFinder/blob/2c39db4ca3c1eca255774f53db2dd9b75ffa95f6/GameFinder.StoreHandlers.Steam/SteamHandler.cs#L171-L189

More infos here: https://learn.microsoft.com/en-us/dotnet/standard/analyzers/platform-compat-analyzer