-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Alignment option always available #174
Merged
axunonb
merged 27 commits into
axuno:version/v3.0
from
axunonb:alignment-option-always-available
Jun 4, 2021
Merged
Alignment option always available #174
axunonb
merged 27 commits into
axuno:version/v3.0
from
axunonb:alignment-option-always-available
Jun 4, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## version/v3.0 #174 +/- ##
===========================================
- Coverage 95% 95% -0%
===========================================
Files 42 43 +1
Lines 1835 1843 +8
===========================================
+ Hits 1744 1750 +6
- Misses 91 93 +2
Continue to review full report at Codecov.
|
axunonb
added a commit
that referenced
this pull request
Aug 27, 2021
#### Target frameworks * Changed `netstandard2.0` to `netstandard2.1`. * `net461` support unchanged. * Added package `System.Memory` #### Remove repetitive substring allocations Connected modifications: * Added method `Write(ReadOnlySpan<char> text)` to `IFormattingInfo` * Generated substrings are cached in classes `Format`, `FormatItem`, `LiteralText`, `Placeholder` and `Selector`. * Evaluating escaped characters for `Placeholder.FormatterOptions` and `LiteralText` work without heap memory allocation. #### Alignment operator inheritance is optimized * Alignment implementation introduced with PR [#174](#174) is modified for better performance * Added method `Placeholder.AddSelector` * `Placeholder.Selectors` is now internal. Selectors are accessible with `IReadOnlyList<Selector> Placeholder.GetSelectors()`. #### DictionarySource performance improved * Implemented suggestion in issue [#186](#186) for better speed and less GC pressure. * Side effect: We're using the `CaseSensitivityType` of the dictionary for getting the value for a key. `Settings.GetCaseSensitivityComparison()` will not be applied.
axunonb
added a commit
to axunonb/SmartFormat
that referenced
this pull request
Mar 10, 2022
**Refactored implementation for string alignment** Example: `Smart.Format("{placeholder,15}")` where ",15" is the string alignment * Modified `ListFormatter` so that items can be aligned, but the spacers stay untouched * `IFormattingInfo.Alignment` now returns the alignment of the current `Placeholder`, or - if this is null - the `Alignment` of any parent `IFormattingInfo` that is not zero. * Aligment is now implemented into class `FormattingInfo`, so it is always available. Former implementation in `DefaultFormatter` is removed. * Introduced `FormatterSettings.AlignmentFillCharacter`, to the the fill character can be customized. Default is space (0x20), like with `string.Format`. * Renamed `IFormattingInfo.Write(Format format, object value)` to `FormatAsChild(Format format, object value)` to make clear that nothing is written to `IOutput` (this happens in a next step). * Added dedicated AlignmentTests
axunonb
added a commit
to axunonb/SmartFormat
that referenced
this pull request
Mar 10, 2022
#### Target frameworks * Changed `netstandard2.0` to `netstandard2.1`. * `net461` support unchanged. * Added package `System.Memory` #### Remove repetitive substring allocations Connected modifications: * Added method `Write(ReadOnlySpan<char> text)` to `IFormattingInfo` * Generated substrings are cached in classes `Format`, `FormatItem`, `LiteralText`, `Placeholder` and `Selector`. * Evaluating escaped characters for `Placeholder.FormatterOptions` and `LiteralText` work without heap memory allocation. #### Alignment operator inheritance is optimized * Alignment implementation introduced with PR [axuno#174](axuno#174) is modified for better performance * Added method `Placeholder.AddSelector` * `Placeholder.Selectors` is now internal. Selectors are accessible with `IReadOnlyList<Selector> Placeholder.GetSelectors()`. #### DictionarySource performance improved * Implemented suggestion in issue [axuno#186](axuno#186) for better speed and less GC pressure. * Side effect: We're using the `CaseSensitivityType` of the dictionary for getting the value for a key. `Settings.GetCaseSensitivityComparison()` will not be applied.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Refactored implementation for string alignment
Example:
Smart.Format("{placeholder,15}")
where ",15" is the string alignmentListFormatter
so that items can be aligned, but the spacers stay untouchedIFormattingInfo.Alignment
now returns the alignment of the currentPlaceholder
, or - if this is null - theAlignment
of any parentIFormattingInfo
that is not zero.FormattingInfo
, so it is always available. Former implementation inDefaultFormatter
is removed.FormatterSettings.AlignmentFillCharacter
, to the the fill character can be customized. Default is space (0x20), like withstring.Format
.IFormattingInfo.Write(Format format, object value)
toFormatAsChild(Format format, object value)
to make clear that nothing is written toIOutput
(this happens in a next step).