Closed cocowalla closed 5 years ago
"Not sure if it should matter, but SwaggerDocumentRegistration, which is part of the NSwag assembly, is an internal class." -- it definitely matters. Lamar has to treat internal types very differently. I'll try to reproduce this later in the week
@cocowalla This one's going to be nasty because of all the damn internals. Lamar really doesn't want you using internal types, and I never realized that that was even common to put things in the IoC container before doing Lamar. Honestly, it'd be way easier to just do a PR to NSwag.
This does work with Microsoft's DI library, so i guess it's a common scenario, or they wouldn't have added it - but yeah, it does seem odd to rely on DI for internal types...
They're the ones who cause this issue in the first place. StructureMap handles it fine too. Anything that uses compiled Expressions can deal with that. My concept for Lamar was specifically to avoid having to do that 'cause it's so damn nasty to work with.
The NSwag author agreed and changed the internal
type to public
, so this specific issue is probably resolved now (will test it on Monday).
Not sure if you want to keep this open and think about a strategy for resolving internal types, or if you prefer Lamar to be opinionated and not handle this anti-pattern? (if it's the latter, I fully understand why)
I think this is more or less resolved
I think this is not resolved, it is related with #135, from what i understand this will be related to #136.
I tried adding NSwag.AspNetCore to a web API project that is using Lamar, but it appears to be resolving the wrong type for one of the dependencies, which is resulting in an exception.
When running, it will throw at
app.UseSwagger()
with:So it appears to be resolving
Object[]
instead of the expectedIEnumerable<SwaggerDocumentRegistration>
. Not sure if it should matter, butSwaggerDocumentRegistration
, which is part of the NSwag assembly, is aninternal
class. Could be related to #106?Reproduce To reproduce, start an empty ASP .NET Core API project from the default Visual Studio template, and add these packages:
In
Program.cs
, add the call to.UseLamar()
, as usual. InStartup.ConfigureContainer
, add:Finally, in
Startup.Configure
, add:When running, it will throw at
app.UseSwagger()
.