Skip to content

Commit 952985d

Browse files
committed
chore: Add obsolete warnings to unused or invalid methods
1 parent 8851038 commit 952985d

6 files changed

Lines changed: 15 additions & 58 deletions

File tree

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

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
4747

4848
switch (typeDefinition.Name)
4949
{
50-
case nameof(NetworkManager):
51-
ProcessNetworkManager(typeDefinition, compiledAssembly.Defines);
52-
break;
5350
case nameof(NetworkBehaviour):
5451
ProcessNetworkBehaviour(typeDefinition);
5552
break;
@@ -90,38 +87,6 @@ public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
9087
return new ILPostProcessResult(new InMemoryAssembly(pe.ToArray(), pdb.ToArray()), m_Diagnostics);
9188
}
9289

93-
// TODO: Deprecate...
94-
// This is changing accessibility for values that are no longer used, but since our validator runs
95-
// after ILPP and sees those values as public, they cannot be removed until a major version change.
96-
private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assemblyDefines)
97-
{
98-
foreach (var fieldDefinition in typeDefinition.Fields)
99-
{
100-
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_func_table))
101-
{
102-
fieldDefinition.IsPublic = true;
103-
}
104-
105-
if (fieldDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
106-
{
107-
fieldDefinition.IsPublic = true;
108-
}
109-
110-
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_name_table))
111-
{
112-
fieldDefinition.IsPublic = true;
113-
}
114-
}
115-
116-
foreach (var nestedTypeDefinition in typeDefinition.NestedTypes)
117-
{
118-
if (nestedTypeDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
119-
{
120-
nestedTypeDefinition.IsNestedPublic = true;
121-
}
122-
}
123-
}
124-
12590
private void ProcessNetworkBehaviour(TypeDefinition typeDefinition)
12691
{
12792
foreach (var nestedType in typeDefinition.NestedTypes)

com.unity.netcode.gameobjects/Editor/NetworkBehaviourEditor.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,8 @@ private void OnEnable()
326326
/// </summary>
327327
/// <param name="transform">The current <see cref="Transform"/> we are inspecting for a parent</param>
328328
/// <returns>the root parent for the first <see cref="Transform"/> passed into the method</returns>
329-
public static Transform GetRootParentTransform(Transform transform)
330-
{
331-
if (transform.parent == null || transform.parent == transform)
332-
{
333-
return transform;
334-
}
335-
return GetRootParentTransform(transform.parent);
336-
}
329+
[Obsolete("Use transform.root instead")]
330+
public static Transform GetRootParentTransform(Transform transform) => transform.root;
337331

338332
/// <summary>
339333
/// Used to determine if a GameObject has one or more NetworkBehaviours but
@@ -358,7 +352,7 @@ public static void CheckForNetworkObject(GameObject gameObject, bool networkObje
358352
}
359353

360354
// Now get the root parent transform to the current GameObject (or itself)
361-
var rootTransform = GetRootParentTransform(gameObject.transform);
355+
var rootTransform = gameObject.transform.root;
362356
if (!rootTransform.TryGetComponent<NetworkManager>(out var networkManager))
363357
{
364358
networkManager = rootTransform.GetComponentInChildren<NetworkManager>();

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ public class NetworkManager : MonoBehaviour, INetworkUpdateSystem
4444
#pragma warning disable IDE1006 // disable naming rule violation check
4545

4646
// RuntimeAccessModifiersILPP will make this `public`
47+
[Obsolete("This field is no longer used and will be removed in a future version.")]
4748
internal delegate void RpcReceiveHandler(NetworkBehaviour behaviour, FastBufferReader reader, __RpcParams parameters);
4849

4950
// RuntimeAccessModifiersILPP will make this `public`
51+
[Obsolete("This field is no longer used and will be removed in a future version.")]
5052
internal static readonly Dictionary<uint, RpcReceiveHandler> __rpc_func_table = new Dictionary<uint, RpcReceiveHandler>();
5153

5254
// RuntimeAccessModifiersILPP will make this `public` (legacy table should be removed in v3.x.x)
55+
[Obsolete("This field is no longer used and will be removed in a future version.")]
5356
internal static readonly Dictionary<uint, string> __rpc_name_table = new Dictionary<uint, string>();
5457

5558
#pragma warning restore IDE1006 // restore naming rule violation check

com.unity.netcode.gameobjects/Runtime/NetworkVariable/Collections/NetworkList.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,14 +683,8 @@ private void HandleAddListEvent(NetworkListEvent<T> listEvent)
683683
/// <summary>
684684
/// This method should not be used. It is left over from a previous interface
685685
/// </summary>
686-
public int LastModifiedTick
687-
{
688-
get
689-
{
690-
// todo: implement proper network tick for NetworkList
691-
return NetworkTickSystem.NoTick;
692-
}
693-
}
686+
[Obsolete("This property is no longer used and will be removed in a future version.")]
687+
public int LastModifiedTick => NetworkTickSystem.NoTick;
694688

695689
/// <summary>
696690
/// Overridden <see cref="IDisposable"/> implementation.

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ private bool TryGetNetworkClient(ulong clientId, out NetworkClient networkClient
448448
/// </summary>
449449
/// <param name="perviousOwner">not used</param>
450450
/// <param name="newOwner">not used</param>
451+
[Obsolete("This method is no longer used and will be removed in a future version.")]
451452
protected virtual void InternalOnOwnershipChanged(ulong perviousOwner, ulong newOwner)
452453
{
453454

@@ -999,7 +1000,7 @@ internal NetworkObject CreateLocalNetworkObject(NetworkObject.SerializedObject s
9991000

10001001
networkObject.DestroyWithScene = serializedObject.DestroyWithScene;
10011002
networkObject.NetworkSceneHandle = serializedObject.NetworkSceneHandle;
1002-
networkObject.DontDestroyWithOwner = serializedObject.DontDestroyWithOwner;
1003+
networkObject.DestroyWithOwner = serializedObject.DestroyWithOwner;
10031004
networkObject.Ownership = (NetworkObject.OwnershipStatus)serializedObject.OwnershipFlags;
10041005

10051006
var nonNetworkObjectParent = false;

testproject/Assets/Tests/Runtime/RpcTestsAutomated.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ private IEnumerator AutomatedRpcTestsHandler(int numClients)
120120
Assert.IsFalse(m_TimedOut);
121121

122122
// Log the output for visual confirmation (Acceptance Test for this test) that all RPC test types (tracked by counters) executed multiple times
123-
Debug.Log("Final Host-Server Status Info:");
124-
Debug.Log(serverRpcTests.GetCurrentServerStatusInfo());
123+
VerboseDebug("Final Host-Server Status Info:");
124+
VerboseDebug(serverRpcTests.GetCurrentServerStatusInfo());
125125

126126
foreach (var rpcClientSideTest in clientRpcQueueManualTestInstsances)
127127
{
128-
Debug.Log($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:");
129-
Debug.Log(rpcClientSideTest.GetCurrentClientStatusInfo());
128+
VerboseDebug($"Final Client {rpcClientSideTest.NetworkManager.LocalClientId} Status Info:");
129+
VerboseDebug(rpcClientSideTest.GetCurrentClientStatusInfo());
130130
}
131131

132-
Debug.Log($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds.");
132+
VerboseDebug($"Total frames updated = {Time.frameCount - startFrameCount} within {Time.realtimeSinceStartup - startTime} seconds.");
133133
}
134134
}
135135
}

0 commit comments

Comments
 (0)