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

Support String Formatting for Expandable Properties #140

Open
raffaelfoidl opened this issue May 10, 2021 · 0 comments
Open

Support String Formatting for Expandable Properties #140

raffaelfoidl opened this issue May 10, 2021 · 0 comments

Comments

@raffaelfoidl
Copy link
Contributor

raffaelfoidl commented May 10, 2021

Some of the supported expandable properties resolve to information that can be represented in different ways (i.e. are related to classes that implement the IFormattable interface). By leveraging these capabilities, the values of the properties used within a license header definition can be more diverse.

For example, date- or time-related properties could be formatted to the user's liking (e.g. leading zeros, which DateTime parts to include, ...)

(Potential, Tentative) Usage
Generally: %PropertyName:FormatSpecifier%
Example: %CreationYear:G%

Above example represents a (new) property with the name CreationYear that will be expanded to a string that displays the date and time in the current culture's short date and time format.

Important Classes
The changes needed to implement such a functionality are not very far-reaching. The most important classes are the following:

  • DocumentHeaderProperty.cs: A model class representing a property that will be expanded (with a Predicate that determines whether a value can be created as well as a Func that creates the value).
  • DocumentHeaderProperties.cs: Actually defines the properties that are resolved during license header insertion.

Implementation Notes
There is no rigid pre-conceived solution we are aiming for. However, the behavior for the existing properties must not change (at least not by default), this would be a breaking change for the userbase. This implies that the format specifier should not become mandatory for pre-existing (or any) properties. Also keep in mind that the culture used for formatting affects the resulting string, so this should not be neglected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant