MemoryPack icon indicating copy to clipboard operation
MemoryPack copied to clipboard

Unity 2023.2.10f1 gives error in Generator

Open chmodseven opened this issue 1 year ago • 8 comments

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 avatar Apr 02 '24 17:04 chmodseven

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

chmodseven avatar Apr 02 '24 17:04 chmodseven

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

DemonikGH avatar Apr 04 '24 05:04 DemonikGH

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?)`

gambit-monkey avatar Apr 04 '24 12:04 gambit-monkey

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

DemonikGH avatar Apr 04 '24 12:04 DemonikGH

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.

DemonikGH avatar Apr 04 '24 12:04 DemonikGH

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

gambit-monkey avatar Apr 04 '24 13:04 gambit-monkey

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.

neuecc avatar Apr 05 '24 03:04 neuecc

FWIW, the same error occurs on Unity 6 Beta

xaroth8088 avatar Apr 12 '24 19:04 xaroth8088

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

neuecc avatar Jul 30 '24 08:07 neuecc