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

Add support for interpolated string handlers annotated with the attribute #1

Open
Emik03 opened this issue Jul 5, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Emik03
Copy link
Owner

Emik03 commented Jul 5, 2023

The goal is to implement the following behavior:

  • Inspect every string interpolation on the project.
  • Get the type of the parameter. Continue only if it is an interpolated string handler as oppose to System.String.
  • Connect $"foo" and $"{foo:foo}" onto AppendFormatted and AppendLiteral overloads, respectively.
    • Check if the parameter of AppendFormatted and AppendLiteral has a Match attribute, if it does, match it against the interpolation.
    • If it doesn't, check the parameter types of the function. If a parameter has an implicit conversion to either System.String (for value and format) or System.Int32 (for alignment).
      • Go to the type's implicit conversion function and get the parameters.
      • For each parameter, get the attributes for Match.
      • If they exist, test each Match against the literal value that was passed into the specific expression of the string interpolation.

This is a very complicated spec, and as such will likely take a very long time to implement.

Tests have already been added, which at the time of writing is currently failing: 45311dd

Once all tests pass, version 2.1 will be released, assuming no other breaking features are rolled out.

@Emik03 Emik03 added the enhancement New feature or request label Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant