NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
NuGet · #41 most downloaded on NuGet
Moq is the most popular and friendly mocking framework for .NET.
Last release 13 days ago
24 Sep 2026
Release timing varies
gaps range from 4 weeks to 2.0 years
Nearly every release is documented
notes for 59 of the last 60 stable releases
10 versions withdrawn
withdrawn after publishing
127 years old
115 releases · first in 1900
Improve performance of It.Is matcher when used with an expression by compiling only once by @peterder72 in #1512
Full Changelog: v4.20.72...v4.21.0
The following sponsors made this release possible: @clarius, @MFB-Technologies-Inc, @sandrock, @drivenet, @Keflon, @tbolon, @rbnswartz, @jfoshee, @Mrxx99, @eajhnsn1, @Jonathan-Hickey, @KenBonny, @SimonCropp, @agileworks-eu, @arsdragonfly, @vezel-dev, @ChilliCream, @4OTC, @DominicSchell, @adalon, @torutek, @mccaffers, @SeikaLogiciel, @wizardness, @eska-gmbh, @geodata-no.
Thanks 💜
One column per quarter.
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
mock.Invocations.Clear() violates self-consistency of inner mocks #1120:hammer: Other:
DefaultValueProvider extensibility #1450:twisted_rightwards_arrows: Merged:
Remove unused attribute by @kzu in #1515
Update License.txt to use SPDX identifier for automatic recognition by @georg-eckert-zeiss in #1471
Full Changelog: v4.20.70...v4.20.71
:bug: Fixed bugs:
:hammer: Other:
null #1391:twisted_rightwards_arrows: Merged:
Restore GDPR compliance and privacy by @DanWillman in #1402
Full Changelog: v4.20.69...v4.20.70
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Let's make it more memorable when Moq became "safe" again.
Let's make it more memorable when Moq became "safe" again.
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Remove SponsorLink since it breaks MacOS restore by @kzu in https://github.com/moq/moq/pull/1375
NOTE: in addition, there were potential privacy issues raised with regards to the SHA256 hashing of
user' email to check for sponsorship, so it won't be coming back until that's properly addressed
Full Changelog: moq/moq.spikes@v4.20.1...v4.20.2
:bug: Fixed bugs:
:hammer: Other:
Add Sponsor button to package readme 💜
Full Changelog: moq/moq.spikes@v4.20.0...v4.20.1
Add setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319
setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319Mock<T>.RaiseAsync by @stakx in https://github.com/moq/moq/pull/1313ThrowsAsync for non-generic ValueTask by @johnthcall in https://github.com/moq/moq/pull/1235mock.Protected().Verify<T>() method overload by @stakx in https://github.com/moq/moq/pull/1325Full Changelog: moq/moq.spikes@v4.18.4...v4.20.0
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Add 💜 SponsorLink support by @kzu in https://github.com/moq/moq/pull/1363
Full Changelog: moq/moq.spikes@v4.20.0-beta...v4.20.0-rc
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Add setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319
setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319Mock<T>.RaiseAsync by @stakx in https://github.com/moq/moq/pull/1313ThrowsAsync for non-generic ValueTask by @johnthcall in https://github.com/moq/moq/pull/1235mock.Protected().Verify<T>() method overload by @stakx in https://github.com/moq/moq/pull/1325Full Changelog: moq/moq.spikes@v4.18.4...v4.20.0-beta
Add setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319
setup.Verifiable(Times times, [string failMessage]) method by @stakx in https://github.com/moq/moq/pull/1319Mock<T>.RaiseAsync by @stakx in https://github.com/moq/moq/pull/1313ThrowsAsync for non-generic ValueTask by @johnthcall in https://github.com/moq/moq/pull/1235mock.Protected().Verify<T>() method overload by @stakx in https://github.com/moq/moq/pull/1325Full Changelog: moq/moq.spikes@v4.18.4...v4.20.0-alpha
:sparkles: Implemented enhancements:
RaiseAsync method for raising Func<..., Task> events? #1310setup.Verifiable(Times times, [string failMessage]) method #1319 (@stakx):bug: Fixed bugs:
:hammer: Other:
System.TypeLoadException : Could not load type 'Castle.Core.Internal.CollectionExtensions' from assembly 'Castle.Core, Version=5.0.0.0 after updating to Moq 4.18.4 #1320:twisted_rightwards_arrows: Merged:
mock.Protected().Verify<T>() method overload #1325 (@stakx)Mock<T>.RaiseAsync #1313 (@stakx)ThrowsAsync for non-generic ValueTask #1235 (@johnthcall):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
IndexOutOfRangeException #1252:hammer: Other:
MissingMethodException when using new C# language features (in parameters, init-only setters, etc.) with generic methods, or with members in generic types #1148:twisted_rightwards_arrows: Merged:
SetupAllProperties crashes when invoked on a Mock subclass \#1278
:bug: Fixed bugs:
SetupAllProperties crashes when invoked on a Mock<T> subclass #1278:hammer: Other:
in keyword parameter does not match #1292:twisted_rightwards_arrows: Merged:
StubbedPropertiesSetup figure out type parameter in a less fragile way #1281 (@stakx)"Expression is not an event add" when using .Raises\(\) \#1175
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
record type support #1275 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Moq is using Castle.Core which has an old version of System.Net.Http which is vulnerable to "DoS", "Spoofing", "Privilege Escalation", "Authentication…
:bug: Fixed bugs:
CallBase and DefaultValue.Mock configured #1249:hammer: Other:
:twisted_rightwards_arrows: Merged:
Property stubs not working on sub mock \#1240
SetupAllProperties causes mocks to become race-prone \#1231
:bug: Fixed bugs:
Mock.Of #1066:hammer: Other:
:twisted_rightwards_arrows: Merged:
SetupAllProperties #1234 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
.Result property #1132:twisted_rightwards_arrows: Merged:
Returns(InvocationFunc) doesn't throw TargetInvocationException #1141 (@stakx).Result setups #1133 (@stakx)AmbiguousMatchException when interface has indexer besides property #1131 (@mujdatdinc).CallBase for default interface implementations #1130 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
IAwaitableFactory) #1125 (@stakx).Verifiable() once again #1121 (@stakx)moq is not compatible with System.Threading.Tasks.Extensions 4.5.3 or 4.5.4 \#1107
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Nothing published for this version
:sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
Mock.Of\ \(\(m\) =\> ...\) doesn't play well with Microsoft IOptions\ \#1039
:bug: Fixed bugs:
:hammer: Other:
Microsoft.Build.Tasks.Git.LocateRepository task failed unexpectedly." #1060:twisted_rightwards_arrows: Merged:
VerifySet breaks with System.NullReferenceException for WriteOnly-Indexed-Properties \#1036
:bug: Fixed bugs:
:twisted_rightwards_arrows: Merged:
NullReferenceException on subsequent setup if expression contains null reference \#1031
Verify behavior change using DefaultValue.Mock 4.12.0 vs 4.13.0 \#1024
API Documentation page broken. \#1023
:hammer: Other:
:twisted_rightwards_arrows: Merged:
DefaultValue.Mock should not add redundant setups for already-matched invocations #1025 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
:sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
Callback and Returns: Allow callback parameters to have type object where a type matcher was used #953Mock.Setups, part 4: Mock, fluent setup & inner mock discovery #989 (@stakx):bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Mock.Setups, part 6: Replace OriginalSetup with simpler OriginalExpression #999 (@stakx)UpgradePropertyAccessorMethods #998 (@stakx)conditionalSetup.Verifiable() an error #997 (@stakx)Mock.Setups, part 5: Simplify fluent setup & inner mock discovery #995 (@stakx)Func<IInvocation,> callback with Returns #992 (@stakx)Mock.Setups, part 3: Individual setup verification #987 (@stakx)SetupAllProperties' setups #986 (@stakx)Mock.Setups, part 2: Match status of setups & invocations #985 (@stakx)Mock.Setups, part 1: Basics #984 (@stakx)Verify(), VerifyAll() #983 (@stakx)Mock.Of<Class> shouldn't delete invocations made from Class' ctor #980 (@stakx)FluentMockVisitor #978 (@stakx)Times.Validate(count) & Times.ToString() #975 (@stakx)Capture.In working again in Verify expressions #974 (@stakx)mock.SetupProperty throws NullReferenceException when called for partially overridden property \#951
:bug: Fixed bugs:
mock.SetupProperty throws NullReferenceException when called for partially overridden property #951SetupAllProperties does not recognize property as read-write if only setter is overridden #886:hammer: Other:
:twisted_rightwards_arrows: Merged:
SetupProperty for partially overridden properties #952 (@stakx)SetupAllProperties stubs all accessors of partially overridden properties #950 (@stakx)InnerMockSetup (i.e. internal setups for cached return values) match generic args exactly instead of by assignment compatibility. #949 (@stakx)params arrays in setup/verification expressions using structural equality #948 (@stakx)mock.As<> round-tripping #945 (@stakx)InterfaceProxy #944 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
SetupAllProperties resets indexer setups #901:hammer: Other:
:twisted_rightwards_arrows: Merged:
.xdoc XML documentation files #916 (@stakx).ReturnsAsync(null) #915 (@stakx)ParamArrayMatcher #912 (@stakx)Match.Matches and It.IsAny<T> #911 (@stakx)SetupAllProperties indexer regression & refactor accessor check methods for clarity #902 (@stakx)InnerMockSetup on mock.Invocations.Clear() #899 (@stakx)SequenceSetup on mock.Invocations.Clear() #896 (@stakx).editorconfig for auto-generated files #894 (@stakx)Unwrap #885 (@stakx)ExpressionStringBuilder into StringBuilderExtensions #882 (@stakx)ExpressionStringBuilder formatting of ternary conditional operator #881 (@stakx)ExpressionStringBuilder formatting of indexer assignment #880 (@stakx)SetupAllProperties for properties named Item #878 (@stakx)Returns callback delegate validation more strict #876 (@stakx)SetupAllProperties for properties whose name starts with Item #871 (@stakx)mock.Invocations.Clear() remove traces of earlier invocations more thoroughly #854 (@stakx)Breaking Change Moq 4.11 - SetupAllProperties\(\) \(includes Mock.Of\ \) fails in cases it didn't before \#845
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
Callback to a mock breaks async tests #702:twisted_rightwards_arrows: Merged:
.Returns nor .CallBase more consistent #849 (@stakx)VerifyNoOtherCalls: Prevent stack overflow by remembering already verified mocks #848 (@stakx)sequenceSetup.ReturnsAsync(Func<T>) #841 (@stakx).nuspec file #832 (@stakx)Full Changelog
Regression in 4.11.0-rc1: Unhelpful exception message with SetupProperty \#823
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
SetupProperty #824 (@stakx)default(Times) to Times.AtLeastOnce() #820 (@stakx)SetupCollection (esp. ToArrayLive) for better performance #819 (@stakx)bb1840c
This commit was signed with the committer’s verified signature .
stakx Dominique Schuppli
GPG key ID: 093A802C7C9B7B59
Verified Learn about vigilant mode .
This is a pre-release version.
stakx
Re-deprecate [Matcher] attribute? \#770
:sparkles: Implemented enhancements:
mock.Protected().Verify method group has no overloads with bool exactParameterMatch #752:bug: Fixed bugs:
Times.Equals is implemented incorrectly #805VerifyAll throws System.InvalidOperationException: 'Nullable object must have a value.' #711Verify despite being "unreachable" #703Verify can create setups that causes a subsequent VerifyAll to fail #699:hammer: Other:
in string parameter verifying doesn't work in some cases #808[Matcher] attribute? #770Verify #756:twisted_rightwards_arrows: Merged:
Times.Equals #806 (@stakx)MockFactory and MockRepository APIs #800 (@stakx)InvocationShape argument matchers & expressions in sync #793 (@stakx)ConstantMatcher more (but not fully) StackOverflowException-proof #792 (@stakx)MatcherAttribute #788 (@stakx)stringBuilder.AppendValueOf safer #786 (@stakx)netstandard2.0 target #784 (@stakx)ActionObserver improved support for parameterized base class ctors & additional virtual calls #782 (@stakx)It.IsAny by default #780 (@stakx)Verify(...) error message #779 (@stakx)Verify expression validation #778 (@stakx)InvocationShape should be equality-comparable #777 (@stakx)LambdaExpressionPart with InvocationShape #776 (@stakx)AmbientObserver into MatcherObserver #775 (@stakx)Raise #771 (@stakx)AmbientObserver reentrant #769 (@stakx)MatchExpression more robust #768 (@stakx)SetupSet and VerifySet expressions from delegates #767 (@stakx)IProxy interface visibility #766 (@stakx)Setup and Verify & make them recursive #765 (@stakx)System.Object members interceptable by *any* interceptor #764 (@stakx)Mock.InnerMocks with InnerMockSetup #760 (@stakx)CONTRIBUTING.md #754 (@stakx)mock.Protected().Verify overloads with additional exactParameterMatch parameter #753 (@Shereef)mock.Protected().Setup() method overload #751 (@stakx)[Matcher] attribute #732 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
CallBase should not be allowed for delegate mocks #706:hammer: Other:
net45 target causes major build issues in .NET Framework 4.7 projects #719:twisted_rightwards_arrows: Merged:
HandleTracking interception aspect into RecordInvocation #723 (@stakx)FluentMockContext to record >1 matcher per invocation #722 (@stakx)System.ValueTuple NuGet dependency #721 (@stakx)IsSpecialName for properties & indexers #718 (@stakx)MethodCallReturn into MethodCall #717 (@stakx)Mock methods non-generic #716 (@stakx)CallBase should not be allowed for delegate mocks #708 (@m-wild)Mock.DelegateInterfaceMethod #705 (@stakx)FluentMockVisitor classes #698 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
mock.Verify(m => m.Event += callback)) #49:bug: Fixed bugs:
.Callback(…) after .Returns(…) / .CallBase() causes a variety of issues #668.Throws() is specified too #667VerifyAll fail #556Action<...> instead of Expression<Action<...>> in the public API causes a variety of problems #414:hammer: Other:
:twisted_rightwards_arrows: Merged:
MockFactory.VerifyMocks do what it says it does #691 (@stakx)License.txt so GitHub recognizes it #687 (@stakx)VerifyAll ignore setups from SetupAllProperties #684 (@stakx)Verify exception should include complete call expression for delegate mocks #680 (@stakx)Verify exception should report configured setups for delegate mocks #679 (@stakx)VerifyAll + VerifyNoOtherCalls for sequence setups #672 (@stakx)Setup #671 (@stakx)setup.CallBase() for void methods #664 (@stakx)MethodCall classes non-generic #663 (@stakx)InvocationShape #662 (@stakx)MatcherFactory #661 (@stakx)VerifyNoOtherCalls take into account previous calls to parameterless Verify() and VerifyAll() #659 (@stakx)Returns #654 (@stakx)Clean up MockException \(and deprecate IError along the way\) \#634 (@stakx)
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
System.Reflection.Emit #638 (@stakx)MockException (and deprecate IError along the way) #634 (@stakx)IInvocation and IInvocationList #633 (@stakx).StripConversion helper method #631 (@stakx).ToLambda() conversions with static typing #629 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
in ValueType parameters are not supported with .NET Standard / Core #605ReturnsAsync and ThrowsAsync for ValueTask<TResult> #599:bug: Fixed bugs:
:hammer: Other:
Mock.Of<T>() is much slower than new Mock<T> (up to several orders of magnitude) #547CONTRIBUTING.md #471:twisted_rightwards_arrows: Merged:
in parameter modifier is supported #625 (@stakx)ISetupSequentialResult<TResult>.Returns method overload that support delegate for deferred results #594 (@snrnats)NotImplementedException DynamicProxy2 error when CallBase = true while mocking interfaces again \#582
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
:sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
DefaultValue.Empty and DefaultValue.Mock #563 (@stakx)CallBase regression with explicitly implemented interface methods #558 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
Setup #479Setup / Returns #445ValueTask<TResult> to DefaultValue.Empty #529 (@stakx):bug: Fixed bugs:
mock.Verify and mock.VerifyAll leak internal MockVerificationException type #507SetupAllProperties tries to set up inaccessible properties #498Setup does not recognize all virtual sealed methods as uninterceptable #496add_X or remove_X are not recorded #487:hammer: Other:
MethodCall.ToString and MethodCall.Format, and whether we can drop one of them (ideally including MethodCall.SetFileInfo) #503[AssemblyVersion] to major version only (4.0.0.0) to save users from having to configure assembly version redirects #424:twisted_rightwards_arrows: Merged:
SetupAllProperties: Defer property initialization #550 (@stakx)SetupAllProperties #549 (@stakx)VerifyNoOtherCalls: fix bugs with multi-dot expressions #544 (@stakx)VerifyNoOtherCalls: Fix bugs with Mock.Of<T> #543 (@stakx)FluentMockContext #542 (@stakx)ImplementedInterfaces contraption #541 (@stakx)Mock into Mock<T> #540 (@stakx)Mock<T>.VerifyNoOtherCalls() method #539 (@stakx)ref parameters using It.Ref<TValue>.IsAny / ItExpr.Ref<TValue>.IsAny #537 (@stakx)LookupOrFallbackDefaultValueProvider base class for custom default value providers #536 (@stakx)Empty, Mock properties to DefaultValueProvider #535 (@stakx)Mock.Of setup expression #528 (@stakx)EmptyDefaultValueProvider to use dictionary lookup for special type handling #524 (@stakx)Returns more strictly #520 (@stakx)MockVerificationException and catch-throw-recatch cycle during verification #511 (@stakx)Interceptor.calls, ExpressionKey, and SetupKind #509 (@stakx)PexProtector out of the debugger's way #508 (@stakx)DefaultValue.Mock to mock Task<TMockable> and ValueTask<TMockable> #502 (@stakx)Protected().As<T>(): Fix generic method support #501 (@stakx)SetupAllProperties skip inaccessible methods #499 (@stakx)Setup recognition logic for sealed methods #497 (@stakx).Protected().As<TDuck>() to perform duck-typed setup and verification of protected members #495 (@stakx)SetupSequence method group for protected members #493 (@stakx)SetupSequence to make it thread-safe #476 (@stakx)Callback and Returns overloads for setting up methods with ref parameters #468 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
Mock<T>.Raise #457:hammer: Other:
:sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Upgrade Castle Core package dependency to next released version \#470
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Upgrade to Castle.Core version 4.2.0 \#425
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
:sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
mock.SetupGet(o => o.Property).CallBase(), strict mocks throw, demanding that the setup provide a return value #448:hammer: Other:
:twisted_rightwards_arrows: Merged:
.CallBase() can set up a return value, too #450 (@stakx)SetupAllProperties work correctly for same-typed sibling properties #442 (@stakx):sparkles: Implemented enhancements:
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Times in Verify messages #420 (@stakx)ExtractProxyCall #415 (@stakx)Resources.resx #403 (@stakx)Mock<T>.Raise to raise events on child mocks #397 (@stakx)Mock.Of #396 (@stakx)CallBase is true #395 (@stakx)Interceptor more thread-safe #392 (@stakx)Possibly undocumented breaking change in 4.2.1408.0511 \#315
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Interface inheritance introduced a possible breaking change in 4.2.1408.619 \#371
:sparkles: Implemented enhancements:
:bug: Fixed bugs:
:hammer: Other:
:twisted_rightwards_arrows: Merged:
:twisted_rightwards_arrows: Merged:
:twisted_rightwards_arrows: Merged:
Moq.nuspec and package references #379 (@stakx)Clean up the mess of mixed tabs & spaces in code files \#364
:hammer: Other:
:twisted_rightwards_arrows: Merged:
It.IsAny, It.IsNotNull work for COM types #361 (@stakx)ExpressionMatcher.Matches #358 (@stakx)ThrowsAsync overload for non-generic Task #357 (@stakx)Documentation Correction around using Verify\(\) \#332
:hammer: Other:
:twisted_rightwards_arrows: Merged:
Small grammar correction in documentation \#260
:twisted_rightwards_arrows: Merged:
Passing a mock into another mock does not work for me \#174
The dependency Moq \>= 4.7.8 could not be resolved \#339
:hammer: Other:
Protected Verify doesn't accept mocks of interfaces as valid for those interfaces \#334
:hammer: Other:
:twisted_rightwards_arrows: Merged:
:twisted_rightwards_arrows: Merged:
Your coding agent can read these notes before it upgrades. Set up the MCP server →