-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Boxed.Mapping Unity3D support #592
Comments
This is a performance enhancement. I ran the benchmark in the project with all the versions of .NET the project supports and its still faster using the factory as opposed to Can we solve your problem by using an |
Wow, I did not expect that these compile shenanigans beat the plain The NuGet packages are available in Unity via this mirror registry. It simply downloads the .nupkg files and repacks them in a Unity-compatible format. It always takes .NETStandard2.0/.NETStandard2.1 dlls from the package, hence there is a whitelist in this repo to only provide Unity-compatible packages that don't use restricted stuff like Expression.Lambda.Compile. Maybe you can |
Hmmm, I'm not familiar with Unity and was hoping it would have its own unity target framework instead of netstandard2.1. I'm not sure how I can detect this and switch to a different code path. |
Uhh, "new() uses reflection under the covers" part sounds super counter-intuitive. Where do I read more about it? Regarding switching to a different code path: I don't think there's a way to detect Unity in runtime, but you can wrap the code in a #if UNITY and compile with this define symbol turned on (and publish a separate NuGet package) #if UNITY
public static T CreateInstance() => new T();
#else
public static T CreateInstance() => CreateInstanceFunc();
#endif |
Oh excellent, I actually got help from none other than Jon Skeet: |
Thanks for the link! For the record, |
Looks like there are some defined by Unity but they're not going to help us. https://docs.unity3d.com/560/Documentation/Manual/PlatformDependentCompilation.html Having another NuGet package is a fair bit of extra work to support. |
Can I help with that? To me, it looks like a two-step task:
From what I see, your build pipeline requires no tweaks to support new packages. And I suppose there won't be any code changes in the future that would break Unity compatibility, so the support effort should be negligible? |
Ok sure. |
Describe the feature
I want to use Boxed.Mapping in my Unity project, but it uses Expression.Lambda.Compile from System.Linq.Expressions here. Since compiling the game to mobile platforms requires AOT compiling, Unity forbids the usage of this method. Is it really necessary there? Is it possible to switch to plain
new()
?The text was updated successfully, but these errors were encountered: