Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

brwhelan-msft
Copy link

Adds a MESSAGEPACK_FORCE_AOT preprocessor directive which forces the same behaviour as IL2CPP under Unity, requiring formatters to be generated ahead of time via MPC/Source Generators.

This is useful when working in the editor, since at the moment a project running in the Editor runs under Mono, so will generate IL, but then building to IL2CPP can result in failures if the formatters haven't been generated. Setting this directive will result in this failing in the editor, providing consistent results against IL2CPP builds

@AArnott
Copy link
Collaborator

AArnott commented Nov 7, 2023

Why not just set ENABLE_IL2CPP in the editor?

@AArnott AArnott added the unity label Nov 7, 2023
@brwhelan-msft
Copy link
Author

Why not just set ENABLE_IL2CPP in the editor?

I'd considered this, but had concerns about the impact it could have on other packages relying on ENABLE_IL2CPP if set globally in the Editor, so opted to target the functionality in MessagePack directly

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

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

Looks fine to me.
@neuecc Any concerns or alternative ideas?

@AArnott AArnott requested a review from neuecc November 8, 2023 00:49
@luis-valverde-ms
Copy link

Thank you for the changes @brwhelan-msft . For maintainability, at least where it is used often, I think it would be good to have this defined:

#if !(MESSAGEPACK_FORCE_AOT || ENABLE_IL2CPP)
#define DYNAMIC_GENERATION
#endif

And check for DYNAMIC_GENERATION instead.

@AArnott
Copy link
Collaborator

AArnott commented Nov 8, 2023

at least where it is used often

I like the suggestion, but I'd go further and say it should be used consistently at the top of any file that uses any of these Defines symbols. Otherwise it seems likely we'll regress in later code changes.

@brwhelan-msft
Copy link
Author

Great idea - I've just pushed an update which switches to defining DYNAMIC_GENERATION at the top of any files affected, and using it throughout

Copy link
Collaborator

@AArnott AArnott left a comment

Choose a reason for hiding this comment

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

Looks great. I'll wait a few more days for @nuecc to chime in before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants