<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="10.0.0-preview.7.25380.108" />

DiagnosticsHelper

static class DiagnosticsHelper
using System.Collections.Generic; namespace System.Diagnostics { internal static class DiagnosticsHelper { internal unsafe static bool CompareTags(IList<KeyValuePair<string, object>> sortedTags, IEnumerable<KeyValuePair<string, object>> tags2) { if (sortedTags == tags2) return true; if (sortedTags == null || tags2 == null) return false; int count = sortedTags.Count; int num = count / 64 + 1; Span<ulong> bitMap; if ((uint)num <= 100) { int num2 = num; bitMap = new Span<ulong>(stackalloc byte[(int)checked(unchecked((ulong)(uint)num2) * 8)], num2); } else bitMap = new ulong[num]; BitMapper bitMapper = new BitMapper(bitMap); ICollection<KeyValuePair<string, object>> collection = tags2 as ICollection<KeyValuePair<string, object>>; if (collection != null) { if (collection.Count != count) return false; IList<KeyValuePair<string, object>> list = collection as IList<KeyValuePair<string, object>>; if (list != null) { for (int i = 0; i < count; i++) { KeyValuePair<string, object> keyValuePair = list[i]; for (int j = 0; j < count; j++) { if (!bitMapper.IsSet(j)) { KeyValuePair<string, object> keyValuePair2 = sortedTags[j]; int num3 = string.CompareOrdinal(keyValuePair.Key, keyValuePair2.Key); if (num3 == 0 && object.Equals(keyValuePair.Value, keyValuePair2.Value)) { bitMapper.SetBit(j); break; } if (num3 < 0 || j == count - 1) return false; } } } return true; } } int num4 = 0; using (IEnumerator<KeyValuePair<string, object>> enumerator = tags2.GetEnumerator()) { while (enumerator.MoveNext()) { num4++; if (num4 > sortedTags.Count) return false; KeyValuePair<string, object> current = enumerator.Current; for (int k = 0; k < count; k++) { if (!bitMapper.IsSet(k)) { KeyValuePair<string, object> keyValuePair3 = sortedTags[k]; int num5 = string.CompareOrdinal(current.Key, keyValuePair3.Key); if (num5 == 0 && object.Equals(current.Value, keyValuePair3.Value)) { bitMapper.SetBit(k); break; } if (num5 < 0 || k == count - 1) return false; } } } return num4 == sortedTags.Count; } } } }