Replace all raw string comparisons with StringKey, source generator that creates cache keys for all names for Gen7 plugin
All checks were successful
Build / Build (push) Successful in 2m21s
All checks were successful
Build / Build (push) Successful in 2m21s
This commit is contained in:
@@ -58,7 +58,7 @@ public readonly struct StringKey : IEquatable<StringKey>, IEquatable<string>
|
||||
return obj switch
|
||||
{
|
||||
StringKey other => Equals(other),
|
||||
string str => Equals(str),
|
||||
string str => string.Equals(_key, str, StringComparison.InvariantCultureIgnoreCase),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
@@ -67,16 +67,22 @@ public readonly struct StringKey : IEquatable<StringKey>, IEquatable<string>
|
||||
public bool Equals(StringKey other) => _hashCode == other._hashCode;
|
||||
|
||||
/// <inheritdoc cref="Equals(StringKey)"/>
|
||||
[Obsolete("Comparing a StringKey to a string uses a slow culture-aware string comparison. " +
|
||||
"Compare against a cached StringKey (e.g. a generated constant) instead.")]
|
||||
public bool Equals(string other) => string.Equals(_key, other, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode() => _hashCode;
|
||||
|
||||
/// <inheritdoc cref="Equals(StringKey)"/>
|
||||
[Obsolete("Comparing a StringKey to a string uses a slow culture-aware string comparison. " +
|
||||
"Compare against a cached StringKey (e.g. a generated constant) instead.")]
|
||||
public static bool operator ==(StringKey? left, string? right) =>
|
||||
(left is null && right is null) || (right != null && (left?.Equals(right) ?? false));
|
||||
|
||||
/// <inheritdoc cref="Equals(StringKey)"/>
|
||||
[Obsolete("Comparing a StringKey to a string uses a slow culture-aware string comparison. " +
|
||||
"Compare against a cached StringKey (e.g. a generated constant) instead.")]
|
||||
public static bool operator !=(StringKey? left, string? right) => !(left == right);
|
||||
|
||||
/// <inheritdoc cref="Equals(StringKey)"/>
|
||||
|
||||
Reference in New Issue
Block a user