UltravioletFramework / ultraviolet

The Ultraviolet Framework is a .NET game development framework written in C#.
https://github.com/UltravioletFramework/ultraviolet/wiki
MIT License
541 stars 46 forks source link

Allow user application code to live in csproj projects #154

Closed jayrulez closed 1 year ago

jayrulez commented 1 year ago

Currently, user application code has to be implemented in a shared .shproj project. This is necessary because the application entry point UltravioletApplication has a separate implementation for different platforms (currently NETCore and Android). The user entry point projects "includes" the types in the .shproj and resolves the correct base version.

If we wanted to have the user application in a csproj, we would need to do a lot of hacky stuff in the csproj file and preprocessor checks in the .cs file.

An alternative approach would be to introduce a new application adapter base type for user application code. This class would mirror all the lifecycle methods from the UltravioletApplication classes. The UltravioletApplication class would call the lifecycle methods on an instance of the new class. It would be necessary to allow the new application adapter to configure the context to avoid some code duplication code in the application entry point projects. We could add a new abstract method to create the context configuration in the UltravioletApplication classes. The configuration instance could be passed to an internal method on the new adapter class. This internal method could call a virtual method for modifying the configuration.

jayrulez commented 1 year ago

Fixed in https://github.com/UltravioletFramework/ultraviolet/commit/496208abe3bb6b81122cfe636950a8ab1d72b809