<PackageReference Include="System.Drawing.Common" Version="10.0.0-preview.5.25277.114" />

BackCompatibleStringComparer

using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; namespace System.Collections.Specialized { [NullableContext(1)] [Nullable(0)] internal class BackCompatibleStringComparer : IEqualityComparer<string> { internal static IEqualityComparer<string> Default { get; } = new BackCompatibleStringComparer(); internal BackCompatibleStringComparer() { } public unsafe int GetHashCode([DisallowNull] string obj) { IntPtr intPtr; if (obj == null) intPtr = (IntPtr)(void*)null; else { ref pinnableReference = ref obj.GetPinnableReference(); intPtr = (IntPtr)(&pinnableReference); } int num = 5381; char* ptr = (char*)(long)intPtr; int num2; while ((num2 = *ptr) != 0) { num = (((num << 5) + num) ^ num2); ptr++; } return num; } [NullableContext(2)] public bool Equals(string x, string y) { return object.Equals(x, y); } public virtual int GetHashCode(object o) { string text = o as string; if (text == null) return o.GetHashCode(); return GetHashCode(text); } } }