Moq.Analyzers 0.4.0

dotnet add package Moq.Analyzers --version 0.4.0
                    
NuGet\Install-Package Moq.Analyzers -Version 0.4.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="Moq.Analyzers" Version="0.4.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="Moq.Analyzers" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Moq.Analyzers">
  <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 Moq.Analyzers --version 0.4.0
                    
#r "nuget: Moq.Analyzers, 0.4.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 Moq.Analyzers@0.4.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=Moq.Analyzers&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Moq.Analyzers&version=0.4.0
                    
Install as a Cake Tool

Moq.Analyzers

NuGet Version NuGet Downloads Main build Codacy Grade Badge Codacy Coverage Badge Ask DeepWiki

Moq.Analyzers is a Roslyn analyzer that helps you to write unit tests using the popular Moq framework. Moq.Analyzers protects you from common mistakes and warns you if something is wrong with your Moq configuration.

Analyzer rules

ID Category Title
Moq1000 Usage Sealed classes cannot be mocked
Moq1001 Usage Mocked interfaces cannot have constructor parameters
Moq1002 Usage Parameters provided into mock do not match any existing constructors
Moq1100 Correctness Callback signature must match the signature of the mocked method
Moq1101 Usage SetupGet/SetupSet/SetupProperty should be used for properties, not for methods
Moq1200 Correctness Setup should be used only for overridable members
Moq1201 Correctness Setup of async methods should use .ReturnsAsync instance instead of .Result
Moq1202 Correctness Raise event arguments should match the event delegate signature
Moq1203 Correctness Method setup should specify a return value
Moq1204 Correctness Raises event arguments should match event signature
Moq1205 Correctness Event setup handler type should match event delegate type
Moq1206 Correctness Async method setups should use ReturnsAsync instead of Returns with async lambda
Moq1207 Correctness SetupSequence should be used only for overridable members
Moq1210 Correctness Verify should be used only for overridable members
Moq1300 Usage Mock.As() should take interfaces only
Moq1301 Usage Mock.Get() should not take literals
Moq1400 Best Practice Explicitly choose a mocking behavior instead of relying on the default (Loose) behavior
Moq1410 Best Practice Explicitly set the Strict mocking behavior
Moq1500 Best Practice MockRepository.Verify() should be called

See docs/rules/README.md for full documentation.

Getting started

Moq.Analyzers is installed from NuGet. Run this command for your test project(s):

dotnet add package Moq.Analyzers

NOTE: You must use a supported version of the .NET SDK (i.e. 8.0 or later).

Configuring rules

Moq.Analyzers follows existing conventions for enabling, disabling, or suppressing rules. See Suppress code analysis warnings - .NET | Microsoft Learn for documentation on how to configure rules for your project.

Contributions welcome

Moq.Analyzers continues to evolve and add new features. Any help will be appreciated. You can report issues, develop new features, improve the documentation, or do other cool stuff. See CONTRIBUTING.md.

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Moq.Analyzers:

Package Downloads
Reo.Core.Testing

Package Description

Reo.Core.IntegrationTesting

Package Description

Reo.Core.CodeGeneratorTesting

Package Description

Reo.Core.Testing.31

Package Description

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on Moq.Analyzers:

Repository Stars
microsoft/semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
Richasy/Rodel.Agent
支持主流在线 AI 服务的应用
Version Downloads Last Updated
0.4.0 8,436 11/27/2025
0.4.0-alpha 450 11/13/2025
0.3.1 117,301 9/19/2025
0.3.0 384,240 1/21/2025
0.3.0-alpha-0001 192 1/17/2025
0.3.0-alpha 197 12/24/2024
0.2.0 61,208 10/20/2024
0.2.0-alpha 179 10/20/2024
0.1.2 103,469 8/28/2024
0.1.1 70,683 6/28/2024
0.1.0 85,900 6/4/2024
0.1.0-beta 157 6/4/2024
0.0.9 847,125 1/11/2022
0.0.8 765,918 8/11/2019
0.0.7 5,465 7/28/2019
0.0.6 1,236 7/28/2019
0.0.4.43043 56,403 11/26/2017
0.0.4.41458 3,374 11/26/2017
0.0.3.40797 3,335 11/26/2017
0.0.1.22865 3,945 11/26/2017