UTFAnalyzers 1.2.0

dotnet add package UTFAnalyzers --version 1.2.0
                    
NuGet\Install-Package UTFAnalyzers -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UTFAnalyzers" Version="1.2.0">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UTFAnalyzers" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="UTFAnalyzers">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UTFAnalyzers --version 1.2.0
                    
#r "nuget: UTFAnalyzers, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UTFAnalyzers@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UTFAnalyzers&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=UTFAnalyzers&version=1.2.0
                    
Install as a Cake Tool

UTF Analyzers

Meta file check Build NuGet openupm

This package provides Roslyn analyzers to help you write safer unit tests with the Unity Test Framework. It diagnoses API usage that could cause Unity Editor freezes or runtime errors before running tests and suggests best practices.

Required

  • Unity 2022.3.12f1 or later

Diagnostics

Baseline version

The analyzers diagnose against the Unity Test Framework package v1.4.6 as the baseline. UTF v1.4.6 is the last version you can update independently as a UPM package.

[!CAUTION]
Versions earlier than the baseline have bugs that these analyzers do not diagnose. Update to UTF v1.4.6 or later.

[!TIP]
Diagnostics remain even if the bug is fixed in UTF v1.5.0 or later. If the bug is fixed in the version you are using, suppress the diagnostic in your project via .editorconfig or .globalconfig.

Structure (UTF1xxx)

Rules about test method signatures and attribute combinations.

Id Title Severity
UTF1001 TestCase and TestCaseSource attributes are not supported on coroutine-style test methods
UTF1002 Task<TResult> is not supported as a test method return type
UTF1003 Pairwise, Sequential, and Combinatorial attributes are not supported on coroutine-style test methods
UTF1004 OneTimeSetUp and OneTimeTearDown attributes are not supported on async methods
UTF1005 Attributes implementing ICommandWrapper are not supported on async and coroutine-style test methods

Assertion (UTF2xxx)

Rules about misuse of assertions and constraints.

Id Title Severity
UTF2001 Assert.ThrowsAsync, CatchAsync, and DoesNotThrowAsync are not supported
UTF2002 Async delegates are not supported as the actual value of Throws constraints, Assert.Throws, Assert.Catch, and Assert.DoesNotThrow
UTF2003 Async delegates are not supported as the actual value of the constraint model
UTF2004 Only TestDelegate is supported as the actual value of the AllocatingGCMemory constraint
UTF2005 DelayedConstraint is not supported

Suppressor (UTF3xxx)

Suppressions of diagnostics reported by other analyzers that do not apply to Unity Test Framework.

Id Title
UTF3001 Suppress NUnit2045 (Use Assert.Multiple) when Assert.Multiple is not available
UTF3002 Suppress CS8618 (Non-nullable field or property is uninitialized) when the member is initialized in a UnitySetUp or UnityOneTimeSetUp method
UTF3003 Suppress CA1001 (Types that own disposable fields should be disposable) on test fixtures with a UnityTearDown or UnityOneTimeTearDown method
UTF3004 Suppress NUnit1028 (The non-test method is public) on UnitySetUp, UnityOneTimeSetUp, UnityTearDown, and UnityOneTimeTearDown methods
UTF3005 Suppress CA1707 (Identifiers should not contain underscores) on test methods
UTF3006 Suppress VSTHRD200 (Use Async suffix for async methods) on test methods

Style (UTF4xxx)

Rules about code that works but is not recommended.

Id Title Severity

Extensions (UTF5xxx)

Rules for authors of custom attributes, constraints, and comparers.

Id Title Severity
UTF5001 ApplyToTest, ApplyToContext, and Wrap must not throw exceptions
UTF5002 Implementing IWrapTestMethod and IWrapSetUpTearDown is not recommended ⚠️
UTF5003 Attributes implementing IOuterUnityTestAction must restrict their targets with AttributeUsage ⚠️
UTF5004 Attributes implementing ITestAction must restrict their targets with AttributeUsage ⚠️

Installation

This package is published to both UPM and NuGet. Choose one of the following.

Install UPM package via OpenUPM

  1. Open the Project Settings window (Editor > Project Settings) and select Package Manager tab
  2. Click + button under the Scoped Registries and enter the following settings:
    1. Name: package.openupm.com
    2. URL: https://package.openupm.com
    3. Scope(s): com.nowsprinting
  3. Open the Package Manager window (Window > Package Manager) and select My Registries tab
  4. Select UTF Analyzers and click the Install button

[!TIP]
You do not need to add a reference to the test assembly definition file (asmdef). Because it's configured via an assembly definition reference file (asmref) to apply across all test assemblies.

[!TIP]
The UPM package also includes the following:

  • Unity Test Framework v1.4.6 (dependency)
  • NUnit.Analyzers v3.9.0 (bundled)

UTFAnalyzers does not require either of these. If you do not need them, use the NuGet package instead.

Install NuGet package via NuGetForUnity

  1. Open the NuGetForUnity window via NuGet > Manage NuGet Packages
  2. Search "UTFAnalyzers" and click Install

License

MIT License

How to contribute

Open an issue or create a pull request.

Be grateful if you could label the PR as enhancement, bug, chore, and documentation. See the autolabeler section in release-drafter settings for automatically labeling from the branch name.

How to development

Clone repo as a embedded package

Clone this repository as a submodule under the Packages/ directory in your project.

git submodule add git@github.com:nowsprinting/test-framework.analyzers.git Packages/com.nowsprinting.test-framework.analyzers

Run Tests

cd Packages/com.nowsprinting.test-framework.analyzers/UTF.Analyzers~
dotnet test

Build

cd Packages/com.nowsprinting.test-framework.analyzers/UTF.Analyzers~
dotnet build -c Release UTF.Analyzers

After the Release build, UTF.Analyzers.dll is automatically copied to Analyzers/UTF.Analyzers/. Please commit the copied DLL; it will be distributed as part of the UPM package.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 68 9/12/2026
1.1.1 90 9/11/2026
1.1.0 145 9/7/2026
1.0.1 168 9/7/2026
1.0.0 159 9/7/2026