You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
This project does not work with Unity 2021.2+ #1343
Due to a change introduced in Unity 2021.2, several packages (including this one) do not work due to referencing various system libraries. There's a thread on the Unity Forums about this here.
Here's an example of one of the errors (there are hundreds across the source)
Assets/Plugins/MessagePack/MessagePackReader.cs(119,43): error CS0433:
The type 'ReadOnlySequence<T>' exists in both
'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
and 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Repro steps
Create a blank project in Unity 2021.2, and add the latest MessagePack-CSharp unitypackage.
It is easy to fix though, just delete the .dll's (like System.Memory) that are included with the library, since they're now included in Unity and by deleting that will avoid the conflict.
Oh,
I thought it was the error CS0570: 'ReadOnlySpan<T>.this[int].get' is not supported by the language bug.
But you are just having a problem with a simple DLL duplication.
It would be better to just not refer to it.
Also, the UPM Git installation does not include the Managed DLL, so that should not be a problem as well.
Ah, well feel free to close the issue then if you think most users won't hit this. BTW, I also noticed another (I assume harmless) warning related to this change:
Assets/Plugins/MessagePack/MessagePackSecurity.cs(249,56): warning CS0436: The type 'HashCode' in '/Users/aroman/Projects/Flowerfare-2021/Client/Assets/Plugins/MessagePack/HashCode.cs' conflicts with the imported type 'HashCode' in 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Using the type defined in '/Users/aroman/Projects/Flowerfare-2021/Client/Assets/Plugins/MessagePack/HashCode.cs'.
For me deleting the .dll files do not work. I get the following error when creating a GeneratedResolver.
Project Compilation Start:D:/Git/MPCTester/Assets/../Assembly-CSharp.csproj
failed to get metadata of System.Threading.Tasks.Task1
failed to get metadata of System.Threading.Tasks.Task
Fail in console app running on MessagepackCompiler.RunAsync
System.InvalidOperationException: failed to get metadata of MessagePack.MessagePackObjectAttribute
at MessagePackCompiler.CodeAnalysis.ReferenceSymbols..ctor(Compilation compilation, Action1 logger)
at MessagePackCompiler.CodeAnalysis.TypeCollector..ctor(Compilation compilation, Boolean disallowInternal, Boolean isForceUseMap, Action1 logger)
at MessagePackCompiler.CodeGenerator.GenerateFileAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols)
at MessagePack.Generator.MessagepackCompiler.RunAsync(String input, String output, String conditionalSymbol, String resolverName, String namespace, Boolean useMapMode, String multipleIfDirectiveOutputSymbols)
at ConsoleAppFramework.ConsoleAppEngine.RunCore(ConsoleAppContext ctx, Type type, MethodInfo methodInfo, String[] args, Int32 argsOffset)
I am on Unity 2021.2.3f1, using the github source code as a local package in the UPM.
Edit:
However it does seem to work when I run it with the command line and use dotnet mpc instead of the mpc.exe in the Tools folder
A clean import of MessagePack.Unity.2.3.85.unitypackage into a Unity project using Unity 2021.2.3f1 has this same problem. It looks like (incomplete?) work has been done to resolve this bug, but a new release with a new .unitypackage has not been created yet. Is cutting a new release the only task remaining to resolve this issue?
Activity
neuecc commentedon Nov 3, 2021
It is Unity's bug and fixed in 2021.2b16 or higher right?
aroman commentedon Nov 3, 2021
I don't think it's a bug but an unfortunate consequence of a change in Unity: https://forum.unity.com/threads/2021-2-0b6-and-system-memory-readonlyspan-under-net-4-8.1152104/#post-7444844
It is easy to fix though, just delete the .dll's (like System.Memory) that are included with the library, since they're now included in Unity and by deleting that will avoid the conflict.
neuecc commentedon Nov 3, 2021
Oh,
I thought it was the
error CS0570: 'ReadOnlySpan<T>.this[int].get' is not supported by the languagebug.But you are just having a problem with a simple DLL duplication.
It would be better to just not refer to it.
Also, the UPM Git installation does not include the Managed DLL, so that should not be a problem as well.
aroman commentedon Nov 3, 2021
Ah, well feel free to close the issue then if you think most users won't hit this. BTW, I also noticed another (I assume harmless) warning related to this change:
neuecc commentedon Nov 4, 2021
Thanks!
shims via
#if !NETCOREAPPis not valid for latest Unity.https://github.com/neuecc/MessagePack-CSharp/blob/ffc18319670d49246db1abbd05c404a820280776/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/HashCode.cs#L45
I'll invesitigate and fix it soon.
neuecc commentedon Nov 4, 2021
I've make PR #1346, it will solve problem.
aroman commentedon Nov 4, 2021
You are the best! Thank you!
neptaco commentedon Nov 29, 2021
I have added NET_STANDARD to fix the warning.
The warning is fixed when the API Compatibility Level is set to
.NET Standard 2.1.However, if I set it to
.NET Framework, the warning seems to appear.LeanderSimonart commentedon Dec 6, 2021
For me deleting the .dll files do not work. I get the following error when creating a GeneratedResolver.
I am on Unity 2021.2.3f1, using the github source code as a local package in the UPM.
Edit:
However it does seem to work when I run it with the command line and use dotnet mpc instead of the mpc.exe in the Tools folder
Idles commentedon Dec 8, 2021
A clean import of MessagePack.Unity.2.3.85.unitypackage into a Unity project using Unity 2021.2.3f1 has this same problem. It looks like (incomplete?) work has been done to resolve this bug, but a new release with a new .unitypackage has not been created yet. Is cutting a new release the only task remaining to resolve this issue?
neuecc commentedon Dec 12, 2021
sorry, I've make new PR #1357.
BigBallard commentedon Jan 23, 2022
Is there an expected fix for this? I am using unity 2021.2.8f1 and I get several compilation errors. Using IL2CPP and .NetStandard 2.1
github-actions commentedon Apr 24, 2022
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days.