Skip to content
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

Can't use NSwag.Build, because of cleaning of hosted services. #4722

Closed
bielu opened this issue Jan 22, 2024 · 5 comments · Fixed by #4756
Closed

Can't use NSwag.Build, because of cleaning of hosted services. #4722

bielu opened this issue Jan 22, 2024 · 5 comments · Fixed by #4756

Comments

@bielu
Copy link

bielu commented Jan 22, 2024

Hi!
I was looking into generating Typecript services and models with usage of nswag, but noticed that it will not work because of :
https://github.com/RicoSuter/NSwag/blob/116c636fb7491623eb6c70725b8fb20c450ec96c/src/NSwag.Commands/HostApplication.cs#L112C23-L119C26
I am trying understand why it was introduced when using GetServiceProviderWithHostFactoryResolver.
As right now I can't generate models when using umbraco cms, as it will throw me missing services which are host services!

@bielu bielu changed the title Can't use NSwag.Build, becaus eof cleaning of hosted services. Can't use NSwag.Build, because of cleaning of hosted services. Jan 22, 2024
@RicoSuter
Copy link
Owner

See #4523

@desjoerd
Copy link
Contributor

desjoerd commented Feb 3, 2024

Which IHostedService is being resolved and gives the exception?

@desjoerd
Copy link
Contributor

desjoerd commented Feb 3, 2024

Hmm, I think the removal of IHostedService registrations is too greedy.

if(typeof(IHostedService).IsAssignableFrom(services[i].ServiceType)

That probably should be just an equals. I will check this on Monday whether this would solve the Umbraco issue and prevent background services from running.

@desjoerd
Copy link
Contributor

desjoerd commented Feb 3, 2024

I verified with a few tests that the removal of IHostedService registrations should only look at the specific interface and not too base interfaces.

Within Umbraco the IRuntime implements IHostedService and there is a registration just registering it as IRuntime. And a registration for the HostedService -> https://github.com/umbraco/Umbraco-CMS/blob/36402a149ad205f0bc9c55166c014bf68c8a8b8b/src/Umbraco.Web.Common/Hosting/HostBuilderExtensions.cs#L36-L37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants