Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Char to split options and formats can be changed #243

Merged
merged 4 commits into from
Feb 10, 2022

Conversation

axunonb
Copy link
Member

@axunonb axunonb commented Feb 10, 2022

The character to split options and formats can be changed. This allows having the default split character | as part of the output string.

Affects ChooseFormatter, ConditionalFormatter, IsMatchFormatter, ListFormatter, PluralLocalizationFormatter, SubStringFormatter.

Example:

var smart = Smart.CreateDefaultSmartFormat();
// Change SplitChar from | to TAB, so we can use | for the output string
smart.GetFormatterExtension<ConditionalFormatter>()!.SplitChar = '\t';
_ = smart.Format("{0:cond:|No|\t|Yes|}", 1);
// Result: "|Yes|"

…er char (like ' \t')

* Affects ChooseFormatter, ConditionalFormatter, IsMatchFormatter, ListFormatter, PluralLocalizationFormatter, SubStringFormatter
* With "{}" in the format part, the matching variable will show
Reasoning: There is no plural rule for invariant culture ("iv")
@codecov
Copy link

codecov bot commented Feb 10, 2022

Codecov Report

Merging #243 (3488dea) into version/v3.0 (b134f38) will decrease coverage by 0%.
The diff coverage is 92%.

❗ Current head 3488dea differs from pull request most recent head 6f4ce1f. Consider uploading reports for the commit 6f4ce1f to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           version/v3.0   #243   +/-   ##
===========================================
- Coverage            96%    96%   -0%     
===========================================
  Files                89     89           
  Lines              3078   3084    +6     
===========================================
+ Hits               2965   2970    +5     
- Misses              113    114    +1     
Impacted Files Coverage Δ
src/SmartFormat/Core/Parsing/Format.cs 95% <ø> (ø)
src/SmartFormat/Extensions/ChooseFormatter.cs 96% <ø> (ø)
...rtFormat/Extensions/PluralLocalizationFormatter.cs 87% <80%> (-1%) ⬇️
src/SmartFormat/Extensions/ConditionalFormatter.cs 99% <100%> (+<1%) ⬆️
src/SmartFormat/Extensions/IsMatchFormatter.cs 89% <100%> (+1%) ⬆️
src/SmartFormat/Extensions/ListFormatter.cs 100% <100%> (ø)
src/SmartFormat/Extensions/SubStringFormatter.cs 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b134f38...6f4ce1f. Read the comment docs.

@axunonb axunonb merged commit 2a43b58 into axuno:version/v3.0 Feb 10, 2022
@axunonb axunonb deleted the pr-split-char-can-be-changed branch February 10, 2022 13:05
axunonb added a commit to axunonb/SmartFormat that referenced this pull request Mar 10, 2022
* SplitChar for formatters can now be changed from default '|' to another char (like ' \t')

* Affects ChooseFormatter, ConditionalFormatter, IsMatchFormatter, ListFormatter, PluralLocalizationFormatter, SubStringFormatter
* With "{}" in the format part, the matching variable will show

* Invariant culture maps to English. Reasoning: There is no plural rule for invariant culture ("iv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant