Skip to content

Commit fd816c5

Browse files
authored
fix: mono cecil compatibility and UNET removal fixes for 2022.2.0a13 and above (#2000)
1 parent 472d51b commit fd816c5

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

com.unity.netcode.gameobjects/Editor/CodeGen/NetworkBehaviourILPP.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -609,17 +609,19 @@ private MethodReference GetFastBufferWriterWriteMethod(string name, TypeReferenc
609609
{
610610
#if CECIL_CONSTRAINTS_ARE_TYPE_REFERENCES
611611
var resolvedConstraint = constraint.Resolve();
612+
var constraintTypeRef = constraint;
612613
#else
613614
var resolvedConstraint = constraint.ConstraintType.Resolve();
615+
var constraintTypeRef = constraint.ConstraintType;
614616
#endif
615617

616618
var resolvedConstraintName = resolvedConstraint.FullNameWithGenericParameters(new[] { method.GenericParameters[0] }, new[] { checkType });
617-
if (constraint.IsGenericInstance)
619+
if (constraintTypeRef.IsGenericInstance)
618620
{
619-
var genericConstraint = (GenericInstanceType)constraint;
621+
var genericConstraint = (GenericInstanceType)constraintTypeRef;
620622
if (genericConstraint.HasGenericArguments && genericConstraint.GenericArguments[0].Resolve() != null)
621623
{
622-
resolvedConstraintName = constraint.FullName;
624+
resolvedConstraintName = constraintTypeRef.FullName;
623625
}
624626
}
625627
if ((resolvedConstraint.IsInterface && !checkType.HasInterface(resolvedConstraintName)) ||
@@ -751,18 +753,20 @@ private MethodReference GetFastBufferReaderReadMethod(string name, TypeReference
751753
{
752754
#if CECIL_CONSTRAINTS_ARE_TYPE_REFERENCES
753755
var resolvedConstraint = constraint.Resolve();
756+
var constraintTypeRef = constraint;
754757
#else
755758
var resolvedConstraint = constraint.ConstraintType.Resolve();
759+
var constraintTypeRef = constraint.ConstraintType;
756760
#endif
757761

758762

759763
var resolvedConstraintName = resolvedConstraint.FullNameWithGenericParameters(new[] { method.GenericParameters[0] }, new[] { checkType });
760-
if (constraint.IsGenericInstance)
764+
if (constraintTypeRef.IsGenericInstance)
761765
{
762-
var genericConstraint = (GenericInstanceType)constraint;
766+
var genericConstraint = (GenericInstanceType)constraintTypeRef;
763767
if (genericConstraint.HasGenericArguments && genericConstraint.GenericArguments[0].Resolve() != null)
764768
{
765-
resolvedConstraintName = constraint.FullName;
769+
resolvedConstraintName = constraintTypeRef.FullName;
766770
}
767771
}
768772

testproject/Assets/Tests/Runtime/MultiprocessRuntime/BaseMultiprocessTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using UnityEngine.SceneManagement;
66
using UnityEngine.TestTools;
77
using Object = UnityEngine.Object;
8+
#if UNITY_UNET_PRESENT
89
using Unity.Netcode.Transports.UNET;
10+
#endif
911
using Unity.Netcode.Transports.UTP;
1012

1113

@@ -84,13 +86,15 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
8486
MultiprocessLogger.Log($"transport is {transport}");
8587
switch (transport)
8688
{
89+
#if UNITY_UNET_PRESENT
8790
case UNetTransport unetTransport:
8891
unetTransport.ConnectPort = int.Parse(TestCoordinator.Port);
8992
unetTransport.ServerListenPort = int.Parse(TestCoordinator.Port);
9093
unetTransport.ConnectAddress = "127.0.0.1";
9194
MultiprocessLogger.Log($"Setting ConnectAddress to {unetTransport.ConnectAddress} port {unetTransport.ConnectPort}, {unetTransport.ServerListenPort}");
9295

9396
break;
97+
#endif
9498
case UnityTransport unityTransport:
9599
unityTransport.ConnectionData.ServerListenAddress = "0.0.0.0";
96100
MultiprocessLogger.Log($"Setting unityTransport.ConnectionData.Port {unityTransport.ConnectionData.ServerListenAddress}");

testproject/Assets/Tests/Runtime/MultiprocessRuntime/TestCoordinator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
using NUnit.Framework;
88
using UnityEngine;
99
using Unity.Netcode.MultiprocessRuntimeTests;
10+
#if UNITY_UNET_PRESENT
1011
using Unity.Netcode.Transports.UNET;
12+
#endif
1113
using Unity.Netcode.Transports.UTP;
1214

1315
/// <summary>
@@ -156,6 +158,7 @@ private void SetAddressAndPort()
156158
MultiprocessLogger.Log($"transport is {transport}");
157159
switch (transport)
158160
{
161+
#if UNITY_UNET_PRESENT
159162
case UNetTransport unetTransport:
160163
unetTransport.ConnectPort = ushortport;
161164
unetTransport.ServerListenPort = ushortport;
@@ -165,6 +168,7 @@ private void SetAddressAndPort()
165168
unetTransport.ConnectAddress = m_ConnectAddress;
166169
}
167170
break;
171+
#endif
168172
case UnityTransport unityTransport:
169173
MultiprocessLogger.Log($"Setting unityTransport.ConnectionData.Port {ushortport}, isClient: {m_IsClient}, Address {m_ConnectAddress}");
170174
unityTransport.ConnectionData.Port = ushortport;

0 commit comments

Comments
 (0)