J2N.Text.StringFormatter: Added constructor overload for IFormatProvider #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This supersedes #44, which targeted the wrong branch.
This adds a constructor overload accepting
IFormatProvider
toStringFormatter
. Note that whileStringFormatter
is marked as[Serializable]
, in .NET Core and newer platforms, none of theIFormatProvider
implementations are serializable.Since in Java,
Locale
is often used as a field and may be a field of a serializable class, we recommend refactoring the class to accept anIFormatProvider
as a method argument rather than using a field, where possible. If that is not possible and serialization is required, it is recommended to create a customIFormatProvider
that wraps the .NET type in order to serialize and deserialize its state. Note that theformatProvider
field inStringFormatter
will automatically be serialized if serialization is supported by the class.This also removes
FEATURE_CULTUREINFO_DEFAULTTHREADCURRENTCULTURE
andFEATURE_CULTUREINFO_DEFAULTTHREADCURRENTUICULTURE
, as these were not being used, anyway.