I love the simplicity of Munq, but I've encountered a pretty big problem with generic types and any of the lifetime managers that caches the reference using a string key (so ThreadLocalStorage, Request, Session, and Cache).
Simple example of failing code:
var lifetime = new Munq.LifetimeManagers.ThreadLocalStorageLifetime();
var container = new Munq.IocContainer();
Assert.IsNotNull(container.Resolve<IFoo<int>>()); // works
Assert.IsNotNull(container.Resolve<IFoo<string>>()); // fails
The issue is that the key generated for the type is based off of Type.Name (line 31 of
Registration.cs), which in the case of a generic type returns the same string for all types (in my example, both IFoo<int> and IFoo<string> return "IFoo`1"
for their Name). When the lifetime retrieves them from the cache, it casts them using "as", which returns null since it is not the right type.
I believe the solution is as simple as using type.FullName instead of type.Name.