Description
The default (non-experimental) GetViolationsFrom() in AssemblyNameViolationDetector iterates over all rules × all references (O(n×m) complexity). For each rule, it scans every reference with a string comparison. The experimental path already optimizes this with dictionary lookups, but it is not the default.
Affected File
src/ReferenceCop/Detectors/AssemblyNameViolationDetector.cs (lines 29-48, GetViolationsFrom)
Impact
- Medium. For typical projects with 50-200 assembly references and 10-50 rules, this is 500-10,000 comparisons per compilation. In large solutions with many projects analyzed concurrently (IDE scenario), this adds up.
- The experimental detector already solves this but requires opt-in via config.
Suggested Optimization
Consider making the experimental detector the default (it is functionally equivalent for exact matches and only iterates patterns separately):
// The experimental path is O(n + n*p) where p = pattern count (usually small)
// vs the current O(n*m) where m = all rules
Alternatively, graduate the experimental detector to be the default behavior and remove the legacy path after validation.
Description
The default (non-experimental)
GetViolationsFrom()inAssemblyNameViolationDetectoriterates over all rules × all references (O(n×m) complexity). For each rule, it scans every reference with a string comparison. The experimental path already optimizes this with dictionary lookups, but it is not the default.Affected File
src/ReferenceCop/Detectors/AssemblyNameViolationDetector.cs(lines 29-48,GetViolationsFrom)Impact
Suggested Optimization
Consider making the experimental detector the default (it is functionally equivalent for exact matches and only iterates patterns separately):
Alternatively, graduate the experimental detector to be the default behavior and remove the legacy path after validation.