Skip to content

This project does not work with Unity 2021.2+ #1343

Closed

Description

@aroman

Bug description

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.

Expected behavior

It works.

Actual behavior

Hundreds of compile errors.

Activity

  1. neuecc commented on Nov 3, 2021

    @neuecc
    Member

    It is Unity's bug and fixed in 2021.2b16 or higher right?

  2. aroman commented on Nov 3, 2021

    @aroman
    Author

    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.

  3. neuecc commented on Nov 3, 2021

    @neuecc
    Member

    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.

  4. aroman commented on Nov 3, 2021

    @aroman
    Author

    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'.
    
  5. neuecc commented on Nov 4, 2021

    @neuecc
    Member
  6. neuecc commented on Nov 4, 2021

    @neuecc
    Member

    I've make PR #1346, it will solve problem.

  7. aroman commented on Nov 4, 2021

    @aroman
    Author

    You are the best! Thank you!

  8. neptaco commented on Nov 29, 2021

    @neptaco

    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.

  9. LeanderSimonart commented on Dec 6, 2021

    @LeanderSimonart

    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

  10. Idles commented on Dec 8, 2021

    @Idles

    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?

  11. neuecc commented on Dec 12, 2021

    @neuecc
    Member

    sorry, I've make new PR #1357.

  12. BigBallard commented on Jan 23, 2022

    @BigBallard

    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

  13. github-actions commented on Apr 24, 2022

    @github-actions
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions