Skip to content
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

Prefix Almost Everything #39

Merged
merged 4 commits into from
Oct 1, 2022

Conversation

ds5678
Copy link
Collaborator

@ds5678 ds5678 commented Jul 28, 2022

Game developers often use the global namespace and external libraries when making their games. For modding, this can cause conflicts during mod development. Although we currently have a way to prefix assemblies and namespaces, it's an opt-in system. An opt-out solution would be better because mod loaders can't anticipate all the assemblies game communities might want to prefix. By prefixing everything but UnityEditor and UnityEngine, we can prevent all potential conflicts between generated interop and managed libraries.

Copy link
Member

@Kasuromi Kasuromi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems like it would break current interop assembly usage. It would require everyone to update their code to use the new prefix.

Some games have 100s of assemblies and are constantly growing. If someone wanted to preserve functionality of old code without having to recompile against the new prefix, every assembly will need to be specified and new assemblies will require updates to the mod loader package.

Could we possibly add an opt-in feature for prefixing (or not prefixing) any assemblies but the old ones we had specified?

@ghorsington
Copy link
Contributor

ghorsington commented Jul 28, 2022

I agree that this will break any code that relies on the current API, but on the other hand, I think that in the long run, this is the correct thing to do.

How about introducing this behaviour as an opt-in for 1.x versions? Specifically

  • Allow both include/exclude options. The options will be exclusive, i.e. specifying both is an error.
  • By default, apply the current include behaviour on 1.x. Also, emit a warning that includes behaviour will be removed in the next major version

This way, we can at least provide a warning about this while still retaining the current behaviour until the next major release. Mod loaders can then choose what behaviour to use (in the case of BepInEx, we can enable exclusion behaviour right away for our doorstop 4 branch, but inclusion behaviour will be needed for current GTFO mods until they migrate too).

Another option is that I can make a separate next branch into which we'll start adding major breaking changes for the next major 2.x version. I was thinking about making such a branch, but I just didn't since I haven't yet made any major breaking changes.

How about these two options -- which one would be better? Any other opinions on how to integrate this into master or address this being a breaking change are welcome.

@ds5678 ds5678 force-pushed the prefix-almost-everything branch from c661b91 to 8e1a597 Compare September 29, 2022 14:28
@ds5678
Copy link
Collaborator Author

ds5678 commented Sep 29, 2022

I implemented your requested changes. A couple things of note:

  • I had to bump IsExternalInit to 1.0.3. Il2CppInterop.Generator would not compile on netstandard 2.1 otherwise.
  • My implementation uses Unity as the only default exclusion prefix.
  • Like discussed, this is backwards-compatible. The old options still work.
  • The new options are incompatible with the old options, and an exception is thrown when they're used together.

@ds5678
Copy link
Collaborator Author

ds5678 commented Oct 1, 2022

I just added code to prevent Assembly-CSharp and Assembly-CSharp-firstpass from getting their assembly name changed. No external library can have those names, and it reduces friction in the transition for modders.

@ghorsington ghorsington merged commit af2450c into BepInEx:master Oct 1, 2022
@ds5678 ds5678 deleted the prefix-almost-everything branch October 1, 2022 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants