Skip to content

Commit 84e90db

Browse files
committed
Fix NetworkVariableSerialization.cs
1 parent 3177f03 commit 84e90db

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

com.unity.netcode.gameobjects/Runtime/NetworkVariable/NetworkVariableSerialization.cs

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ public void Duplicate(in NativeList<T> value, ref NativeList<T> duplicatedValue)
10221022
/// <summary>
10231023
/// Serializer for managed INetworkSerializable types, which differs from the unmanaged implementation in that it
10241024
/// has to be null-aware
1025-
/// <typeparam name="T"></typeparam>
1025+
/// </summary>
10261026
internal class ManagedNetworkSerializableSerializer<T> : INetworkVariableSerializer<T> where T : class, INetworkSerializable, new()
10271027
{
10281028
public void Write(FastBufferWriter writer, ref T value)
@@ -1095,7 +1095,7 @@ public void Duplicate(in T value, ref T duplicatedValue)
10951095
/// extension methods. Finding those methods isn't achievable efficiently at runtime, so this allows
10961096
/// users to tell NetworkVariable about those extension methods (or simply pass in a lambda)
10971097
/// </summary>
1098-
/// <typeparam name="T"></typeparam>
1098+
/// <typeparam name="T">The type to be serialized.</typeparam>
10991099
public class UserNetworkVariableSerialization<T>
11001100
{
11011101
/// <summary>
@@ -1110,6 +1110,7 @@ public class UserNetworkVariableSerialization<T>
11101110
/// </summary>
11111111
/// <param name="writer">The <see cref="FastBufferWriter"/> to write the value of type `T`</param>
11121112
/// <param name="value">The value of type `T` to be written</param>
1113+
/// <param name="previousValue">The previous value of type `T` to be compared.</param>
11131114
public delegate void WriteDeltaDelegate(FastBufferWriter writer, in T value, in T previousValue);
11141115

11151116
/// <summary>
@@ -1129,8 +1130,8 @@ public class UserNetworkVariableSerialization<T>
11291130
/// <summary>
11301131
/// The read value delegate handler definition
11311132
/// </summary>
1132-
/// <param name="reader">The <see cref="FastBufferReader"/> to read the value of type `T`</param>
1133-
/// <param name="value">The value of type `T` to be read</param>
1133+
/// <param name="value">The value of type `T` to be duplicated.</param>
1134+
/// <param name="duplicatedValue">The duplicated value of type `T`.</param>
11341135
public delegate void DuplicateValueDelegate(in T value, ref T duplicatedValue);
11351136

11361137
/// <summary>
@@ -1273,46 +1274,47 @@ internal static void InitializeIntegerSerialization()
12731274
}
12741275

12751276
/// <summary>
1276-
/// Registeres an unmanaged type that will be serialized by a direct memcpy into a buffer
1277+
/// Registers an unmanaged type that will be serialized by a direct memcpy into a buffer
12771278
/// </summary>
1278-
/// <typeparam name="T"></typeparam>
1279+
/// <typeparam name="T">The unmanaged type to be serialized</typeparam>
12791280
public static void InitializeSerializer_UnmanagedByMemcpy<T>() where T : unmanaged
12801281
{
12811282
NetworkVariableSerialization<T>.Serializer = new UnmanagedTypeSerializer<T>();
12821283
}
12831284

12841285
/// <summary>
1285-
/// Registeres an unmanaged type that will be serialized by a direct memcpy into a buffer
1286+
/// Registers an unmanaged array type that will be serialized by a direct memcpy into a buffer
12861287
/// </summary>
1287-
/// <typeparam name="T"></typeparam>
1288+
/// <typeparam name="T">The unmanaged type to be serialized</typeparam>
12881289
public static void InitializeSerializer_UnmanagedByMemcpyArray<T>() where T : unmanaged
12891290
{
12901291
NetworkVariableSerialization<NativeArray<T>>.Serializer = new UnmanagedArraySerializer<T>();
12911292
}
12921293

12931294
#if UNITY_NETCODE_NATIVE_COLLECTION_SUPPORT
12941295
/// <summary>
1295-
/// Registeres an unmanaged type that will be serialized by a direct memcpy into a buffer
1296+
/// Registers an unmanaged list type that will be serialized by a direct memcpy into a buffer
12961297
/// </summary>
1297-
/// <typeparam name="T"></typeparam>
1298+
/// <typeparam name="T">The unmanaged type to be serialized</typeparam>
12981299
public static void InitializeSerializer_UnmanagedByMemcpyList<T>() where T : unmanaged
12991300
{
13001301
NetworkVariableSerialization<NativeList<T>>.Serializer = new UnmanagedListSerializer<T>();
13011302
}
13021303

13031304
/// <summary>
1304-
/// Registeres a native hash set (this generic implementation works with all types)
1305+
/// Registers a native hash set (this generic implementation works with all types)
13051306
/// </summary>
1306-
/// <typeparam name="T"></typeparam>
1307+
/// <typeparam name="T">The type of elements in the hash set.</typeparam>
13071308
public static void InitializeSerializer_NativeHashSet<T>() where T : unmanaged, IEquatable<T>
13081309
{
13091310
NetworkVariableSerialization<NativeHashSet<T>>.Serializer = new NativeHashSetSerializer<T>();
13101311
}
13111312

13121313
/// <summary>
1313-
/// Registeres a native hash set (this generic implementation works with all types)
1314+
/// Registers a native hash set (this generic implementation works with all types)
13141315
/// </summary>
1315-
/// <typeparam name="T"></typeparam>
1316+
/// <typeparam name="TKey">The type of keys in the hash map.</typeparam>
1317+
/// <typeparam name="TVal">The type of values in the hash map.</typeparam>
13161318
public static void InitializeSerializer_NativeHashMap<TKey, TVal>()
13171319
where TKey : unmanaged, IEquatable<TKey>
13181320
where TVal : unmanaged
@@ -1322,27 +1324,28 @@ public static void InitializeSerializer_NativeHashMap<TKey, TVal>()
13221324
#endif
13231325

13241326
/// <summary>
1325-
/// Registeres a native hash set (this generic implementation works with all types)
1327+
/// Registers a native hash set (this generic implementation works with all types)
13261328
/// </summary>
1327-
/// <typeparam name="T"></typeparam>
1329+
/// <typeparam name="T">The type of elements in the list.</typeparam>
13281330
public static void InitializeSerializer_List<T>()
13291331
{
13301332
NetworkVariableSerialization<List<T>>.Serializer = new ListSerializer<T>();
13311333
}
13321334

13331335
/// <summary>
1334-
/// Registeres a native hash set (this generic implementation works with all types)
1336+
/// Registers a native hash set (this generic implementation works with all types)
13351337
/// </summary>
1336-
/// <typeparam name="T"></typeparam>
1338+
/// <typeparam name="T">The type of elements in the hash set.</typeparam>
13371339
public static void InitializeSerializer_HashSet<T>() where T : IEquatable<T>
13381340
{
13391341
NetworkVariableSerialization<HashSet<T>>.Serializer = new HashSetSerializer<T>();
13401342
}
13411343

13421344
/// <summary>
1343-
/// Registeres a native hash set (this generic implementation works with all types)
1345+
/// Registers a native hash set (this generic implementation works with all types)
13441346
/// </summary>
1345-
/// <typeparam name="T"></typeparam>
1347+
/// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
1348+
/// <typeparam name="TVal">The type of values in the dictionary.</typeparam>
13461349
public static void InitializeSerializer_Dictionary<TKey, TVal>() where TKey : IEquatable<TKey>
13471350
{
13481351
NetworkVariableSerialization<Dictionary<TKey, TVal>>.Serializer = new DictionarySerializer<TKey, TVal>();
@@ -1352,7 +1355,7 @@ public static void InitializeSerializer_Dictionary<TKey, TVal>() where TKey : IE
13521355
/// Registers an unmanaged type that implements INetworkSerializable and will be serialized through a call to
13531356
/// NetworkSerialize
13541357
/// </summary>
1355-
/// <typeparam name="T"></typeparam>
1358+
/// <typeparam name="T">The unmanaged type that implements INetworkSerializable.</typeparam>
13561359
public static void InitializeSerializer_UnmanagedINetworkSerializable<T>() where T : unmanaged, INetworkSerializable
13571360
{
13581361
NetworkVariableSerialization<T>.Serializer = new UnmanagedNetworkSerializableSerializer<T>();
@@ -1362,7 +1365,7 @@ public static void InitializeSerializer_UnmanagedINetworkSerializable<T>() where
13621365
/// Registers an unmanaged type that implements INetworkSerializable and will be serialized through a call to
13631366
/// NetworkSerialize
13641367
/// </summary>
1365-
/// <typeparam name="T"></typeparam>
1368+
/// <typeparam name="T">The unmanaged type that implements INetworkSerializable.</typeparam>
13661369
public static void InitializeSerializer_UnmanagedINetworkSerializableArray<T>() where T : unmanaged, INetworkSerializable
13671370
{
13681371
NetworkVariableSerialization<NativeArray<T>>.Serializer = new UnmanagedNetworkSerializableArraySerializer<T>();
@@ -1373,7 +1376,7 @@ public static void InitializeSerializer_UnmanagedINetworkSerializableArray<T>()
13731376
/// Registers an unmanaged type that implements INetworkSerializable and will be serialized through a call to
13741377
/// NetworkSerialize
13751378
/// </summary>
1376-
/// <typeparam name="T"></typeparam>
1379+
/// <typeparam name="T">The unmanaged type that implements INetworkSerializable.</typeparam>
13771380
public static void InitializeSerializer_UnmanagedINetworkSerializableList<T>() where T : unmanaged, INetworkSerializable
13781381
{
13791382
NetworkVariableSerialization<NativeList<T>>.Serializer = new UnmanagedNetworkSerializableListSerializer<T>();
@@ -1384,7 +1387,7 @@ public static void InitializeSerializer_UnmanagedINetworkSerializableList<T>() w
13841387
/// Registers a managed type that implements INetworkSerializable and will be serialized through a call to
13851388
/// NetworkSerialize
13861389
/// </summary>
1387-
/// <typeparam name="T"></typeparam>
1390+
/// <typeparam name="T">The managed type that implements INetworkSerializable.</typeparam>
13881391
public static void InitializeSerializer_ManagedINetworkSerializable<T>() where T : class, INetworkSerializable, new()
13891392
{
13901393
NetworkVariableSerialization<T>.Serializer = new ManagedNetworkSerializableSerializer<T>();
@@ -1394,7 +1397,7 @@ public static void InitializeSerializer_UnmanagedINetworkSerializableList<T>() w
13941397
/// Registers a FixedString type that will be serialized through FastBufferReader/FastBufferWriter's FixedString
13951398
/// serializers
13961399
/// </summary>
1397-
/// <typeparam name="T"></typeparam>
1400+
/// <typeparam name="T">The FixedString type to be serialized.</typeparam>
13981401
public static void InitializeSerializer_FixedString<T>() where T : unmanaged, INativeList<byte>, IUTF8Bytes
13991402
{
14001403
NetworkVariableSerialization<T>.Serializer = new FixedStringSerializer<T>();
@@ -1404,7 +1407,7 @@ public static void InitializeSerializer_FixedString<T>() where T : unmanaged, IN
14041407
/// Registers a FixedString type that will be serialized through FastBufferReader/FastBufferWriter's FixedString
14051408
/// serializers
14061409
/// </summary>
1407-
/// <typeparam name="T"></typeparam>
1410+
/// <typeparam name="T">The FixedString type to be serialized.</typeparam>
14081411
public static void InitializeSerializer_FixedStringArray<T>() where T : unmanaged, INativeList<byte>, IUTF8Bytes
14091412
{
14101413
NetworkVariableSerialization<NativeArray<T>>.Serializer = new FixedStringArraySerializer<T>();
@@ -1415,7 +1418,7 @@ public static void InitializeSerializer_FixedStringArray<T>() where T : unmanage
14151418
/// Registers a FixedString type that will be serialized through FastBufferReader/FastBufferWriter's FixedString
14161419
/// serializers
14171420
/// </summary>
1418-
/// <typeparam name="T"></typeparam>
1421+
/// <typeparam name="T">The FixedString type to be serialized.</typeparam>
14191422
public static void InitializeSerializer_FixedStringList<T>() where T : unmanaged, INativeList<byte>, IUTF8Bytes
14201423
{
14211424
NetworkVariableSerialization<NativeList<T>>.Serializer = new FixedStringListSerializer<T>();
@@ -1467,7 +1470,7 @@ public static void InitializeEqualityChecker_HashSet<T>() where T : IEquatable<T
14671470
/// <summary>
14681471
/// Registers an unmanaged type that will be checked for equality using T.Equals()
14691472
/// </summary>
1470-
/// <typeparam name="TKey">The type of dictionary keys that implements IEquatable<TKey>.</typeparam>
1473+
/// <typeparam name="TKey">The type of dictionary keys that implements IEquatable.</typeparam>
14711474
/// <typeparam name="TVal">The type of dictionary values.</typeparam>
14721475
public static void InitializeEqualityChecker_Dictionary<TKey, TVal>()
14731476
where TKey : IEquatable<TKey>
@@ -1495,7 +1498,7 @@ public static void InitializeEqualityChecker_NativeHashSet<T>() where T : unmana
14951498
/// <summary>
14961499
/// Registers an unmanaged type that will be checked for equality using T.Equals()
14971500
/// </summary>
1498-
/// <typeparam name="TKey">The type of dictionary keys that implements IEquatable<TKey>.</typeparam>
1501+
/// <typeparam name="TKey">The type of dictionary keys that implements IEquatable.</typeparam>
14991502
/// <typeparam name="TVal">The type of dictionary values.</typeparam>
15001503
public static void InitializeEqualityChecker_NativeHashMap<TKey, TVal>()
15011504
where TKey : unmanaged, IEquatable<TKey>
@@ -1562,6 +1565,9 @@ public static class NetworkVariableSerialization<T>
15621565
/// <summary>
15631566
/// A callback to check if two values are equal.
15641567
/// </summary>
1568+
/// <param name="a">The first value to compare.</param>
1569+
/// <param name="b">The second value to compare.</param>
1570+
/// <returns>True if the values are equal; otherwise, false.</returns>
15651571
public delegate bool EqualsDelegate(ref T a, ref T b);
15661572

15671573
/// <summary>
@@ -1642,6 +1648,7 @@ public static void Read(FastBufferReader reader, ref T value)
16421648
/// </summary>
16431649
/// <param name="writer">The FastBufferWriter to write the serialized data to.</param>
16441650
/// <param name="value">The value to serialize</param>
1651+
/// <param name="previousValue">The previous value of type `T` to be compared.</param>
16451652
public static void WriteDelta(FastBufferWriter writer, ref T value, ref T previousValue)
16461653
{
16471654
Serializer.WriteDelta(writer, ref value, ref previousValue);

pvpExceptions.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
},
88
"PVP-150-1": {
99
"errors": [
10-
"Unity.Netcode.UserNetworkVariableSerialization<T>: empty <typeparam> tag",
11-
"Unity.Netcode.UserNetworkVariableSerialization<T>.DuplicateValueDelegate: unexpected <param name=\"reader\">",
1210
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeSerializer_UnmanagedByMemcpy(): empty <typeparam> tag",
1311
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeSerializer_UnmanagedByMemcpyArray(): empty <typeparam> tag",
1412
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeSerializer_List(): empty <typeparam> tag",
@@ -149,8 +147,6 @@
149147
"Unity.Netcode.NetworkVariableUpdateTraits: MaxSecondsBetweenUpdates: undocumented",
150148
"Unity.Netcode.NetworkVariableBase: NetworkBehaviour GetBehaviour(): undocumented",
151149
"Unity.Netcode.NetworkVariableBase: void MarkNetworkBehaviourDirty(): undocumented",
152-
"Unity.Netcode.UserNetworkVariableSerialization<T>.WriteDeltaDelegate: missing <param name=\"previousValue\">",
153-
"Unity.Netcode.UserNetworkVariableSerialization<T>.DuplicateValueDelegate: missing <param name=\"duplicatedValue\">",
154150
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeSerializer_Dictionary(): missing <typeparam name=\"TKey\">",
155151
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeSerializer_Dictionary(): missing <typeparam name=\"TVal\">",
156152
"Unity.Netcode.NetworkVariableSerializationTypes: void InitializeEqualityChecker_Dictionary(): missing <typeparam name=\"TKey\">",

0 commit comments

Comments
 (0)