Skip to content

Commit f130f44

Browse files
committed
Specify format
1 parent 8239106 commit f130f44

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ riderModule.iml
66
.idea
77
/tools
88
.vscode
9-
*.DotSettings.user
9+
*.DotSettings.user
10+
.qodo

Reactor/Networking/Extensions/ExtraMessageExtensions.cs

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#pragma warning disable CA1305 // Specify IFormatProvider
2-
31
using System;
2+
using System.Globalization;
43
using Hazel;
54
using Hazel.Udp;
65
using UnityEngine;
@@ -45,19 +44,19 @@ public static void Write(this MessageWriter writer, Enum value)
4544
var underlyingType = enumType.GetEnumUnderlyingType();
4645

4746
if (underlyingType == typeof(byte))
48-
writer.Write(Convert.ToByte(value));
47+
writer.Write(Convert.ToByte(value, NumberFormatInfo.InvariantInfo));
4948
else if (underlyingType == typeof(sbyte))
50-
writer.Write(Convert.ToSByte(value));
49+
writer.Write(Convert.ToSByte(value, NumberFormatInfo.InvariantInfo));
5150
else if (underlyingType == typeof(short))
52-
writer.Write(Convert.ToInt16(value));
51+
writer.Write(Convert.ToInt16(value, NumberFormatInfo.InvariantInfo));
5352
else if (underlyingType == typeof(ushort))
54-
writer.Write(Convert.ToUInt16(value));
53+
writer.Write(Convert.ToUInt16(value, NumberFormatInfo.InvariantInfo));
5554
else if (underlyingType == typeof(ulong))
56-
writer.Write(Convert.ToUInt64(value));
55+
writer.Write(Convert.ToUInt64(value, NumberFormatInfo.InvariantInfo));
5756
else if (underlyingType == typeof(uint))
58-
writer.WritePacked(Convert.ToUInt32(value));
57+
writer.WritePacked(Convert.ToUInt32(value, NumberFormatInfo.InvariantInfo));
5958
else if (underlyingType == typeof(int))
60-
writer.WritePacked(Convert.ToInt32(value));
59+
writer.WritePacked(Convert.ToInt32(value, NumberFormatInfo.InvariantInfo));
6160
else if (underlyingType == typeof(long))
6261
throw new NotSupportedException("long enum types are not supported at the moment.");
6362
else

Reactor/Networking/Serialization/MessageSerializer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static void Register(UnsafeMessageConverter messageConverter)
3030
/// Finds a MessageConverter for the specified <paramref name="type"/>.
3131
/// </summary>
3232
/// <param name="type">The type of an object.</param>
33-
/// <returns>A MessageConverted that can convert the specified <see cref="Type"/>.</returns>
33+
/// <returns>A MessageConverter that can convert the specified <see cref="Type"/>.</returns>
3434
public static UnsafeMessageConverter? FindConverter(Type type)
3535
{
3636
if (MessageConverterMap.TryGetValue(type, out var value))
@@ -169,7 +169,7 @@ public static object Deserialize(this MessageReader reader, Type objectType)
169169
return reader.ReadUInt64();
170170
}
171171

172-
if (typeof(Enum).IsAssignableFrom(objectType))
172+
if (objectType.IsEnum)
173173
{
174174
return reader.ReadEnum(objectType);
175175
}

0 commit comments

Comments
 (0)