Skip to content

Analyzer that flags [ClassCleanup] where the cleanup behavior is not set #3227

Closed
@Evangelink

Description

@Evangelink

Summary

Analyzer that flags [ClassCleanup] where the cleanup behavior is not set.

Background and Motivation

As of today, [ClassCleanup] will by default be run at the end of the assembly and not at the end of the class. Until we move to v4 and can break this behavior, it'd be interesting to introduce an analyzer that would flag when the behavior is not explicitely set so we can ensure the user really wanted to run at the end of the assembly.

Proposed Feature

Flag:

[TestClass]
public class C
{
    [ClassCleanup]
    public static Cleanup() {}
}

and the other overloads where the cleanup behavior is not specified.

Rule info:

  • Category: Usage
  • Severity: Info
  • Enabled by default: true

Alternative Designs

We could have edited the rule MSTEST0011 but this rule should not be warning by default on a minor release as we don't want to break build for something that doesn't result in a guaranteed runtime error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions