Skip to main content
Any Framework

This package includes code analyzers and code fixes for MSTest. MSTest is Microsoft supported Test Framework.

Published
Oct 27, 2026
26d ago
Total Downloads
89.3M
89,282,032

Deprecated Package Version

Reason: Legacy

Install

dotnet add package MSTest.Analyzers --version 4.5.2

No framework information available.

README

MSTest.Analyzers

MSTest is Microsoft supported Test Framework.

This package includes static code analyzers for C# and VB.NET helping you to better use and design your tests. For access to the testing framework, install the MSTest.TestFramework package.

Pinning constant contracts

MSTEST0032 reports assertions whose conditions are always true, but permits Assert.AreEqual(16, Protocol.HeaderSize) when HeaderSize is a const field in a referenced assembly. Comparing an independently written literal with a dependency's constant can pin a compatibility contract: changing the constant and recompiling the test makes the assertion fail. Replacing the dependency without recompiling the test does not update an inlined constant.

The exemption accepts literal values (including strings and signed numbers) on either side, named arguments, parentheses, and implicit built-in conversions. It does not apply to constants compiled into the test assembly, including linked/shared source. Local constants, arithmetic expressions, explicit casts, and self-comparisons remain diagnostic. Boolean assertions such as Assert.IsTrue(Protocol.HeaderSize == 16) are unchanged, as is the existing exemption for pinning enum members cast to their exact underlying type.

Changes from Previous Version

No structural changes between v4.5.1 and v4.5.2.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

NuGet marks this package as deprecated. Review the publisher's migration guidance before adopting it.No target framework metadata is available. Confirm compatibility in a representative project before standardising on this package.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.