Skip to content

Add support for NoWarn to prevent warnings for specific references #23

@mfogliatto

Description

@mfogliatto

Description

Currently, ReferenceCop does not leverage/support NoWarn attributes in projects to allow exceptions to the rules in the csproj itself. We need to implement a NoWarn support so references with that attribute won't trigger a warning.

Problem

When defining reference rules in ReferenceCop, there's no way to create exceptions for specific references that might otherwise violate the rules but should be allowed in certain circumstances.

Proposed Solution

  1. Modify violation detectors (particularly AssemblyNameViolationDetector, ProjectPathViolationDetector, and ProjectTagViolationDetector) to check if a reference has the NoWarn attribute in the csproj before reporting it as a violation (only applicable for Warning severity rule violations)
  2. Ensure the NoWarn attributes are considered for all references, across all detectors in both the MSBuild task and the Roslyn analyzer.
  3. Add unit tests for the new functionality
  4. Update documentation

Implementation Details

  • Allow configuring exceptions at the project level
  • Ensure backward compatibility with existing configuration files

Acceptance Criteria

  • Users can specify references that should not trigger warnings despite matching rule patterns
  • Unit tests demonstrate the feature works as expected
  • Documentation is updated to explain the new NoWarn capabilities

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions