From 8cc9cb963ee2afb45f5ea2c0a1bc13fe81ed1428 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 09:04:52 +0000 Subject: [PATCH 1/3] Initial plan From 8b1295adf436a5146a9e93b38e125458db86438d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 09:10:50 +0000 Subject: [PATCH 2/3] =?UTF-8?q?Fix=20O(n=C2=B2)=20hash=20collisions=20in?= =?UTF-8?q?=20DuplicateDataRowAnalyzer=20by=20including=20Value=20in=20Get?= =?UTF-8?q?HashCode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/2135dfb7-7ef6-4958-953f-5384259bfc39 Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../MSTest.Analyzers/DuplicateDataRowAnalyzer.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs b/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs index 6d560c76c1..e4c4a040c4 100644 --- a/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs +++ b/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs @@ -153,6 +153,18 @@ public int GetHashCode(ImmutableArray obj) { hashCode.Add(typedConstant.Kind); hashCode.Add(SymbolEqualityComparer.Default.GetHashCode(typedConstant.Type)); + + if (!typedConstant.IsNull) + { + if (typedConstant.Kind == TypedConstantKind.Array) + { + hashCode.Add(GetHashCode(typedConstant.Values)); + } + else + { + hashCode.Add(typedConstant.Value); + } + } } return hashCode.ToHashCode(); From e74c7ffebe3b3c7001eb5329864a5a7143d9e606 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:54:36 +0000 Subject: [PATCH 3/3] Mirror float/double bit-pattern hashing from Equals into GetHashCode Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/dacb1394-4b55-4396-a616-e924d625f66b Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com> --- .../DuplicateDataRowAnalyzer.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs b/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs index e4c4a040c4..57b927d41f 100644 --- a/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs +++ b/src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs @@ -162,12 +162,32 @@ public int GetHashCode(ImmutableArray obj) } else { - hashCode.Add(typedConstant.Value); + AddTypedConstantValueHash(ref hashCode, typedConstant); } } } return hashCode.ToHashCode(); } + + private static void AddTypedConstantValueHash(ref RoslynHashCode hashCode, TypedConstant typedConstant) + { + if (typedConstant.Kind == TypedConstantKind.Primitive) + { + switch (typedConstant.Type?.SpecialType) + { + case SpecialType.System_Single: + // BitConverter.SingleToInt32Bits isn't available on netstandard2.0, so we use BitConverter.GetBytes instead. + hashCode.Add(BitConverter.ToInt32(BitConverter.GetBytes((float)typedConstant.Value!), 0)); + return; + + case SpecialType.System_Double: + hashCode.Add(BitConverter.DoubleToInt64Bits((double)typedConstant.Value!)); + return; + } + } + + hashCode.Add(typedConstant.Value); + } } }