1
0
mirror of https://github.com/oliverbooth/VpSharp synced 2024-11-10 04:55:41 +00:00

Explicit Ordinal string comparison

This commit is contained in:
Oliver Booth 2022-11-30 18:01:45 +00:00
parent 79129f44d2
commit 86458129b5
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
2 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
using VpSharp.Internal.Attributes; using VpSharp.Internal.Attributes;
namespace VpSharp.Internal.ValueConverters; namespace VpSharp.Internal.ValueConverters;
@ -13,7 +13,9 @@ internal sealed class StringToEnumConverter<T> : ValueConverter<T>
{ {
string value = reader.ReadToEnd(); string value = reader.ReadToEnd();
FieldInfo? field = typeof(T).GetFields().FirstOrDefault(f => string.Equals(f.GetCustomAttribute<SerializationKeyAttribute>()?.Key, value)); FieldInfo? field = typeof(T).GetFields().FirstOrDefault(f =>
string.Equals(f.GetCustomAttribute<SerializationKeyAttribute>()?.Key, value, StringComparison.Ordinal));
if (field is not null) if (field is not null)
{ {
result = (T)field.GetValue(Enum.GetValues<T>()[0])!; result = (T)field.GetValue(Enum.GetValues<T>()[0])!;

View File

@ -1,4 +1,4 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Threading.Channels; using System.Threading.Channels;
using VpSharp.Entities; using VpSharp.Entities;
@ -30,7 +30,7 @@ public sealed partial class VirtualParadiseClient
await foreach (VirtualParadiseWorld world in EnumerateWorldsAsync()) await foreach (VirtualParadiseWorld world in EnumerateWorldsAsync())
{ {
if (string.Equals(world.Name, name)) if (string.Equals(world.Name, name, StringComparison.Ordinal))
{ {
return world; return world;
} }