You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So this builder is basically broken. When adding ExcludedAssemblies via method ExcludeAssemblies() the DefaultMetadataReferenceManager will not receive those elements, because it was added to services (via services.TryAddSingleton<IMetadataReferenceManager, DefaultMetadataReferenceManager>();) before finishing setting the RazorLightOptions. The constructor in DefaultMetadataReferenceManager with IOptions will receive outdated data (empty list in it). So my suggestion is to remove AddRazorLight(this IServiceCollection services) and replace this with AddRazorLight(this IServiceCollection services, Action<RazorLightOptions> opts); This way we will be able to init all options before registering all other services.
The text was updated successfully, but these errors were encountered:
Can you please provide a sample of what is wrong. I dont really look at my configuration stuff very often so a repro is super time saving. For context, in the past, I would guess what the heck people were doing and it would take hours or days to reproduce, until I found a blog post on the Internet and realized everyone was copying some dude's shitty code.
And that you think we should address it by creating
public RazorLightDependencyBuilder AddRazorLight(thisIServiceCollectionservices,Action<RazorLightOptions>opts){
_services.Configure<RazorLightOptions>(opts);returnthis;}
So this builder is basically broken. When adding ExcludedAssemblies via method ExcludeAssemblies() the DefaultMetadataReferenceManager will not receive those elements, because it was added to services (via services.TryAddSingleton<IMetadataReferenceManager, DefaultMetadataReferenceManager>();) before finishing setting the RazorLightOptions. The constructor in DefaultMetadataReferenceManager with IOptions will receive outdated data (empty list in it). So my suggestion is to remove AddRazorLight(this IServiceCollection services) and replace this with AddRazorLight(this IServiceCollection services,
Action<RazorLightOptions>
opts); This way we will be able to init all options before registering all other services.The text was updated successfully, but these errors were encountered: