Skip to content

Commit 2a83dcb

Browse files
committed
Made more obsolete apis throw errors
1 parent dd472a6 commit 2a83dcb

13 files changed

Lines changed: 34 additions & 58 deletions

File tree

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1717
- `Unity.Netcode.Editor.CodeGen``Unity.Netcode.GameObjects.Editor.CodeGen`
1818
- `Unity.Netcode.Editor.PackageChecker``Unity.Netcode.GameObjects.Editor.PackageChecker`
1919
- `Unity.Netcode.Editor.Tests``Unity.Netcode.GameObjects.Editor.Tests`
20+
- Several APIs that were already marked `[Obsolete]` with a warning now raise a compile error instead (they are not removed yet): `NetworkObject.IsSceneObject`, `NetworkObject.SetSceneObjectStatus`, `NetworkList.LastModifiedTick`, `UnityTransport.InitialMaxSendQueueSize`, `UnityTransport.DebugSimulator`, `UnityTransport.SetDebugSimulatorParameters`, the deprecated `BufferedLinearInterpolator` buffer/interpolation fields and its testing-only `Update(float, NetworkTime)` overload, `NetworkSpawnManager.InternalOnOwnershipChanged`, `CommandLineOptions.Instance`, `CommandLineOptions.GetArg`, and `NotListeningException`.
2021

2122
### Deprecated
2223

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,25 @@ private void ProcessNetworkManager(TypeDefinition typeDefinition, string[] assem
9797
{
9898
foreach (var fieldDefinition in typeDefinition.Fields)
9999
{
100-
#pragma warning disable CS0618 // Type or member is obsolete
101-
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_func_table))
102-
#pragma warning restore CS0618 // Type or member is obsolete
100+
if (fieldDefinition.Name == "__rpc_func_table")
103101
{
104102
fieldDefinition.IsPublic = true;
105103
}
106104

107-
#pragma warning disable CS0618 // Type or member is obsolete
108-
if (fieldDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
109-
#pragma warning restore CS0618 // Type or member is obsolete
105+
if (fieldDefinition.Name == "RpcReceiveHandler")
110106
{
111107
fieldDefinition.IsPublic = true;
112108
}
113109

114-
#pragma warning disable CS0618 // Type or member is obsolete
115-
if (fieldDefinition.Name == nameof(NetworkManager.__rpc_name_table))
116-
#pragma warning restore CS0618 // Type or member is obsolete
110+
if (fieldDefinition.Name == "__rpc_name_table")
117111
{
118112
fieldDefinition.IsPublic = true;
119113
}
120114
}
121115

122116
foreach (var nestedTypeDefinition in typeDefinition.NestedTypes)
123117
{
124-
#pragma warning disable CS0618 // Type or member is obsolete
125-
if (nestedTypeDefinition.Name == nameof(NetworkManager.RpcReceiveHandler))
126-
#pragma warning restore CS0618 // Type or member is obsolete
118+
if (nestedTypeDefinition.Name == "RpcReceiveHandler")
127119
{
128120
nestedTypeDefinition.IsNestedPublic = true;
129121
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ public override void OnInspectorGUI()
101101
EditorGUILayout.Toggle(nameof(NetworkObject.IsOwner), m_NetworkObject.IsOwner);
102102
EditorGUILayout.Toggle(nameof(NetworkObject.IsOwnedByServer), m_NetworkObject.IsOwnedByServer);
103103
EditorGUILayout.Toggle(nameof(NetworkObject.IsPlayerObject), m_NetworkObject.IsPlayerObject);
104-
#pragma warning disable CS0618 // Type or member is obsolete
105-
// TODO-3.x: Update name in 3.x branch
106-
EditorGUILayout.Toggle(nameof(NetworkObject.IsSceneObject), m_NetworkObject.InScenePlaced);
107-
#pragma warning restore CS0618 // Type or member is obsolete
104+
EditorGUILayout.Toggle("IsSceneObject", m_NetworkObject.InScenePlaced);
108105
EditorGUILayout.Toggle(nameof(NetworkObject.DestroyWithScene), m_NetworkObject.DestroyWithScene);
109106
EditorGUILayout.TextField(nameof(NetworkObject.NetworkManager), m_NetworkObject.NetworkManager == null ? "null" : m_NetworkObject.NetworkManager.gameObject.name);
110107
GUI.enabled = guiEnabled;

com.unity.netcode.gameobjects/Runtime/Components/Interpolator/BufferedLinearInterpolator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,28 @@ private float GetPrecision()
5959
/// <remarks>
6060
/// This is replaced by the <see cref="m_BufferQueue"/> of type <see cref="Queue{T}"/>.
6161
/// </remarks>
62-
[Obsolete("This list is no longer used and will be deprecated.", false)]
62+
[Obsolete("This list is no longer used and will be deprecated.", true)]
6363
protected internal readonly List<BufferedItem> m_Buffer = new List<BufferedItem>();
6464

6565
/// <summary>
6666
/// ** Deprecating **
6767
/// The starting value of type <see cref="T"/> to interpolate from.
6868
/// </summary>
69-
[Obsolete("This property will be deprecated.", false)]
69+
[Obsolete("This property will be deprecated.", true)]
7070
protected internal T m_InterpStartValue;
7171

7272
/// <summary>
7373
/// ** Deprecating **
7474
/// The current value of type <see cref="T"/>.
7575
/// </summary>
76-
[Obsolete("This property will be deprecated.", false)]
76+
[Obsolete("This property will be deprecated.", true)]
7777
protected internal T m_CurrentInterpValue;
7878

7979
/// <summary>
8080
/// ** Deprecating **
8181
/// The end (or target) value of type <see cref="T"/> to interpolate towards.
8282
/// </summary>
83-
[Obsolete("This property will be deprecated.", false)]
83+
[Obsolete("This property will be deprecated.", true)]
8484
protected internal T m_InterpEndValue;
8585
#endregion
8686

@@ -651,7 +651,7 @@ public T Update(float deltaTime, double renderTime, double serverTime)
651651
/// <param name="deltaTime">time since call</param>
652652
/// <param name="serverTime">current server time</param>
653653
/// <returns>The newly interpolated value of type 'T'</returns>
654-
[Obsolete("This method is being deprecated due to it being only used for internal testing purposes.", false)]
654+
[Obsolete("This method is being deprecated due to it being only used for internal testing purposes.", true)]
655655
public T Update(float deltaTime, NetworkTime serverTime)
656656
{
657657
return UpdateInternal(deltaTime, serverTime);

com.unity.netcode.gameobjects/Runtime/Configuration/CommandLineOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CommandLineOptions
1212
/// <summary>
1313
/// Command-line options singleton
1414
/// </summary>
15-
[Obsolete("Not used anymore replaced by TryGetArg")]
15+
[Obsolete("Not used anymore replaced by TryGetArg", true)]
1616
public static CommandLineOptions Instance
1717
{
1818
get
@@ -38,7 +38,7 @@ private set
3838
/// </summary>
3939
/// <param name="arg">The name of the argument</param>
4040
/// <returns><see cref="string"/>Value of the command line argument passed in.</returns>
41-
[Obsolete("Not used anymore replaced by TryGetArg")]
41+
[Obsolete("Not used anymore replaced by TryGetArg", true)]
4242
public string GetArg(string arg)
4343
{
4444
var argIndex = k_CommandLineArguments.IndexOf(arg);

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,11 +1189,7 @@ internal void CreateAndSpawnPlayer(ulong ownerId)
11891189
return;
11901190
}
11911191

1192-
#pragma warning disable CS0618 // Type or member is obsolete
1193-
// Obsolete with warning means we need the underlying behaviour to keep existing
1194-
// TODO: remove in the 3.x branch
1195-
networkObject.SetSceneObjectStatus(false);
1196-
#pragma warning restore CS0618 // Type or member is obsolete
1192+
networkObject.IsSceneObjectInternal = false;
11971193
networkObject.NetworkManagerOwner = NetworkManager;
11981194
networkObject.SpawnAsPlayerObject(ownerId, networkObject.DestroyWithScene);
11991195
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ private static void ResetStaticsOnLoad()
7171
#pragma warning disable IDE1006 // disable naming rule violation check
7272

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

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

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

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

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,7 @@ private void CheckForInScenePlaced()
347347
}
348348
}
349349

350-
#pragma warning disable CS0618 // Type or member is obsolete
351-
// Obsolete with warning means we need the underlying behaviour to keep existing
352-
// TODO-3.x: remove in the 3.x branch
353-
SetSceneObjectStatus(true);
354-
#pragma warning restore CS0618 // Type or member is obsolete
350+
IsSceneObjectInternal = true;
355351

356352
// We go ahead and set this for "typical in-scene placed" usage patterns so this is serialized
357353
InScenePlaced = true;
@@ -1323,8 +1319,10 @@ public bool HasOwnershipStatus(OwnershipStatus status)
13231319
/// This method is marked for deprecation.<br />
13241320
/// Use <see cref="InScenePlaced"/> instead.
13251321
/// </remarks>
1326-
[Obsolete("Use InScenePlaced instead")]
1327-
public bool? IsSceneObject { get; internal set; }
1322+
internal bool? IsSceneObjectInternal { get; set; }
1323+
1324+
[Obsolete("Use InScenePlaced instead", true)]
1325+
public bool? IsSceneObject { get => IsSceneObjectInternal; internal set => IsSceneObjectInternal = value; }
13281326

13291327

13301328
/// <summary>
@@ -1361,10 +1359,10 @@ internal set
13611359
/// </summary>
13621360
/// <remarks>Only use this when using custom scene loading</remarks>
13631361
/// <param name="isSceneObject">When true, marks this as a scene-instantiated object; when false, marks it as runtime-instantiated</param>
1364-
[Obsolete("SetSceneObjectStatus is now calculated during the build.")]
1362+
[Obsolete("SetSceneObjectStatus is now calculated during the build.", true)]
13651363
public void SetSceneObjectStatus(bool isSceneObject = false)
13661364
{
1367-
IsSceneObject = isSceneObject;
1365+
IsSceneObjectInternal = isSceneObject;
13681366
}
13691367

13701368
/// <summary>
@@ -1990,11 +1988,7 @@ private void SpawnInternal(bool destroyWithScene, ulong ownerClientId, bool play
19901988
return;
19911989
}
19921990

1993-
// Calculate the legacy IsSceneObject value as the public field is obsolete with warning
1994-
// We can't break the public behavior of the field.
1995-
#pragma warning disable CS0618 // Type or member is obsolete
1996-
var legacyIsSceneObject = IsSceneObject.HasValue && IsSceneObject.Value;
1997-
#pragma warning restore CS0618 // Type or member is obsolete
1991+
var legacyIsSceneObject = IsSceneObjectInternal.HasValue && IsSceneObjectInternal.Value;
19981992

19991993
// If the initial state of the GameObject was disabled and InScenePlaced is marked,
20001994
// then spawn it as in-scene placed.

com.unity.netcode.gameobjects/Runtime/Exceptions/NotListeningException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Unity.Netcode
55
/// <summary>
66
/// Exception thrown when the operation require NetworkManager to be listening.
77
/// </summary>
8-
[Obsolete("Not used anymore.")]
8+
[Obsolete("Not used anymore.", true)]
99
public class NotListeningException : Exception
1010
{
1111
/// <summary>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ private void HandleAddListEvent(NetworkListEvent<T> listEvent)
686686
/// <summary>
687687
/// This method should not be used. It is left over from a previous interface
688688
/// </summary>
689-
[Obsolete("This property is no longer used and will be removed in a future version.")]
689+
[Obsolete("This property is no longer used and will be removed in a future version.", true)]
690690
public int LastModifiedTick => NetworkTickSystem.NoTick;
691691

692692
/// <summary>

0 commit comments

Comments
 (0)