mapperly icon indicating copy to clipboard operation
mapperly copied to clipboard

Use [FormatProvider] for Parse conversion

Open OwnageIsMagic opened this issue 6 months ago • 3 comments

Related to #887. IFormatProvider overload is included in IParseable<> interface, but it's relatively new addition to .NET.

OwnageIsMagic avatar Jul 04 '25 11:07 OwnageIsMagic

Thanks for bringing this up, sounds like a good improvement. Would be happy to accept a PR implementing this. A good starting point to contribute is the contributors documentation. Let us know if you plan to work on this 😊 Some hints / affected code:

  • ParseMappingBuilder

latonz avatar Jul 07 '25 06:07 latonz

I was thinking of picking this up - when extending that Parse mapping to consider for IFormatProvider, does it only want to consider types which implement IParsable<> which would limit the potential reach (and probably make the parsing code more complex), or simply consider any Parse method with the IFP, as <T>(T Source, IFormatProvider formatProvider) is/was a standard signature for dotnet stuff before the introduction of the interface, but might match new methods which weren't before

Nysosis avatar Nov 27 '25 07:11 Nysosis

I'm ok with matching all parse methods with a matching signature even if the interface isn't present.

latonz avatar Nov 27 '25 07:11 latonz