Gitpedia
axuno

axuno/SmartFormat

A lightweight text templating library written in C# which can be a drop-in replacement for string.Format

30 Releases
Latest: 8mo ago
v3.6.1Latest
axunonbaxunonb·8mo ago·September 13, 2025
GitHub

📋 What's Changed

  • Bump codecov/codecov-action from 4 to 5 by @dependabot[bot] in https://github.com/axuno/SmartFormat/pull/476
  • Update README in https://github.com/axuno/SmartFormat/pull/477
  • Make `Publish` workflow branch-agnostic in https://github.com/axuno/SmartFormat/pull/481
  • Fix: Make `Publish` workflow branch-agnostic in https://github.com/axuno/SmartFormat/pull/482
  • Fix: `LocalizationProvider.GetString` with fallback culture in https://github.com/axuno/SmartFormat/pull/484
  • chore: Update unit test for fallback behavior when nesting in https://github.com/axuno/SmartFormat/pull/486
  • Update Windows runner version in SonarCloud.yml in https://github.com/axuno/SmartFormat/pull/488
  • chore: `Parser.ParseFormat`: Reduce cognitive complexity in https://github.com/axuno/SmartFormat/pull/489
  • + 5 more
v3.6.0
axunonbaxunonb·1y ago·March 17, 2025
GitHub

📦 Thread Safety Enhancements

  • 1. `Parser`:
  • The parsing logic in `Parser` has been refactored by replacing stateful instance variables.
  • The `Parser.ParseFormat(...)` method is now thread-safe, ensuring safe operations in multi-threaded environments.
  • 2. `SmartFormatter`:
  • All `SmartFormatter.Format...` methods are thread-safe.
  • Removed the `ThreadStatic` attribute from the `Smart.Default` instance of `SmartFormatter`.
  • Added parallel unit tests to ensure thread-safe operations with shared `SmartFormatter` instances using different `Smart.Extensions`.
  • Updated documentation in `Parser`, `Smart`, and `SmartFormatter` classes to clarify the thread safety of methods.
  • + 1 more

📦 Heads Up

  • Removal of `ThreadStatic` Attribute for `Smart.Default`:
  • The `ThreadStatic` attribute for the `Smart.Default` instance of `SmartFormatter` has been removed.
  • This change addresses user feedback regarding their lack of favor and the increased GC pressure it caused in multi-threaded environments like ASP.NET Core.
  • The removal is intended to enhance usability and performance in multi-threaded environments. It may, however, break existing code.
  • [![image](https://github.com/user-attachments/assets/5c441cf6-c945-4143-ac4f-9afafe1c01c6)](https://github.com/axuno/SmartFormat/discussions/472#discussioncomment-12534088)
  • The following example demonstrates how to use a single `SmartFormatter` instance with multiple threads in parallel. This ensures thread-safe operations and efficient resource utilization.
  • ```csharp
  • using System;
  • + 30 more

📋 What's Changed in Detail

  • Refactor parsing for thread safety in https://github.com/axuno/SmartFormat/pull/467
  • Update appveyor api key for nuget in https://github.com/axuno/SmartFormat/pull/468
  • Shift CI Publishing Workflow to GitHub Actions in https://github.com/axuno/SmartFormat/pull/469
  • Move code quality CI to Github Action CodeQuality.yml in https://github.com/axuno/SmartFormat/pull/470
  • Make `SmartFormatter.Format(...)` methods thread-safe in https://github.com/axuno/SmartFormat/pull/473
  • Bump version to v3.6.0 in https://github.com/axuno/SmartFormat/pull/474
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.5.3...v3.6.0
v3.5.3
axunonbaxunonb·1y ago·January 17, 2025
GitHub

📋 What's Changed

  • Add support for specifying separator between units when using TimeFormatter by @hakksor in https://github.com/axuno/SmartFormat/pull/459
  • Bump version to v3.5.3 in https://github.com/axuno/SmartFormat/pull/463
  • `TimeFormatter` allows for nested formats:
  • ```cs
  • var ci = CultureInfo.GetCultureInfo("en");
  • // Using standard:
  • _ = Smart.Format(ci, "{1:time:", new TimeSpan(1,1,1,1,1));
  • // Output: "1 day 1 hour 1 minute 1 second"
  • + 4 more

New Contributors

  • @hakksor made their first contribution in https://github.com/axuno/SmartFormat/pull/459
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.5.2...v3.5.3
v3.5.2
axunonbaxunonb·1y ago·December 18, 2024
GitHub

📋 What's Changed

  • Enhancement: Enable chaining from `StringBuilder.AppendSmart()` and `StringBuilder.AppendLineSmart()` by @Klikini in https://github.com/axuno/SmartFormat/pull/452
  • [Fix Conditional Formatter] Use invariant decimal parsing by @karljj1 in https://github.com/axuno/SmartFormat/pull/456
  • Bump version to v3.5.2 in https://github.com/axuno/SmartFormat/pull/457
  • Update appveyor build and test scripts for cross-platform compatibility in https://github.com/axuno/SmartFormat/pull/446
  • Fix: Creation of AltCover report for Codecov in https://github.com/axuno/SmartFormat/pull/447 and https://github.com/axuno/SmartFormat/pull/455
  • Update package versions in project files in https://github.com/axuno/SmartFormat/pull/453
  • Update NUnit v4.2.2 to v4.3.0 in https://github.com/axuno/SmartFormat/pull/457

New Contributors

  • @Klikini made their first contribution in https://github.com/axuno/SmartFormat/pull/452 Thank you!
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.5.1...v3.5.2
v3.5.1
axunonbaxunonb·1y ago·October 11, 2024
GitHub

📋 What's Changed

  • Microsoft Security Advisory CVE-2024-43485 in https://github.com/axuno/SmartFormat/pull/442
  • Update dependencies in SmartFormat.Tests in https://github.com/axuno/SmartFormat/pull/443
  • Bump version to v3.5.1 in https://github.com/axuno/SmartFormat/pull/444
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.5.0...v3.5.1
v3.5.0
axunonbaxunonb·1y ago·July 29, 2024
GitHub

Feature: Add interface IFormattingExtensionsToggle to skip formatting (#436)

  • Added the `IFormattingExtensionsToggle` interface to allow skipping formatting by `IFormatter` extensions.
  • This interface is primarily used by `ISource` extensions that receive it with the `ISelectorInfo` parameter.
  • By setting `IFormattingExtensionsToggle.DisableFormattingExtensions` to `true`, formatting can be skipped. This can be useful when the `ISource` found a value in `ISource.TryEvaluateSelector` where default formatting cannot reasonably be done.

🔒 Security: Update of System.Text.Json (#435)

  • Bumped `System.Text.Json` to v8.0.4
  • Fixed a vulnerability in .NET when calling the JsonSerializer.DeserializeAsyncEnumerable method against an untrusted input using System.Text.Json, which could result in Denial of Service.

Feature: Implement ISpanFormattable for DefaultFormatter (#434)

  • Implemented `ISpanFormattable` for `DefaultFormatter`
  • `ISpanFormattable` is 5% faster than IFormattable, with 24% less allocations
  • ```CSharp
  • // Performance test case
  • Smart.FormatInto(output, null, _placeholder0005Format, 1234567.890123f, 1234567.890123f, 1234567.890123f, 1234567.890123f, 1234567.890123f);
  • ```
  • ```
  • BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3737/23H2/2023Update/SunValley3)
  • + 10 more

Feature: ReflectionSource (#426)

  • Made `ReflectionSource.TypeCache` `static` for better performance.
  • If the `static` cache has undesired effects on your code logic, consider to disable the cache (`ReflectionSource.IsTypeCacheEnabled = false`).
  • Implemented a mechanism to control the size of `ReflectionSource.TypeCache` and remove the oldest item first.

📦 Enhancement: DictionarySource (#426)

  • Dynamics in `DictionarySource` now use case-sensitivity setting
  • Cache for `IReadOnlyDictionary` now has instance scope

📦 SmartFormatter

  • Separated members for handling `ISource` and `IFormatter` extensions into internal class `Registry`
  • Separated members for evaluating formats into internal class `Evaluator`
  • Existing members of `SmartFormatter` remain unchanged and are not yet marked as obsolete

📦 ZCharArray

  • Added a lightweight, thread-safe container that rents a buffer from an `ArrayPool<char>` and returns it when disposed
  • Simplifies passing around the buffer without intermediate memory allocations
  • `ZCharArray` contains most frequently used methods for writing data into the underlying buffer
  • Used in `FormattingInfo` methods (see below) for low memory allocation

📦 FormattingInfo

  • Added methods useful in custom `IFormatter`s:
  • _public ZCharArray FormattingInfo.FormatAsSpan(IFormatProvider, Format, object?)_: Works like SmartFormatter.Format(...) for the specified Format
  • _public ZCharArray FormattingInfo.FormatAsSpan(IFormatProvider, Placeholder, object?)_: Gets the value for the `Placeholder` and applies its `Format`
  • _public bool TryGetValue(Placeholder, out object?)_: Tries to get the value for a `Placeholder`

📦 Evaluator

  • Internal class that supplies the methods for evaluating `Placeholder` and `Format` objects
  • Contains the methods that `FormattingInfo` uses to evaluate `Placeholder` and `Format` objects
  • Has other methods formerly included in `SmartFormatter` that are now moved to `Evaluator`
  • Includes a partial class for handling events in all steps of the evaluation process

📦 Registry

  • Internal class that contains all methods for handling `ISource` and `IFormatter` extensions that have been moved from `SmartFormatter`

Feature: Format.HasNested checks for existing Placeholder in Items (#416)

  • Added `Format.HasNested` property that checks Items for existing Placeholder

Test: Add unit test for nested scope (#404)

  • Added unit test for nested scope

📦 Enhancement: Ensure Format instances get returned to object pool (#402)

  • Ensured that Format instances get returned to object pool

♻️ Refactor: Internal `SmartFormat.Pooling` classes (#401)

  • Simplified pooling classes and made methods and names more consistent

Chore: Remove unused performance test projects (#398)

  • Removed unused performance test projects

🐛 Fix: Returning a StringBuilder exceeding default capacity to StringBuilderPool (#397)

  • Fixed an issue where returning a `StringBuilder` exceeding the default capacity to `StringBuilderPool` would throw an exception.

🗑️ Refactor: Remove code duplications in SmartFormatter (#396)

  • Removed code duplications in SmartFormatter
  • Unified preprocessor directives

🗑️ Chore: Remove redundant DependsOnTargets from SmartFormat.csproj (#394)

  • Removed redundant DependsOnTargets from SmartFormat.csproj
  • ---
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.4.0...v3.5.0
v3.4.0
axunonbaxunonb·2y ago·May 15, 2024
GitHub

📦 All Target Frameworks

  • We have removed the `SmartFormat.ZString` assembly and replaced it with a reference to the [ZString](https://github.com/Cysharp/ZString) package. This change does not affect the API.

📦 Commits in detail

  • Fix: Update nuget api key in https://github.com/axuno/SmartFormat/pull/378
  • Target Framework Updates in https://github.com/axuno/SmartFormat/pull/389 (merged the version/3.4.0 branch)
  • Thanks to @thompson-tomo for his first contribution with https://github.com/axuno/SmartFormat/pull/377
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.3.2...v3.4.0
v3.3.2
axunonbaxunonb·2y ago·January 29, 2024
GitHub

📦 Reasoning for the Update

  • Regression caused by https://github.com/axuno/SmartFormat/pull/368
  • If there are namespace collisions with Cysharp.Text using v3.3.1 please update to v3.2.2

📋 What's Changed

  • Change all public types in namespace Cysharp.Text to internal in https://github.com/axuno/SmartFormat/pull/372
  • Stop namespace collisions with Cysharp.ZString nuget package
  • Affects: class, struct, interface, delegate, enum
  • using https://github.com/zzzprojects/findandreplace on command line, so we can automate this step:
  • Add a unit test to get an alert when Cysharp.Text objects are public (e.g. after an update)
  • Bump version to v3.3.2
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.3.1...v3.3.2
v3.3.1
axunonbaxunonb·2y ago·January 14, 2024
GitHub

🐛 Fix

  • PluralRule for DualFromZeroToTwo: Now a value of 2 is covered and will not throw. Frend is one of the affected languages. Closes #369 in https://github.com/axuno/SmartFormat/pull/370

📋 Other Changes

  • Unit tests: Convert NUnit Classic Assert to Constraint Model in https://github.com/axuno/SmartFormat/pull/364
  • Bump NUnit package reference to v4.0.1 in https://github.com/axuno/SmartFormat/pull/367
  • Linq optimizations in https://github.com/axuno/SmartFormat/pull/366
  • Update package Cysharp.ZString to v2.5.1 in https://github.com/axuno/SmartFormat/pull/368
  • Bump version to v3.3.1 in https://github.com/axuno/SmartFormat/pull/371
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.3.0...v3.3.1
v3.3.0
axunonbaxunonb·2y ago·September 25, 2023
GitHub

📋 What's Changed

  • Add support for nested formats in `LocalizationFormatter` by @zacateras in https://github.com/axuno/SmartFormat/pull/350. This is useful, if the string to localize contains a _SmartFormat_ placeholder instead of a pure text. Example: If the format is `"{:L:{ProductType}}"`, the `ProductType` placeholder will be replaced with the variable content "pen". "pen" will in turn be localiced to "bic" for the `FR` locale.
  • `DictionarySource` has an option to evaluate `IReadOnlyDictionary<TKey,TValue>` sources by @axunonb in https://github.com/axuno/SmartFormat/pull/353. To enable, set `DictionarySource.IsIReadOnlyDictionarySupported` to `true` (default is `false`). This is for types that only implement `IReadOnlyDictionary<TKey,TValue>`, but not `IDictionary`.
  • Bump version to v3.3.0 in https://github.com/axuno/SmartFormat/pull/356

New Contributors

  • Thanks to @zacateras for the first contribution in https://github.com/axuno/SmartFormat/pull/350
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.2.2...v3.3.0
v3.2.2
axunonbaxunonb·2y ago·August 3, 2023
GitHub

🐛 Fix

  • `PluralLocalizationFormatter` does not treat a numeric string as valid argument (resolves #345, restore behavior of v3.1.0 and before) in https://github.com/axuno/SmartFormat/pull/346
  • Bump version to v3.2.2

📦 Chore

  • Update appveyor and github CI scripts
  • Update change log for v3.2.1 in https://github.com/axuno/SmartFormat/pull/331
  • Update NuGet API Key in https://github.com/axuno/SmartFormat/pull/335
  • Update link to pluralization rules we use as a reference in https://github.com/axuno/SmartFormat/pull/338
  • Add unit test for DateOnly and TimeOnly types (NET6.0+) in https://github.com/axuno/SmartFormat/pull/341
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.2.1...v3.2.2
v3.2.1
axunonbaxunonb·3y ago·February 19, 2023
GitHub

📦 PluralLocalizationFormatter

  • Fix: Auto-detection of PluralLocalizationFormatter does not throw for values not convertible to decimal by @axunonb in https://github.com/axuno/SmartFormat/pull/330 Resolves #329 (Thanks to @BtbN)
  • Current behavior, introduced in v3.2.0:
  • When `PluralLocalizationFormatter.CanAutoDetect == true`, values that are not convertible to `decimal` will throw then trying to `IConvertible.ToDecimal(...)`
  • New behavior, equivalent to v3.1.0:
  • When `PluralLocalizationFormatter.CanAutoDetect == true`, for values that are not convertible to `decimal`, `IFormatter.TryEvaluateFormat(...)` will return `false`
  • Fix processing for Singular languages by @axunonb in https://github.com/axuno/SmartFormat/pull/322

📋 Other Changes

  • EditorConfig and appveyor.yml by @axunonb in https://github.com/axuno/SmartFormat/pull/319
  • Integrate Cysharp.ZString release v2.5.0 (26 Oct 2022) by @axunonb in https://github.com/axuno/SmartFormat/pull/323
  • Fix: PluralRules for Czech locale by @alexheb in https://github.com/axuno/SmartFormat/pull/325
  • Fixes for Demo App and NUnit TestAdapter by @axunonb in https://github.com/axuno/SmartFormat/pull/328

New Contributors

  • @alexheb made their first contribution in https://github.com/axuno/SmartFormat/pull/325
  • Full Changelog: https://github.com/axuno/SmartFormat/compare/v3.2.0...v3.2.1
v3.2.0
axunonbaxunonb·3y ago·September 18, 2022
GitHub

📦 Enhancements

  • Remove usage of Linq for less GC
  • Add `IConvertable` support for `PluralLocalizationFormatter` and `ConditionalFormatter`
  • `ListFormatter`
  • ListFormatter handles selector name "Index" in `IEnumerable`s and `IList`s: In `v1.6.1` a Selector was tested for having the name "index", even if data was not an `IList`, and returned the `CollectionIndex`. This is now implemented again in the `ListFormatter.TryEvaluateSelector(...)`
  • Set the `ParentPlaceholder` property for item `Format`s
  • Use `PooledObject<T>` where possible, so objects will be returned to `ObjectPool` also in case of exceptions

🐛 Fixes

  • `FormatItem.AsSpan()` returns the correct name
  • Remove potential namespace collisions: All public types in namespace `Cysharp.Text` are now internal

📋 What's Changed

  • Upgrade projects targeting NET5.0 to NET6.0 by @axunonb in https://github.com/axuno/SmartFormat/pull/286
  • Refactor suggestions by @karljj1 in https://github.com/axuno/SmartFormat/pull/290
  • Refactored unit tests for ReflectionSource and thread-safe mode by @axunonb in https://github.com/axuno/SmartFormat/pull/291
  • Convert solution to file-scoped namespacing by @axunonb in https://github.com/axuno/SmartFormat/pull/292
  • Use `is` instead of checking the type info. by @karljj1 in https://github.com/axuno/SmartFormat/pull/293
  • SonarCloud do not support analysis of forked PRs by @axunonb in https://github.com/axuno/SmartFormat/pull/294
  • Avoid using Linq as it generates GC each time. by @karljj1 in https://github.com/axuno/SmartFormat/pull/296
  • IConvertible support for plural and conditional formatters by @karljj1 in https://github.com/axuno/SmartFormat/pull/300
  • + 7 more
v2.7.3v2.7.3.0
axunonbaxunonb·3y ago·June 28, 2022
GitHub

#### Fix: Newtonsoft.Json prior to version 13.0.1 is vulnerable Newtonsoft.Json prior to version 13.0.1 is vulnerable to Insecure Defaults due to improper handling of expressions with high nesting level that lead to StackOverFlow exception or high CPU and RAM usage. Exploiting this vulnerability results in Denial Of Service (DoS). Package reference updated to a minimum version 13.0.1

v3.1.0
axunonbaxunonb·4y ago·May 17, 2022
GitHub

📦 Thread-safe Mode

  • Thread-safe mode is now enabled by default:
  • `SmartSettings.IsThreadSafeMode == true`.<br/>
  • 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](https://github.com/axuno/SmartFormat/wiki/Async-and-Thread-Safety)

📦 `ListFormatter` may have Placeholders in "spacers"

  • Thanks to [karljj1](https://github.com/axuno/SmartFormat/commits?author=karljj1) for the PR.
  • Before *v3.1.0* the format options for `ListFormatter` could only contain literal text. Now `Placeholder`s are allowed.
  • ```CSharp
  • var args = new {
  • Names = new[] { "John", "Mary", "Amy" },
  • IsAnd = true, // true or false
  • Split = ", " // comma and space as list separator
  • };
  • + 4 more
v3.0.0
axunonbaxunonb·4y ago·March 14, 2022
GitHub

📦 `SubStringFormatter`

  • The formatter now accecpts a format argument with a nested `Placeholder` that lets you format the result of the sub-string operation.
  • Example: Convert the sub-string to lower-case:
  • ```CSharp
  • Smart.Format("{0:substr(0,2):{ToLower}}", "ABC");
  • ```
  • Reasoning: Enhancement

📦 Nullable Notation

  • `KeyValuePairSource`, `PersistentVariablesSource` and `GlobalVariablesSource` can now process "null if nullable"
  • Reasoning: Enhancement

📦 `TemplateFormatter`

  • The name of the formatter is now `"t"` (was "template" before).
  • Reasoning: Minimize the format string

📦 Char to split options and formats is limited to pipe, comma, tilde

  • Char to split options and formats is limited to pipe, comma, tilde
  • SplitChar for formatters is unified and checked for validity
  • Affects `ChooseFormatter`, `ConditionalFormatter`, `IsMatchFormatter`, `ListFormatter`, `PluralLocalizationFormatter`, `SubStringFormatter`
  • Reasoning: Avoid conflicts with reserved characters

📦 Modified ChooseFormatter case-sensitivity for option strings

  • bool and null: always case-insensitive
  • using SmartSettings.CaseSensitivity unless overridden with ChooseFormatter.CaseSensitivity
  • option strings comparison is culture-aware, using CultureInfo if supplied in Smart.Format(...) or CurrentUICulture
  • Reasoning: Enhancement

📦 Magic Leading Colon

  • An implementation of a magic leading colon in order to identify whether `ConditionalFormatter` or `PluralLocalizationFormatter` should be invoked, was removed.
  • Reasoning:
  • This is undocumented and unnecessary.
  • Adding the formatter name in the format string achieves the same target.
v3.0.0-rc.2Pre-release
axunonbaxunonb·4y ago·February 15, 2022
GitHub

📋 Changes since [v3.0.0-rc.1](https://github.com/axuno/SmartFormat/releases/tag/v3.0.0-rc.1)

  • A single escape character (`\`) at the end of the input string will now throw an `ArgumentException` with a comprehensive error message.
  • `KeyValuePairSource` isas a simple, cheap and performant way to create named placeholders.
  • Example:
  • ```Csharp
  • Smart.Format("{placeholder}", new KeyValuePair<string, object?>("placeholder", "some value")
  • // Result: "some value"
  • ```
  • The `IsMatchFormatter` is a formatter with evaluation of regular expressions.
  • + 22 more
v3.0.0-rc.1Pre-release
axunonbaxunonb·4y ago·February 1, 2022
GitHub

📦 Packages ([#238](https://github.com/axuno/SmartFormat/pull/238))

  • SmartFormat has the following NuGet packages:
  • a) SmartFormat.NET
  • This is package which references all other packages below.
  • b) SmartFormat
  • SmartFormat is the core package. It comes with the most frequently used extensions built-in:
  • 1) Source extensions:
  • `GlobalVariablesSource`
  • `PersistentVariablesSource`
  • + 51 more
v2.7.2v2.7.2.0
axunonbaxunonb·4y ago·December 26, 2021
GitHub

📋 Changes

  • Fixed: `ConditionalFormatter` processes unsigned numbers in arguments correctly.
  • Fixed: `JsonSource`: Corrected handling of `null` values in `Newtonsoft.Json` objects.
v3.0.0-alpha.5Pre-release
axunonbaxunonb·4y ago·December 3, 2021
GitHub

📦 1. Object Pools

  • After implementing Object Pools for all classes which are frequently instantiated, GC and memory allocation again went down significantly.
  • In order to return "smart" objects back to the object pool, its important to use one of the following patterns.
  • Examples:
  • a) Single thread context (no need to care about object pooling)
  • ```CSharp
  • var resultString = Smart.Format("format string", args);
  • ```
  • b) Recommended: Auto-dispose `Format` (e.g.: caching, multi treading context)
  • + 14 more

📦 2. Thread Safety

  • SmartFormat makes heavy use of caching and object pooling for expensive operations, which both require `static` containers.
  • a) Instantiating `SmartFormatter`s from different threads:
  • `SmartSettings.IsThreadSafeMode=true` must be set, so that thread safe containers are used. This brings an inherent performance penalty.
  • a) Instantiating `SmartFormatter`s from a single thread:
  • `SmartSettings.IsThreadSafeMode=false` should be set for avoiding the multithreading overhead and thus for best performance.
  • The simplified `Smart.Format(...)` API overloads are allowed here.
v3.0.0-alpha.4Pre-release
axunonbaxunonb·4y ago·October 25, 2021
GitHub

2. Added `LocalizationFormatter` ([#176](https://github.com/axuno/SmartFormat/pull/207))

  • Added `LocalizationFormatter` to localize literals and placeholders
  • Added `ILocalizationProvider` and a standard implemention as `LocalizationProvider`, which handles `resx` resource files. A fallback culture can be set. It will be used, in case no item for a certain culture could be found in any of the resources. `LocalizationProvider` can search an unlimited number of defined resoures.
  • `SmartSettings` were exended with category `Localization`. That way, custom `IFormatter`s can also make use of localization, if needed.
  • Added `LocalizationFormattingException`, which is derived from `FormattingException` to easily identify this kind of issues
  • Culture-specific results shown here are included in embedded resource files, which are omitted for brevity.
  • a) Localize pure literals into Spanish:
  • ```CSharp
  • // culture supplied as a format option
  • + 22 more

♻️ 3. Refactored `PluralLocalizationFormatter` ([#209](https://github.com/axuno/SmartFormat/pull/209))

  • Constructor with string argument for default language is obsolete.
  • Property `DefaultTwoLetterISOLanguageName` is obsolete.
  • Culture is now determined in this sequence (same as with `LocalizationFormatter`):<br/>
  • a) Get the culture from the `FormattingInfo.FormatterOptions`.<br/>
  • b) Get the culture from the `IFormatProvider` argument (which may be a `CultureInfo`) to `SmartFormatter.Format(IFormatProvider, string, object?[])`<br/>
  • c) The `CultureInfo.CurrentUICulture`<br/>

♻️ 4. Refactored `TimeFormatter` ([#220](https://github.com/axuno/SmartFormat/pull/220), [#221](https://github.com/axuno/SmartFormat/pull/221))

  • Constructor with string argument for default language is obsolete.
  • Property `DefaultTwoLetterISOLanguageName` is obsolete.
  • Culture is now determined in this sequence (same as with `LocalizationFormatter` and `PluralLocalizationFormatter`):<br/>
  • a) Get the culture from the `FormattingInfo.FormatterOptions`.<br/>
  • b) Get the culture from the `IFormatProvider` argument (which may be a `CultureInfo`) to `SmartFormatter.Format(IFormatProvider, string, object?[])`<br/>
  • c) The `CultureInfo.CurrentUICulture`<br/>
  • New: With the extended `CommonLanguagesTimeTextInfo`, `TimeFormatter` includes French, Spanish, Portuguese, Italian and German as new languages besides English out-of-the-box.
  • New: With e.g. `TimeFormatter.FallbackLanguage = "en";`, this fallback language will be used, if no supported language could be found.
  • + 41 more
v2.7.1v2.7.1.0
axunonbaxunonb·4y ago·October 21, 2021
GitHub

📋 Changes

  • Fixed: [#179](https://github.com/axuno/SmartFormat/issues/179) DualFromZeroToTwo plural rule. Thanks to [@OhSoGood](https://github.com/OhSoGood)
  • Fixed: [#211](https://github.com/axuno/SmartFormat/issues/211) Illegal placeholder characters that are not 8-bit, will no more throw unexpected `ThrowByteOverflowException`. Thanks to [@bogatykh](https://github.com/bogatykh)
v3.0.0-alpha.3Pre-release
axunonbaxunonb·4y ago·September 20, 2021
GitHub

📋 Changes

  • Behavior is comparable to `ChooseFormatter`
  • Allows for nested formats
  • More plausibility checks
  • include IsMatchFormatter
  • include NullFormatter
v3.0.0-alpha.2Pre-release
axunonbaxunonb·4y ago·September 21, 2021
GitHub

📋 Changes

  • Opposed to `string.Format` null(able) arguments are allowed.
  • Changes effect classes `Smart` and `SmartFormatter`
v3.0.0-alpha.1Pre-release
axunonbaxunonb·4y ago·August 29, 2021
GitHub

📋 Changes

  • increase in speed by up to 40%
  • decrease of GC pressure (collects are only GC Generation 0, allocated memory reduced by up to 60%)
v2.7.0.0
axunonbaxunonb·5y ago·April 10, 2021
GitHub

📋 Changes

  • Fixed broken backward compatibilty introduced in v2.6.2 (issues referenced in [#148](https://github.com/axuno/SmartFormat/issues/148), [#147](https://github.com/axuno/SmartFormat/issues/147), [#143](https://github.com/axuno/SmartFormat/issues/143)).
  • Fixed: Take an erroneous format string like `"this is {uncomplete"` (missing closing brace). Before v2.7.0 the parser handled `{uncomplete` as a `TextLiteral`, not as an erroneous `Placeholder`.
  • Fixed: Since v1.6.1 there was an undiscovered issue: If the `Parser` encountered a `ParsingError.TooManyClosingBraces`, this closing brace was simply "swallowed-up". This way, the result with `Parser.ErrorAction.MaintainTokens` differs from the original format string. From v2.7.0, the redundant closing brace is handled as a `TextLiteral`.
  • If you have issues formatting HTML with CSS and/or JavaScript included, please read the bullet-proof [How-to in the Wiki](https://github.com/axuno/SmartFormat/wiki/HTML-with-CSS-or-JavaScript)
v2.6.2.0
axunonbaxunonb·5y ago·February 17, 2021
GitHub

📋 Changes

  • Fix: Fully implemented all `Settings.ParseErrorAction`, see [#143](https://github.com/axuno/SmartFormat/pull/143) - Thanks to [Anders Jonsson](https://github.com/andersjonsson)
v2.6.1.0
axunonbaxunonb·5y ago·February 12, 2021
GitHub

📋 Changes

  • Fixed [#136](https://github.com/axuno/SmartFormat/issues/136)
  • Upgraded test project to netcoreapp3.1
  • Enhanced SubString extension as described in [PR142](https://github.com/axuno/SmartFormat/pull/142) - Thanks to [Anders Jonsson](https://github.com/andersjonsson)
  • Migrated project with Nullable Reference Types (NRT) enabled
v2.5.3.0
axunonbaxunonb·5y ago·November 10, 2020
GitHub

Bugfix release

v2.5.3.0-preview1Pre-release
axunonbaxunonb·5y ago·November 2, 2020
GitHub

```ListFormatter``` will only process ```IList``` sources.