fix: Introduce tracing capabilities for debugging rule triggers#63
Open
mfogliatto wants to merge 1 commit into
Open
fix: Introduce tracing capabilities for debugging rule triggers#63mfogliatto wants to merge 1 commit into
mfogliatto wants to merge 1 commit into
Conversation
Adds an ITraceWriter abstraction with NullTraceWriter (disabled) and TraceWriter (enabled) implementations. When EnableTracing is set to true in the ReferenceCop config, all violation detectors emit detailed trace messages explaining rule evaluation: which rules match, which references are evaluated, why violations are triggered or suppressed. - MSBuild task: trace messages are flushed to the build log as normal importance messages with [TRACE] prefix - Roslyn analyzer: trace messages are reported as debug diagnostics - Performance: zero overhead when tracing is disabled (NullTraceWriter short-circuits via IsEnabled check) - Backward compatible: all existing constructors preserved Fixes #31
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.
Summary
Introduces tracing capabilities to help debug why certain references trigger specific rules.
Changes
New files
src/ReferenceCop/Tracing/ITraceWriter.cs— Interface for trace outputsrc/ReferenceCop/Tracing/NullTraceWriter.cs— No-op implementation (zero overhead when disabled)src/ReferenceCop/Tracing/TraceWriter.cs— Collects trace messages in memoryModified files
ReferenceCopConfig.cs— AddedEnableTracingconfig propertyReferenceCopConfig.xsd— AddedEnableTracingschema elementProjectTagViolationDetector.cs— Traces rule evaluation (match/skip/suppress/violation)ProjectPathViolationDetector.cs— Traces rule evaluation (match/skip/suppress/violation)AssemblyNameViolationDetector.cs— Traces rule evaluation (match/suppress/violation)BuildEngineExtensions.cs— AddedLogTraceMessagefor MSBuild outputReferenceCopTask.cs— Creates trace writer from config, flushes traces to build logReferenceCopAnalyzer.cs— Creates trace writer, flushes traces as debug diagnosticsHow to use
Set
<EnableTracing>true</EnableTracing>in your ReferenceCop config file. Trace messages will appear:[TRACE]prefix (visible with-v:normalor higher)Design decisions
NullTraceWriter.IsEnabledshort-circuits all string interpolation)Fixes #31