Is your feature request related to a problem? Please describe.
N/A
Describe the solution you'd like
With C# 11 we can use static interface members and with these specific .NET 7+ interfaces, it would provide parsing that is consistent with the built-in primitives.
Before 59023a8bc82585719f8bcc9f3ebc7527b8ac36ad the Iban type actually had static Iban.Parse and Iban.TryParse members, but was this moved to the IIbanParser abstraction a few years ago. Proposal is to bring back the static members to the Iban type and remove the IIbanParser abstraction.
This is a breaking change!
Some issues to deal with:
The IbanParser type depends on IIbanRegistry or IIbanValidator via the ctor. This is not possible with the static parse members on the Iban type.
The dependency on the registry is required, but we can solve this by adding a static IbanRegistry.Current member which allows users to override the registry (eg. to add the WikipediaRegistryProvider).
The dependency on the validator was there to validate that the IBAN is correct but also satisfies the validator options (eg. custom registry + custom rules). The registry is already solved with previous bullet, and thus I think the best approach is to validate with that registry and just ignore custom rules. Especially because parsing is a different concern as opposed to validation I think it makes sense to stop the interdependency. It also means that type conversion and JSON conversion doesn't care about custom rules anymore.
Perhaps it is better to trim use of the IbanValidatorOptions as well by refactoring how we use the Registry property and only use it for the dependency injection configuration extensions.
Is your feature request related to a problem? Please describe. N/A
Describe the solution you'd like With C# 11 we can use static interface members and with these specific .NET 7+ interfaces, it would provide parsing that is consistent with the built-in primitives.
See https://learn.microsoft.com/en-us/dotnet/api/system.iparsable-1
Before 59023a8bc82585719f8bcc9f3ebc7527b8ac36ad the
Iban
type actually had staticIban.Parse
andIban.TryParse
members, but was this moved to theIIbanParser
abstraction a few years ago. Proposal is to bring back the static members to theIban
type and remove theIIbanParser
abstraction.This is a breaking change!
Some issues to deal with:
IbanParser
type depends onIIbanRegistry
orIIbanValidator
via the ctor. This is not possible with the static parse members on theIban
type.IbanRegistry.Current
member which allows users to override the registry (eg. to add theWikipediaRegistryProvider
).IbanValidatorOptions
as well by refactoring how we use theRegistry
property and only use it for the dependency injection configuration extensions.Describe alternatives you've considered N/A
Additional context N/A