mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-23 01:08:47 +00:00
Explicit Ordinal string comparison
This commit is contained in:
parent
79129f44d2
commit
86458129b5
@ -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])!;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user