-
-
Notifications
You must be signed in to change notification settings - Fork 155
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
MapperDefaults configuration API for MSBuild (csproj, Directory.Build.props, ...) #1581
Comments
Can you provide evidence that ByName is more common than ByValue? In the projects I work I'd say its about 60% ByValue. |
Hey @latonz, thanks for your reply. When it comes to Sometimes there are redundant values, such as for API purposes. And sometimes a given business model supports only a few values, so it's always about the name. The msbuild property: <MapperlyEnumMappingStrategy>ByName</MapperlyEnumMappingStrategy> Looks cool to me. We have dozens of repositories, some having as many as 1,000 projects. We can either statically parse the Directory.Build.props and .editorconfig or synchronize settings between them. For me, it would probably look like this <Project>
<PropertyGroup>
<MapperlyAllowOptionOverride>false</MapperlyAllowOptionOverride>
<MapperlyRequiredMappingStrategy>Target</MapperlyRequiredMappingStrategy>
<MapperlyEnumMappingStrategy>ByName</MapperlyEnumMappingStrategy>
<MapperlyEnumNamingStrategy>MemberName</MapperlyEnumNamingStrategy>
<MapperlyPropertyNameMappingStrategy>CaseSensitive</MapperlyPropertyNameMappingStrategy>
<MapperlyEnumMappingIgnoreCase>false</MapperlyEnumMappingIgnoreCase>
<MapperlyThrowOnPropertyMappingNullMismatch>true</MapperlyThrowOnPropertyMappingNullMismatch>
<MapperlyThrowOnMappingNullMismatch>true</MapperlyThrowOnMappingNullMismatch>
</PropertyGroup>
</Project> I would also suggest something like In my opinion, we do not add complexity for the user, if the use of MsBuild properties is optional. Whoever wants can just use it. |
That may be true for your business domain, but is it true for most business domains? I'm not really sure. There is little increase in complexity for the user of Mapperly, but the complexity of Mapperly itself increases quite a bit, resulting in more maintenance required. |
ByName
Okay, thanks for your opinion and reply. As always, the answer is, it depends. I'll try to take a look at the code when I have some free time |
Is your feature request related to a problem? Please describe.
The default enum mapping option uses values that represent some items in some order. The
ByName
option, on the other hand, seems to make more business sense.Example:
gRPC API model
domain API model
Default extension class like
generates:
, and will return
User
, instead ofUnknown
.Describe the solution you'd like
By default, the enum should map 1:1 by name and throw an exception if the value is not present.
should generate
like when using
Describe alternatives you've considered
Could use already available
, but the above is not very convenient for split dlls and is easily forgotten
Or add new global default switch to csproj like:
or
, could be added to Directory.Build.props.
Additional context
It seems to me that much more often the name of an enumeration in a business concourse is more important than its number.
#325
#336
#337
related
The text was updated successfully, but these errors were encountered: