-
Notifications
You must be signed in to change notification settings - Fork 392
feat(TypeAdapterConfig): Add IHostBuilder and IServiceCollection extensions for global configuration via appsettings right in the Hostbuilder #851
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
base: development
Are you sure you want to change the base?
Conversation
β¦erOptions configuration including
β¦c to be set and add ApplyTo function for Options to TypeAdapterConfig Mapping
β¦rConfig from UseMapster Extension - Collected ambiguous signatures to one UseMapster Method - Renamed the ServiceCollectionExtensions to get rid of ambiguous warnings and enable clearer identification from the extension name
β¦e needed for IDE0130
|
@DevTKSS π
Is this a feature or a side effect? With the current approach, we can at least find what we're referencing on the globalconfig using code search.
If this is a planned feature, it needs to be described separately in the documentation, with a warning that it will change the global config, which can be called without DI, and a description of the benefits it provides. |
I did read the docs, and they are currently instructing, to either set it with the GlobalSettings or provide a new own instance, so all this does is to enable doing the same integrated.
Is your point on Intellisense support? Because a
No, this is one of the core features of the feature provided by the Extension, so I would appreciate if you could explain what you see me missing π |
Then you are missing tests where you use global configuration via
Taking into account the description in the wiki and the existing tests, Therefore, the default behavior here should be the same: |
|
@DevTKSS I'm talking about the following problem. Example You didn't get the result you expected.: if you register as GlobalConfig = false, In this case, you will be looking for a mapping problem where you configured the DI container. if you register as GlobalConfig = true, In addition to the place indicated above, you will need to check the entire program code for calls: // Actually, there is another way through RuleMap or Rule, i don't remember exactly anymore π |
PR Type:
What is the current behavior? π€
TypeAdapterConfigregistation and config himself.What is the new behavior? π
Added
MapsterOptionsreflecting all currentTypeAdapterConfigpropertiesIServiceCollection.AddMapsterOptions:MapsterOptionswill be loaded from Configuration and are not breaking build when not providedMapsterbut can be overwritten up fromUseMapsterFunc<HostBuilderContext, IConfiguration>? configurationto provide his options section manually.IServiceCollection.AddTypeAdapterConfig:useGlobalConfigwe will start withTypeAdapterConfig.GlobalSettingsor if false, use a new Instance just like he would be able to do manually by now.TypeAdapterConfigbefore callingUseMapsterorAddTypeAdapterConfig(both added) he can tell the extension to ratheruseExistingand (if found) this will be used insteadMapsterOptionswill then be applyed on the evaluated instance ofTypeAdapterConfigFunc<TypeAdapterConfig,TypeAdapterConfig>configuration option, allows to future configure the Config and do the.NewConfig<T1,T2>like we can do by now.Only the first call of the added
ServiceCollectionExtensionswill be executed,UseMapstercan be called multiple times, but up from second time only theAction<HostBuilderContext,IServiceCollection>will get executed, allowing future registration of Mapping relevant Services when needed.PR Checklist β
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information βΉοΈ
Eventually we want to merge the new Docs to the existing ones. Kept them seperated so far.