Fix O(n²) hash collisions in DuplicateDataRowAnalyzer#7803
Open
Fix O(n²) hash collisions in DuplicateDataRowAnalyzer#7803
Conversation
…lue in GetHashCode Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/2135dfb7-7ef6-4958-953f-5384259bfc39 Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix O(n2) hash collisions in DuplicateDataRowAnalyzer
Fix O(n²) hash collisions in DuplicateDataRowAnalyzer
Apr 24, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Improves DuplicateDataRowAnalyzer performance by strengthening hashing for [DataRow] constructor arguments so dictionary lookups don’t degrade due to excessive hash collisions.
Changes:
- Extend
TypedConstantArrayComparer.GetHashCodeto incorporateTypedConstant.Valuewhen non-null. - Recursively hash array-typed constants to mirror the recursive equality logic.
Show a summary per file
| File | Description |
|---|---|
| src/Analyzers/MSTest.Analyzers/DuplicateDataRowAnalyzer.cs | Updates hashing logic for typed constants (including arrays) to reduce collisions and improve analyzer performance. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Agent-Logs-Url: https://github.com/microsoft/testfx/sessions/dacb1394-4b55-4396-a616-e924d625f66b Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TypedConstantArrayComparer.GetHashCodeonly hashedKindandType, ignoringValue. This caused all[DataRow(T)]attributes sharing the same parameter type to produce identical hashes, degrading every dictionary lookup to O(n) and making duplicate detection O(n²).Change
Include
Valuein the hash, matching the logic already present inEquals:Equalsnull-handling).Equalspath.[DataRow]attributes on a single test method.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
x3yvsblobprodcus370.vsblob.vsassets.io/home/REDACTED/work/testfx/testfx/artifacts/bin/MSTest.Analyzers.UnitTests/Release/net8.0/MSTest.Analyzers.UnitTests /home/REDACTED/work/testfx/testfx/artifacts/bin/MSTest.Analyzers.UnitTests/Release/net8.0/MSTest.Analyzers.UnitTests --diagnostic --diagnostic-output-directory /home/REDACTED/work/testfx/testfx/artifacts/log/Release --diagnostic-file-prefix MSTest.Analyzers.UnitTests_net8.0_Release_x64 --diagnostic-verbosity trace --crashdump --hangdump --hangdump-timeout 15m --report-azdo --coverage --coverage-settings /home/REDACTED/work/testfx/testfx/test/coverage.config --coverage-output MSTest.Analyzers.UnitTests_net8.0_Release_x64.coverage --filter DuplicateDataRow(dns block)If you need me to access, download, or install something from one of these locations, you can either: