github axuno/SmartFormat v3.1.0

latest releases: v3.5.1, v3.5.0, v3.4.0...
2 years ago

This is a feature update, that is released upon feedback from the community.

Thread-safe Mode

Thread-safe mode is now enabled by default:
SmartSettings.IsThreadSafeMode == true.

This has no impact on the API.

In case SmartFormat is exclusively utilized in a single-threaded context, SmartSettings.IsThreadSafeMode=false should be considered for enhanced performance.

Static Smart Methods for Formatting

Static Smart methods like Smart.Format(format, args) can now be called in an async / multi-threaded context.

The SmartFormatter instance returned by Smart.Default is flagged with the ThreadStatic attribute.
See more details in the Wiki: Async and Thread Safety

ListFormatter may have Placeholders in "spacers"

Thanks to karljj1 for the PR.

Before v3.1.0 the format options for ListFormatter could only contain literal text. Now Placeholders are allowed.

Example:

var args = new {
    Names = new[] { "John", "Mary", "Amy" },
    IsAnd = true, // true or false
    Split = ", "  // comma and space as list separator
};
_ = Smart.Format("{Names:list:{}|{Split}| {IsAnd:and|nor} }", args);
// Output for "IsAnd=true":  "John, Mary and Amy"
// Output for "IsAnd=false": "John, Mary nor Amy"

Don't miss a new SmartFormat release

NewReleases is sending notifications on new releases.