Cysharp / MemoryPack

Zero encoding extreme performance binary serializer for C# and Unity.
MIT License
3.25k stars 190 forks source link

Unity 2023.2.10f1 gives error in Generator #275

Closed chmodseven closed 2 months ago

chmodseven commented 6 months ago

Hi, I'm not sure if I'm being a donkey here and not installing it properly, but I have attempted to import the latest MemoryPack into a Unity 2023.2.10f1 project, to replace a previous version that came in a unitypackage with the current 1.21.0 via Nuget For Unity.

I get the following: Assembly 'Assets/Packages/MemoryPack.Generator.1.21.0/analyzers/dotnet/cs/MemoryPack.Generator.dll' will not be loaded due to errors: Unable to resolve reference 'Microsoft.CodeAnalysis'. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector. Unable to resolve reference 'Microsoft.CodeAnalysis.CSharp'. Is the assembly missing or incompatible with the current platform? Reference validation can be disabled in the Plugin Inspector.

I attempted to also nuget in that reference and it led to a whole rabbit warren of other errors. So I created a temp project back on an older Unity 2022.3.20f1 install, and the latest MemoryPack installed just fine there over nuget, with no analyzer issues.

Is there some extra step I'm missing for Unity 2023+ or is it just not compatible there yet? I can't fathom why 2022 would not get stuck in the CodeAnalysis dependency weeds while the other one fails.

chmodseven commented 6 months ago

Furthermore, in case it helps, when I reverted back to 1.10.0 using nuget for unity, I got the same error, however when I cleared out all of that and re-added it via the .unitypackage then all went back to normal. So to summarise:

Unity 2022.3 - was able to install 1.21.0 via nuget for unity Unity 2023.2 - was not able to install either 1.21.0 or 1.10.0 over nuget, but was ablr to revert to 1.10.0 unitypackage

DemonikGH commented 6 months ago

Currently have the same problem with 2023.2.16f1, can't add memory pack.

gambit-monkey commented 6 months ago

Having same issue with MemoryPack 1.2x.x and Unity 2023.x. The following messages appear even in a clean project using the Git URL `Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\ProviderInitializer.cs(3,18): error CS0234: The type or namespace name 'Formatters' does not exist in the namespace 'MemoryPack' (are you missing an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(3,18): error CS0234: The type or namespace name 'Internal' does not exist in the namespace 'MemoryPack' (are you missing an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(94,49): error CS0246: The type or namespace name 'MemoryPackFormatter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(9,53): error CS0246: The type or namespace name 'MemoryPackFormatter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(50,47): error CS0246: The type or namespace name 'MemoryPackFormatter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(49,6): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(49,6): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(8,6): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(8,6): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(93,6): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(93,6): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(12,59): error CS0246: The type or namespace name 'MemoryPackWriter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(97,59): error CS0246: The type or namespace name 'MemoryPackWriter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(53,59): error CS0246: The type or namespace name 'MemoryPackWriter<>' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(25,46): error CS0246: The type or namespace name 'MemoryPackReader' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(68,46): error CS0246: The type or namespace name 'MemoryPackReader' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(109,46): error CS0246: The type or namespace name 'MemoryPackReader' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(96,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(96,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(52,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(52,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(11,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(11,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(24,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(24,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(108,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(108,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(67,10): error CS0246: The type or namespace name 'PreserveAttribute' could not be found (are you missing a using directive or an assembly reference?)

Library\PackageCache\com.cysharp.memorypack@d7971d7a98\Runtime\UnityFormatters.cs(67,10): error CS0246: The type or namespace name 'Preserve' could not be found (are you missing a using directive or an assembly reference?)`

DemonikGH commented 6 months ago

Old 1.10 version downloaded from OpenUPM work in 2023.2.16f1 for now.

DemonikGH commented 6 months ago

https://github.com/Cysharp/MemoryPack/issues/275#issuecomment-2037056055

You're trying to use unity package and it only contains unity specific stuff, you also need to download nuget package. But nuget package is also broken.

gambit-monkey commented 6 months ago

I did pull over 1.10.0 from the project I am actually working on updating from Unity 2021 to 2023 and it did work. I was not however able to do https://github.com/Cysharp/MemoryPack.git?path=src/MemoryPack.Unity/Assets/MemoryPack.Unity#1.10.0 through Unity itself

neuecc commented 6 months ago

Thanks for the report. I've been hearing about this problem a lot with ZLogger, which uses the same method, https://github.com/Cysharp/ZLogger/issues/155 The problem seems to be that the Generator.dll is not labeled/run-time referenced for RoslynAnalyzer. This should generate a meta that NuGetForUnity resolves at install time when installed with NuGetForUnity.

xaroth8088 commented 5 months ago

FWIW, the same error occurs on Unity 6 Beta

neuecc commented 2 months ago

maybe latest NuGetForUnity solves it. https://github.com/GlitchEnzo/NuGetForUnity/releases/tag/v4.1.1