-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[WIP] Type catalog (Making type scanning instance based) #1846
Conversation
Right, just found the first pain point. While going back and changing direct uses of ADATS into At this point, the bootstrapper is not created (and initialised) so there won't be an |
Merged. |
😉 I think for the bootstrapper locator we should just put scanning logic directly in there, rather than using adats |
fyi, Some typos on the xml comments - determin -> determine |
…rapperLocator scanning logic
ping @NancyFx/most-valued-minions @NancyFx/nancy-core-contributors I updated the description with information on all of the (remaining) places where ADATS is directly used. Some of them are simple to resolve, but there are a bunch of them that will require us to change things around, so feedback'a'hoy! =) |
So |
That was also my immediate reaction, but after thinking about it a bit more I do not think it is the path we want to follow. I reckon that most This is how we currently rig up the protected ITypeCatalog TypeCatalog
{
get { return new DefaultTypeCatalog(); }
} We then register it as an instance in the container, using the |
Moving this off 1.2 since it'll take a bit longer for it to be finished 😄 |
One thing to remember is that DNX does not have an AppDomain and reflection API is slightly different so we may need some #ifdef or we try doing it differently somehow |
We can just base a DNX |
For reference, this is how MVC does it: https://github.com/aspnet/Mvc/blob/d95e9956fe7233064a500ce90a3305c762cb2e37/src/Microsoft.AspNet.Mvc.Core/DefaultAssemblyProvider.cs Remind you of something you've seen before? 😉 |
C# 6 too - get them! ;) On 15 July 2015 at 13:26, Kristian Hellang [email protected] wrote:
|
If I can't get to it before I will look at it when I'm on holiday start of August.. hoping to look before then though :) |
For
It works, but it is a bit ugly. The entire |
Made the following changes to allow Changed the signature of the protected virtual Func<ITypeCatalog, NancyInternalConfiguration> InternalConfiguration
{
get
{
return NancyInternalConfiguration.Default;
}
} The The bootstrapper will then grab the actual instance, by passing in the I've also changes, so that internally, the bootstrapper uses this method, instead of goings straight to the private NancyInternalConfiguration GetInternalConfiguration()
{
return this.internalConfiguration ?? (this.internalConfiguration = this.InternalConfiguration.Invoke(this.TypeCatalog));
} which will make sure the instance is cached. Before this chance, |
Do not merge this yet
This is the first swing at making the type scanning instance based. We've introduced the new
ITypeCatalog
interface and stuck it on the bootstrapper in the form of a booststrapper so you can override it with your own implementation. TheDefaultTypeCatalog
implementation is just a proxy around the oldAppDomainAssemblyTypeScanner
with one change, ADATS now delay the scanning until the first time you try to pull types out of it.I'd like to get a round of feedback on this before we pull it in. I know @damianh has had some issued with it not being instance based before, so just want to make sure his old pain point(s) is covered by this change.
Nancy
Registrations
instances are pulled from the container but the problem here is that we would have to enforce a ctor signature (something likeprotected Registrations(ITypeCatalog catalog)
) and force all implementations to call it, so a major breaking changeNancyConventions
in NancyBoostrapperBase.ctorDiagnosticModule
instances and shoving them into the container. We manually create an instance of this in the DiagnosticsHook.Enable method. This should not be a problem because the way we call this method is from inside DefaultDiagnostics which is an implementation ofIDiagnostics
and we pull that from the container already, so we just need to pass it down the chain.DiagnosticModule
, so we can just add it to the ctor signature of the module, no worriesISuperSimpleViewEngineMatcher
and register them in the container. This should not be an issue because it is an implementation ofIRegistrations
and they are pulled from the container, so we should just be able to add the type catalog on the ctorIResourceAssemblyProvider
that we stick into the container, fromNancyInternalConfiguration
so we can just add the catalog to the signature. HOWEVER It does not use ADATS for type discovery, it uses ADATS for ASSEMBLY DISCOVERY it grabs hold of all the loaded assemblies (the ones that ADATS loaded), that are not a Nancy-assembly. This breaks the signature we have forITypeCatalog
(new interface for this pull-request) because it currently only expose methods for grabbing types.Nancy.ViewEngines.Razor
Nancy.Testing
Nancy.ViewEngines.Razor.Tests
Nancy.Demo.Hosting.Aspnet
IResourceAssemblyProvider
implementation. It's used to find all non dynamic assemblies. Again, this is another situation where ADATS is used to get assemblies instead of typesNancy.Demo.Razor.Localiztion
IResourceAssemblyProvider
implementation. It's used to find all non dynamic assemblies. Again, this is another situation where ADATS is used to get assemblies instead of types