Skip to content

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

@Emik03

Description

@Emik03

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions