Pretender 0.1.4-prerelease

This is a prerelease version of Pretender.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Pretender --version 0.1.4-prerelease
NuGet\Install-Package Pretender -Version 0.1.4-prerelease
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="Pretender" Version="0.1.4-prerelease" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pretender --version 0.1.4-prerelease
#r "nuget: Pretender, 0.1.4-prerelease"
#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.
// Install Pretender as a Cake Addin
#addin nuget:?package=Pretender&version=0.1.4-prerelease&prerelease

// Install Pretender as a Cake Tool
#tool nuget:?package=Pretender&version=0.1.4-prerelease&prerelease




var pretendMyInterface = Pretend.That<IMyInterface>();

    .Setup(i => i.MyMethod(It.IsAny<string>(), 14))

var myInterface = pretendMyInterface.Create();

Benchmarks vs Competitors

Doing a simple Is.IsAny<string>() or equivalent call.

Method Mean Error StdDev Median Ratio RatioSD Gen0 Gen1 Allocated Alloc Ratio
MoqTest 45,863.83 ns 897.457 ns 1,641.051 ns 45,172.41 ns 509.57 19.58 1.3428 1.2207 8850 B 22.12
NSubstituteTest 4,151.76 ns 82.517 ns 126.012 ns 4,133.53 ns 45.69 1.68 1.2360 0.0381 7760 B 19.40
PretenderTest 91.08 ns 1.432 ns 1.270 ns 91.33 ns 1.00 0.00 0.0637 - 400 B 1.00


  • Intercept .Create calls
  • Base implementation name off of ITypeSymbol derived info
  • Async/Task Support
  • Benchmark vs NSub & Moq
  • Property Support
  • Compiled Setup calls
  • Intercept Setup calls
  • Support Base MatcherAttribute
  • Special case AnyMatcher
  • Multiple uses of single type
  • Classes
  • Constructor support
  • out parameters
  • Make our own delegate for matcher calls
  • Maybe not even use expressions in Setup
  • Use Span<object?> for CallInfo arguments
  • Multiple method overloads


  • Check how many times a call has been made
  • Take constructor args in .Create() call
  • Respect [Pretend] attribute that is placed on a partial class
  • A lot more benchmarks
  • Property setter
  • Static Abstract (not support but we should fake an implementation)
  • More matchers
  • Probably need a static matcher register 😦
  • Support Matcher arguments and fallback if impossible
  • Obsolete public types that exist only for SourceGen
  • And move to Pretender.Internals namespace
  • pragma disable obsolete warnings
  • More Behaviors
  • Use CancellationToken everywhere


  • Special case known good fake implementation over mocking
    • EphemeralDataProtectionProvider
    • TimeProvider
  • Make Pretend Implementation castable to something you can get the Pretend out of

Future Ideas

  • What can I do with things that are protected or sealed
  • Analyze all the things
  • Custom awaitable (honestly don't think I care)
  • Analyze constructor args them for likely match
  • Debugger story
    • We do people want to step into
    • What objects will they inspect and how can it be helpful
  • Documentation
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
0.1.5-prerelease 49 4/22/2024
0.1.4-prerelease 123 12/24/2023
0.1.3-prerelease 100 11/19/2023
0.1.2-prerelease 70 9/24/2023
0.1.1-prerelease 61 9/24/2023
0.1.0-prerelease 62 9/24/2023
0.0.2-prerelease 88 8/20/2023
0.0.1-prerelease 70 8/19/2023