Skip to content

FFS0012: Do not trigger on benchmark classes #426

@credfeto

Description

@credfeto

Summary

FFS0012 (Classes should be sealed, static, or abstract) currently fires on classes that contain [Benchmark] methods, even though benchmark classes cannot be sealed — BenchmarkDotNet requires them to be instantiable non-sealed classes.

Current workaround

The codebase already has a whitelist entry in SuppressMessageDiagnosticsAnalyzer allowing [SuppressMessage] for FFS0012 on classes that contain benchmark methods. This means developers must add a SuppressMessage to every benchmark class.

Desired behaviour

FFS0012 should not trigger at all on a class that contains one or more methods decorated with [Benchmark], matching the same condition already used by the SuppressMessage whitelist.

Acceptance criteria

  • FFS0012 does not fire on a class that has at least one method with a [Benchmark] attribute
  • FFS0012 continues to fire on all other non-sealed, non-static, non-abstract classes
  • Existing tests updated / new tests added to cover the benchmark exemption

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