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

honor type-annotations in parameter-declarations #6

Closed
earloc opened this issue Nov 9, 2022 · 3 comments · Fixed by #15
Closed

honor type-annotations in parameter-declarations #6

earloc opened this issue Nov 9, 2022 · 3 comments · Fixed by #15
Labels
enhancement New feature or request

Comments

@earloc
Copy link
Owner

earloc commented Nov 9, 2022

As a developer, I want the source-generator to honor primitive type-declarations in parameter-expressions of a ResX-File´s key value, to let the generator produce better typin gs while generating wrapper-methods, in order to ensure that I pass the correct value to a translation.

@earloc earloc changed the title Honor type-annotations in parameter-declarations honor type-annotations in parameter-declarations Nov 9, 2022
@earloc
Copy link
Owner Author

earloc commented Nov 9, 2022

Keys of a ResX-File might introduce a type-annotation, that get´s honored during code generation
Something like
Hello, {userName:string} might end up as an extension-method with the following signature:

public static string Hello__userName(..., string userName)...

instead of always falling back to object, as the current implementation does (and btw is the most annoying missing link to just use vanilla IStringLocalizer<T>-Index access ):

public static string Hello__userName(..., object userName)...

Utilizing existing formatting-annotations as for string.Format() might be a good idea as well. But solely utilizing these feels a bit of a too steep learning-curve for people just looking for a drop-in-enhancement to get a more typed and manageable acceess to localizables.

@earloc earloc added the enhancement New feature or request label Nov 10, 2022
@earloc
Copy link
Owner Author

earloc commented Nov 11, 2022

initial design should honor:

  • int
  • double
  • string
  • DateTime
  • DateTimeOffset

  • bool <- should this provide a built-in lookup or similar for true/false/null, on/off/partial, yes/no/maybe, enabled/disabled/dunno, wahr/falsch/vielleicht, ja/nein/keine Ahnung?

More to consider:
What about Nullable<T>s of these types. Should there be some kind of fallback-resolution in a sensible way?

@earloc
Copy link
Owner Author

earloc commented Nov 11, 2022

Also, the above list could be extended to also support built-in types as:

what about:

earloc added a commit that referenced this issue Nov 12, 2022
earloc added a commit that referenced this issue Nov 12, 2022
earloc added a commit that referenced this issue Nov 12, 2022
@earloc earloc mentioned this issue Nov 12, 2022
@earloc earloc mentioned this issue Nov 12, 2022
22 tasks
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

Successfully merging a pull request may close this issue.

1 participant