Skip to content

FFS0024: Do not trigger in unit test assemblies #428

@credfeto

Description

@credfeto

Problem

FFS0024 (LoggerParametersOnLeafClassesShouldUseGenericLoggerCategory) currently fires in unit test assemblies. In FunFair.Test.Common, the MockLogger class wraps the non-generic ILogger interface directly (it is a mock, not injected via DI), so it legitimately cannot use the generic ILogger<TCategoryName>.

Currently this requires a suppression:

[SuppressMessage("FunFair.CodeAnalysis", "FFS0024: ...", Justification = "...")]

This suppression itself triggers FFS0049, which is why a whitelist entry was added to SuppressMessageDiagnosticsAnalyzer. This is a layered workaround.

Solution

In ConstructorGenericParameterTypeDiagnosticsAnalyser (which raises FFS0024), add a check for IsUnitTestAssembly() and skip the diagnostic when the compilation is a unit test assembly.

Once done, the corresponding whitelist entry for FFS0024 in SuppressMessageDiagnosticsAnalyzer.AllowedSuppressions should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions