NSubstitute v4.0.0 Release Notes
Release Date: 2019-01-01 // over 5 years ago-
Thanks to core team member Alex Povar (@zvirja) for putting a huge amount of work into ๐ defining and implementing features, fixes and refactoring for this release! Also thanks to @tpodolak for the new NSubstitute.Analyzers project! Finally, thanks to everyone who submitted PRs, raised or commented on issues, or took the time to help answer questions on StackOverflow.
Major new features and improvements
- [NEW] NSubstitute.Analyzers project. ๐ง Uses Roslyn to detect potential problems with NSubstitute configurations, such as trying to substitute for non-virtual members. Whenever you add NSubstitute to your C# or VB project, ๐ฆ don't forget to also add the corresponding NSubstitute.Analyzers package! Thanks to @tpodolak for starting and running this project!
- [NEW]
CallBase
for enabling base method calls for specific methods. (#449, @zvirja) - [NEW][BREAKING] Arg matchers (
Arg.Is
etc) can now be used forref
andout
arguments. ๐ See [BreakingChanges.md](BreakingChanges.md) if you are still using pre-C#7. (#404, @zvirja) - ๐ง [NEW]
Configure()
extension inNSubstitute.Extensions.ConfigurationExtensions
to ๐ง ensure NSubstitute handles the next call as a configuration/specification. (#350, @zvirja) - ๐ [UPDATE] Performance improvements. (@zvirja)
CallResults
performance optimisation- Delegate proxy generation improvements (#362)
- Minimise allocations and LINQ use on hot code paths (#390)
- Optimise array allocation (#395)
- โก๏ธ [UPDATE][BREAKING] Calls made with one or more argument matchers (
Arg.Is
orArg.Any
) ๐ง will no longer return previously configured results. NSubstitute will assume the call is ๐ง being configured and avoid running logic configured via previousReturns()
calls. ๐ This helps fix some problems with overlapping configurations. See #345 and [BreakingChanges.md](BreakingChanges.md) for more information. (@zvirja)
๐ New and improved debugging, errors and error messages
- ๐ง [NEW] Raise
CouldNotConfigureBaseMethodException
when trying to configure a call to call a base method that does not exist. (#429, @zvirja) - [NEW] Raise
RedundantArgumentMatcherException
if extra arg matchers are detected. This is โ a huge help for immediately identifying misconfigured tests. (@zvirja) - โก๏ธ [UPDATE] Improved
AmbiguousArgumentsException
behaviour and errors. (#403 and others; @zvirja) - [NEW] Improve debugging experience with proxy ids. (#39, @zvirja)
- โก๏ธ [UPDATE] Improved display of
MatchArgs
to help with debugging. (@zvirja) - โ [NEW][BREAKING] Detection of unused argument matchers. This helps to identify errors in tests due to incorrectly used argument matchers. (#361, #89, #279; @zvirja)
And lots, lots more!
Including (but not limited to):
- ๐ [NEW] Support for netstandard-2.0. (#447, @zvirja)
- [FIX] Improved handling of virtual calls in constructors. (#423, @zvirja)
- ๐ง [NEW] Added a set of
When()
overloads to configure async methods without compilation warnings. (#468, @zvirja) - ๐ [FIX] Fixed potential for
ArgumentNullException
on finalizer thread. (#382, @zvirja) - โก๏ธ [UPDATE] Now using Castle.Core 4.3.1+. We :heart: you Castle.Core! (Thanks for the PR Alexandr Nikitin!)
- [NEW] Expose
.Received(Quantity)
inNSubstitute.ReceivedExtensions
namespace. Thanks to @firelizzard18 for this suggestion. - โก๏ธ [UPDATE] Made substitute setup and verification more robust in the concurrent environments. (#462, @zvirja)
- โก๏ธ [UPDATE] Removed NSubstitute.Core.Extensions.Zip (no longer require NET35 support). (#336)
- ๐ [FIX] Restored XML documentation. (#345)
- [NEW] Made global NSubstitute customization more easier. (#448, @zvirja)
- ๐ [UPDATE] Documentation updates and fixes. Thanks to @jsbed, Chris Maddock, Jim Aho (#369), and Mathias Lorenzen.
- โก๏ธ [UPDATE] Updated builds thanks to Alexandr Nikitin.
- ๐จ [UPDATE] Significant refactoring thanks to Alex Povar. (#448 and many, many other PRs)