Skip to content

FFS0029/FFS0030: Do not trigger in unit test assemblies #429

@credfeto

Description

@credfeto

Problem

FFS0029 (MockBaseClassInstancesMustBeInternal) and FFS0030 (MockBaseClassInstancesMustBeSealed) currently fire in unit test assemblies. In FunFair.Test.Common, the MockBase<T> base classes are intentionally public and abstract so that consuming test projects in other assemblies can derive from them. They cannot be internal or sealed by design.

Currently this requires suppressions:

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

These suppressions themselves trigger FFS0049, which is why whitelist entries were added to SuppressMessageDiagnosticsAnalyzer. This is a layered workaround.

Solution

In ClassVisibilityDiagnosticsAnalyzer (which raises FFS0029/FFS0030), add a check for IsUnitTestAssembly() and skip both diagnostics when the compilation is a unit test assembly.

Once done, the corresponding whitelist entries for FFS0029 and FFS0030 in SuppressMessageDiagnosticsAnalyzer.AllowedSuppressions should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions