skwasjer / IbanNet

C# .NET IBAN validator, parser, builder and generator
Apache License 2.0
119 stars 31 forks source link

AutoMapper implicit conversion based on System.ComponentModel.TypeConverter is broken since AutoMapper >= v11 #158

Closed skwasjer closed 10 months ago

skwasjer commented 10 months ago

Describe the bug AutoMapper is no longer implicitly supported via System.ComponentModel.TypeConverter because in v11.x supported was removed.

System.ComponentModel.TypeConverter is no longer supported It was removed for performance reasons. So it’s best not to use it anymore. But if you must, there is a sample in the test project.

https://docs.automapper.org/en/v12.0.0/11.0-Upgrade-Guide.html#system-componentmodel-typeconverter-is-no-longer-supported

However:

To Reproduce See above.

Expected behavior There are a few options:

  1. Document it properly that there is a workaround using TypeConverterMapper. (see the linked example on AutoMapper documentation page)
  2. Provide an IbanNet.AutoMapper extension library. Probably overkill.
  3. Remove the example and documentation, and let the user of IbanNet implement an integration in their own codebase (since AutoMapper is not the only object mapper out there). Reason being that this originally was just a 'happy coincidence' that it worked this way as an out-of-the-box feature.
  4. Update the example and documentation to use AutoMapper's own type converter functionality and IIbanParser. (eg. to Iban with .ConvertUsing(s => ibanParser.Parse(s)) and to string .ConvertUsing(src => src.ToString("E"))

Option 4. is probably the best, except for the fact that IIbanParser may itself get deprecated as well in favor of Iban.Parse which does not yet exist.

IbanNet library/version

.NET runtime

Operating system

Additional context N/A