Skip to content

How to use DI in ICompileModule #328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wwwlicious opened this issue Feb 20, 2015 · 6 comments
Closed

How to use DI in ICompileModule #328

wwwlicious opened this issue Feb 20, 2015 · 6 comments

Comments

@wwwlicious
Copy link

Looking for guidance in using IServiceProvider within the context of an ICompileModule.

I am creating a new appbuilder, passing in the existing IServiceProvider passed from the host app but was wondering if this is considered improper use. Example code can be found at the links

https://github.com/wwwlicious/R4MVC/blob/master/src/R4Mvc/R4MVCCompilerModule.cs#L38
https://github.com/wwwlicious/R4MVC/blob/master/src/R4Mvc/Ioc/IocConfig.cs

@wwwlicious wwwlicious changed the title How to use DI in PreCompiler How to use DI in ICompileModule Feb 20, 2015
@davidfowl
Copy link
Member

Why are you trying to extend what seems like the application via an ICompileModule?

@wwwlicious
Copy link
Author

It was a suggestion by yourself here to follow the pattern of razorprecompiler. I may have misunderstood..?

@davidfowl
Copy link
Member

Ah is this the T4MVC replacement?

@wwwlicious
Copy link
Author

yes, so was just looking at the razorprecompiler and it makes a bit more sense now I'm a bit more familiar with a few bits.

So should I be creating a service collection just for the compiler module to use, that seems to be what razorprecompiler is doing?

@davidfowl
Copy link
Member

Yes but currently, things generated by ICompileModules don't show up for intellisense in visual studio or omnisharp right now.

@wwwlicious
Copy link
Author

ok, I am writing the r4mvc gen'd file out to disk which avoids that issue as it gets picked up by the compiler second time around, again probably a horrible thing to do but I just don't know any better at the moment :)

wwwlicious pushed a commit to wwwlicious/R4MVC that referenced this issue Feb 22, 2015
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants