com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Compile / Code Gen Error: Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP: (0,0)

Open JayPeet opened this issue 3 years ago • 11 comments

Description

On Unity 2022.2.0a12, Latest version of NGO (hash: 6d54e2878bc80b92f32a618473162763b56b38ce), the package fails to compile.

I feel this is related to https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/1920 , I tried with different versions of the Mono.Cecil package with no luck (1.10.1 through 1.11.4).

Reproduce Steps

  1. Install Unity 2022.2.0a12.
  2. Install Netcode for GameObjects via git
  3. Notice compile error after compilation finishes

Actual Outcome

Unity prints the error Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP: (0,0): error - System.InvalidCastException: Unable to cast object of type 'Mono.Cecil.ArrayType' to type 'Mono.Cecil.GenericInstanceType'.|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.ResolveGenericType(TypeReference type, List1 typeStack)|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.ResolveGenericType(TypeReference type, List1 typeStack)|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly)

Expected Outcome

The project should compile

Environment

  • OS: Windows 10 Pro 21H1
  • Unity Version: 2022.2.0a12
  • Netcode Version: 1.0.0-pre.9
  • Netcode Commit: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/commit/6d54e2878bc80b92f32a618473162763b56b38ce

JayPeet avatar May 12 '22 16:05 JayPeet

I get a similar one with preview 9 and 2021.3.2f1

error  - System.NullReferenceException: Object reference not set to an instance of an object.||   at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in C:\Users\ashka\Projects\NeoDemoDev\Library\PackageCache\[email protected]\Editor\CodeGen\INetworkSerializableILPP.cs:line 116   at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in C:\Users\ashka\Projects\NeoDemoDev\Library\PackageCache\[email protected]\Editor\CodeGen\INetworkSerializableILPP.cs:line 116

I don't get this in an empty project so something in my project is triggering it.

ashkan-saeedi-mazdeh avatar May 17 '22 09:05 ashkan-saeedi-mazdeh

Also based on this post https://forum.unity.com/threads/null-reference-exception-after-add-script.1280162/ It seems to be at least one case it happens is generic constraints.

ashkan-saeedi-mazdeh avatar May 17 '22 10:05 ashkan-saeedi-mazdeh

Similar issue with preview 9 and 2020.3.15f2 over here as well ~~university requiring the use of 2020.3.15f2, still trying to encourage them to update the version they have installed~~

(0,0): error - System.NullReferenceException: Object reference not set to an instance of an object|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process (Unity.CompilationPipeline.Common.ILPostProcessing.ICompiledAssembly compiledAssembly) [0x00161] in <c68a31db69ca400d86b2009bda4cd3b4>:0 at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process (Unity.CompilationPipeline.Common.ILPostProcessing.ICompiledAssembly compiledAssembly) [0x00161] in <c68a31db69ca400d86b2009bda4cd3b4>:0

11BelowStudio avatar May 27 '22 12:05 11BelowStudio

Also having an issue with pre-9. This repo by Dilmer works on pre-3 but fails on pre-9. https://github.com/dilmerv/UnityMultiplayerPlayground With this error: (0,0): error - System.NullReferenceException: Object reference not set to an instance of an object.|| at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in D:\repos\bombbomb\Library\PackageCache\[email protected]\Editor\CodeGen\INetworkSerializableILPP.cs:line 116 at Unity.Netcode.Editor.CodeGen.INetworkSerializableILPP.Process(ICompiledAssembly compiledAssembly) in D:\repos\bombbomb\Library\PackageCache\[email protected]\Editor\CodeGen\INetworkSerializableILPP.cs:line 116

mickjmason avatar Jun 06 '22 11:06 mickjmason

Its fixed locally for me, however my remote CI (ubuntu) can only get one build out before hitting this error. Deleting the library folder "fixes" it.

JayPeet avatar Jun 19 '22 00:06 JayPeet

Its still an issue, here is the error log output during build

`Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(611,69): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'Resolve' and no accessible extension method 'Resolve' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(619,55): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'IsGenericInstance' and no accessible extension method 'IsGenericInstance' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(621,61): error CS0030: Cannot convert type 'Mono.Cecil.GenericParameterConstraint' to 'Mono.Cecil.GenericInstanceType'

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(624,84): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'FullName' and no accessible extension method 'FullName' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(755,69): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'Resolve' and no accessible extension method 'Resolve' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(764,55): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'IsGenericInstance' and no accessible extension method 'IsGenericInstance' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(766,61): error CS0030: Cannot convert type 'Mono.Cecil.GenericParameterConstraint' to 'Mono.Cecil.GenericInstanceType'

Library/PackageCache/com.unity.netcode.gameobjects@fddb7cd920/Editor/CodeGen/NetworkBehaviourILPP.cs(769,84): error CS1061: 'GenericParameterConstraint' does not contain a definition for 'FullName' and no accessible extension method 'FullName' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?)`

This happens every build, unless the Library folder is deleted

JayPeet avatar Jul 06 '22 15:07 JayPeet

Tracked in our backlog MTT-4087

ashwinimurt avatar Jul 12 '22 23:07 ashwinimurt

Hi @JayPeet error CS1061: 'GenericParameterConstraint' does not contain a definition for 'Resolve' and no accessible extension method 'Resolve' accepting a first argument of type 'GenericParameterConstraint' could be found (are you missing a using directive or an assembly reference?) This only happens on specific versions of 2022.2.x

I believe this is fixed now. Could you please try the latest 2022.2.x Unity with Netcode for GameObjects 1.0. Let us know if you have any other errors. Thanks!

ashwinimurt avatar Jul 20 '22 22:07 ashwinimurt

Heya @ashwinimurt

I get the same issue on 2022.2.0b2, on the latest Netcode version

JayPeet avatar Jul 22 '22 00:07 JayPeet

Looking at my build log, I notice that CECIL_CONSTRAINTS_ARE_TYPE_REFERENCES is set. Yet on my local machine its not. Going to investigate to find out where its being set

JayPeet avatar Jul 22 '22 19:07 JayPeet

Worked around it for now by using my fork, with the defines disabled https://github.com/JayPeet/com.unity.netcode.gameobjects

JayPeet avatar Jul 23 '22 01:07 JayPeet

Hi @JayPeet These issues have been fixed on the Unity side. If you try with latest Unity 2022 patch release, you should not get any compile errors. I have verified this locally. Closing as completed. Please reopen if you are still seeing the same issue on latest 2022. Thanks!

ashwinimurt avatar Oct 10 '22 21:10 ashwinimurt