Optimize AssemblyNameViolationDetector to O(n) time complexity#45
Merged
mfogliatto merged 8 commits intomainfrom Dec 24, 2025
Merged
Optimize AssemblyNameViolationDetector to O(n) time complexity#45mfogliatto merged 8 commits intomainfrom
mfogliatto merged 8 commits intomainfrom
Conversation
Also includes config flag to switch on and to enable debug messages
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.
Description
This PR improves the time complexity of
AssemblyNameViolationDetectorfrom O(m*n) to O(n), where m is the number of rules and n is the number of references. The optimization is achieved by reversing the lookup strategy: instead of iterating over rules for each reference, we now build a dictionary of references and check each rule against it in O(1) time.Type of change
Related Issue
Closes #28
Implementation Details
Core Changes
UseExperimentalDetectorsandEnableDebugMessagesflags toReferenceCopConfigto enable the new implementationPerformance Improvements
Benchmark Results
Performance testing was conducted using BenchmarkDotNet across various scenarios with different numbers of rules and references:
Key Findings:
The experimental implementation shows the most significant improvements when dealing with:
How Has This Been Tested?
Screenshots (if applicable)
N/A - Performance improvement, no UI changes
Additional context