Repository navigation
Conversation
913f071 to
b301bc6
Compare
With this change MessagePack builds specially for iOS and UWP applications and omits the Ref.Emit code similar to how we omit it for certain Unity platforms. A UWP test project is added to verify that the most basic scenario works. We may add more/all of our unit tests to run in the UWP test project eventually.
neuecc
left a comment
There was a problem hiding this comment.
Good to target as 2.1.
As your concern, removing UNITY_2018_3_OR_NEWER, NET_STANDARD_2_0 is bad because there definition automaticaly defined by Unity but REF_EMIT is not.
By the way, ideally uap's targetplatforms should not be added.
In my comment of #701
StandardResolver.Resolvers uses DynamicObjectResolver.Instance
that create new DynamicAssembly and it uses AssemblyBuilder.DefineDynamicAssembly immediately.
Well, this is different from what I thought and it is not good behavior.
If this is the cause, can I solve it by initializing DynamicAssembly with Lazy?
public sealed class DynamicObjectResolver : IFormatterResolver
{
internal static readonly Lazy<DynamicAssembly> DynamicAssembly;
static DynamicObjectResolver()
{
DynamicAssembly = new Lazy<DynamicAssembly>(()=> new DynamicAssembly(ModuleName));
}
private static class FormatterCache<T>
{
static FormatterCache()
{
TypeInfo formatterTypeInfo = DynamicObjectTypeBuilder.BuildType(DynamicAssembly.Value, typeof(T), false, false);
}
}I think, this will follow framwork standard( RuntimeFeature.IsDynamicCodeSupported etc).
Are some unity builds supposed to support REF_EMIT? Which symbols does Unity define that we should use instead of REF_EMIT?
It does add a tax that I'd rather avoid, I agree. In some cases like my P/Invoke project it's absolutely mandatory because the UWP store submission process will reject the app if even an unused p/invoke signature for a banned API is in the DLL. So we literally have to remove the method from the binary that UWP consumes. But I guess for dynamic assembly generation, maybe UWP's submission process won't ban code that tries, and if we avoid invoking it at runtime it shouldn't fail either. @neuecc: do you have a sense for the general approach you want to take across all these platforms that support different features? I'm thinking especially about |
Yes, currently Unity has no pre-declared(library author defined) define symbols. The following symbols are currently used.
In the case of This is why it has been excluded from being compiled in the first place. I think the UWP verification process is very stupid, but if there is still a situation that doesn't pass that way, I don't object to putting in a fix that allows the same path as UNITY to pass. |
Are you saying you object to even encoding UWP tests into the repo? Short of that, I don't know how we'll avoid regressions in this area in the future. Verifying unity is done with every PR/CI build (to a small extent at least, and we should get more tests running there to improve that). I feel we should do the same with UWP since we have users that want to use the library on that platform as well. As for avoiding a specialized iOS or UAP target in the messagepack library, I'd rather avoid that too. I like your suggestion to use |
|
@neuecc Regarding the 3 compiler symbols defined in Unity that you listed above, can you please provide a grid that indicates all the Unity platforms and these symbols and which symbols are defined in which circumstances? Maybe just modify my grid below to make it easy. Do I even have the right list for the vertical dimension in the table? What are the various modes that Unity can be in? Feel free to edit the table in any way. My goal is to understand when each preprocessor symbol is defined so I can make the necessary edits.
|
|
@AArnott I've edited your table. |
|
Any word on UWP support? |
|
@Noemata It's still on my TODO list. Just not prioritized particularly high. |
|
No worries @AArnott, turns out this was surprisingly easy to sort out myself from the breadcrumbs left behind by others. It was less than an hours worth of work. It's working well, just doing some perf comparisons to a couple other approaches. Protobuf is looking faster so far. |
For Unity 2018.3+ we can define own define constrains in .asmdef file: We can make separate |
|
this code is almostly same as #996, can close? |
This probably also gets it working on Xamarin.iOS as well.
TODO
#ifconditions in code where there were Unity-related conditions. I'm guessing I didn't get them all right. @neuecc can you confirm? Do we need to setREF_EMITin certain unity builds?Fixes #159