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

Allow assembly-wide usage of UseStaticMapper #1146

Open
cremor opened this issue Mar 4, 2024 · 3 comments
Open

Allow assembly-wide usage of UseStaticMapper #1146

cremor opened this issue Mar 4, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@cremor
Copy link

cremor commented Mar 4, 2024

Is your feature request related to a problem? Please describe.
I have a static mapper that is used in many other mappers. I don't want to add the UseStaticMapper attribute to each mapper class.

Describe the solution you'd like
UseStaticMapper should be allowed as an assembly attribute and should apply to all mappers in the assembly.

Describe alternatives you've considered
A new optional property UseAsStaticMapper (or similar) on the Mapper attribute that enables the usage of this mapper as a static mapper in all other mappers.

@cremor cremor added the enhancement New feature or request label Mar 4, 2024
@latonz
Copy link
Contributor

latonz commented Mar 8, 2024

I like the idea, I'm not sure though if we should just add a list of types to the MapperDefaultsAttribute to enforce having all the assembly-wide configuration at one place. WDYT?

@cremor
Copy link
Author

cremor commented Mar 8, 2024

That would also be a possibility. But with more than a few mappers you'd then have to wrap the code line. I think such long/wrapped attributes are ugly, but that's my personal opinion. If you want to do it that way then I'll accept it 😄

@latonz
Copy link
Contributor

latonz commented Mar 11, 2024

I thought more about it and I think the best solution would be to allow the UseStaticMapper to be applied to the assembly. The System.Text.Json apis treat a similar case the same way.
Would be happy to accept a PR.
The reading of the attributes should happen similarly to the assembly defaults.

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

No branches or pull requests

2 participants