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;
namespace VpSharp.Internal.ValueConverters;
@ -12,8 +12,10 @@ internal sealed class StringToEnumConverter<T> : ValueConverter<T>
public override void Deserialize(TextReader reader, out T result)
{
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)
{
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 VpSharp.Entities;
@ -30,7 +30,7 @@ public sealed partial class VirtualParadiseClient
await foreach (VirtualParadiseWorld world in EnumerateWorldsAsync())
{
if (string.Equals(world.Name, name))
if (string.Equals(world.Name, name, StringComparison.Ordinal))
{
return world;
}