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

let us opt-in or -out of including parameter-names in generated method-names #71

Closed
earloc opened this issue Jan 13, 2023 · 0 comments · Fixed by #72
Closed

let us opt-in or -out of including parameter-names in generated method-names #71

earloc opened this issue Jan 13, 2023 · 0 comments · Fixed by #72
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed work:in progress Work on this item has been started
Milestone

Comments

@earloc
Copy link
Owner

earloc commented Jan 13, 2023

As a developer, I want to configure if the source-generator should use parameter-names in the generated method-names, in order to no pollute my code base with redundant information when i prefer to utilize the identifer-keyed-approach when naming resources.

Currently, TypealizR uses the names of parameters to generate the method-name from it, mainly to support cases where an otherwise reduced method-name would end up as a duplicate. This is mainly useful when naming resources via the phrase-keyed-approach (which original usage of IStringLocalizer implicitly kind of forces us to do)

some-phrase-keyed.resx

<data name="Hello {user:s} xml:space="preserve">
 	<value>Hello {0}</value>
 </data>
 <data name="Hello {admin:s} xml:space="preserve">
 	<value>Hello {0}</value>
 </data>

would be generated to (pseudocode)

  • Hello__user(string user)
  • Hello__admin(string admin)

In scenarios where devs prefer the identifer-keyed-approach, the resource´s key presumably is unambigious enough, so that the parameter-name may be safely omitted from the generated method-name. (Fallback duplicate resolution would still apply, though):

some-identifier-keyed.resx

<data name="GreetEarly{user:s} xml:space="preserve">
 	<value>Good morning, {0}</value>
 </data>
 <data name="GreetLate{user:s} xml:space="preserve">
 	<value>Good afternoon, {0}</value>
 </data>

could be generated to (pseudocode)

  • GreetEarly(string user)
  • GreetLate(string admin)

As the intended usage cannot be inferred by any means, TypealizR should provide a configuration-switch which opts-out of using parameter-names in method-names.

Discussable is still, what the default-behavior should be, though. Switching from the current behavior might break existing code-bases, so this should be decided very carefully.

@earloc earloc added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jan 13, 2023
@earloc earloc modified the milestones: v1.0, v0.9 Jan 13, 2023
@earloc earloc added the work:in progress Work on this item has been started label Jan 15, 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 good first issue Good for newcomers help wanted Extra attention is needed work:in progress Work on this item has been started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant