question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Non generic version of A.Fake(Type t) is missing

See original GitHub issue

To be able to use FakeItEasy in conjunction with Simple Injector, I’d like to do the following:

container.ResolveUnregisteredType += 
    (sender, args) => args.Register(() =>A.Fake(args.UnregisteredServiceType));

However, there is no publicly available method that supports providing the type as non generic argument, although IFakeAndDummyManager.CreateFake works this way (but is internal).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thomaslevesquecommented, Mar 15, 2018

Hi @marcwittke,

The non-generic API exists, but it’s hidden because it’s not commonly used by most people: FakeItEasy.Sdk.Create.Fake(Type).

0reactions
marcwittkecommented, Apr 4, 2018

this FakeItEasy.Sdk.Create.Fake(Type) was exactly what I was missing, thanks. sorry for the delay…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Non-generic Fake and Dummy creation · Issue #482
I just realized that A.Fake doesn't have a non-generic overload accepting a Type parameter, which would be very useful in some scenarios.
Read more >
Why are missing type parameters inferred as unknown in ...
I would expect the call of doStuff to be an error as the type parameter is missing. Instead it infers unknown so the...
Read more >
Allow Faking of non-generic types with methods that have in ...
NET Standard, and if the type is a generic type, it cannot be faked by either the FakeItEasy .NET Standard or .NET Framework...
Read more >
Go generics are not bad
Can't hate on generics, so we need to find something else. Go takes away type system fidget spinners and leave devs with nothing...
Read more >
4. Generics - Programming C# 5.0 [Book]
In Chapter 3, I showed how to write types and described the various kinds of members they can contain. However, there's an extra...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found