Skip to content

Conversation

@shriprasanna
Copy link
Contributor

@shriprasanna shriprasanna commented May 31, 2022

Issues

This pull request fixes issue #84.

Description

Objective of this PR is to enable LowerCamelCaser to support camel casing for Enum Members. In the current state, Enum Member is not camel cased when processed by LowerCamelCaser. The workaround is to use EnumMember attribute (specifying the EnumMember.Value in camel case) for each of the EnumMembers.

With this PR, support has been added to EnumCamelCaser to process the Enum Members. A new flag is added to NameResolverOptions (ProcessEnumMemberNames) that will define if the EnumMember should be camel cased. If the flag is enabled, then LowerCamelCaser.ApplyLowerCamelCase() will iterate though each of the Enum Members in Builder.EnumTypes and will convert the EnumMember's Name to Camel Case.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

Additional update to documentation may be needed for the new flag added to LowerCamelCaser.

Prasanna Vaitheswaran added 2 commits May 31, 2022 12:48
@corranrogue9
Copy link

@shriprasanna, thanks for the contribution! I think this is only half of the battle though. The model will accommodate the lower camel casing, but I think the serialization will still be broken when deserializing an incoming request, and serializing and outgoing request. Are you planning to do work in the WebApi repo to reflect this?

@pull-request-quantifier-deprecated

This PR has 66 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Small
Size       : +64 -2
Percentile : 26.4%

Total files changed: 7

Change summary by file extension:
.cs : +38 -2
.xml : +16 -0
.bsl : +10 -0

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detetcted.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@shriprasanna shriprasanna requested a review from corranrogue9 June 2, 2022 18:35
@shriprasanna
Copy link
Contributor Author

@shriprasanna, thanks for the contribution! I think this is only half of the battle though. The model will accommodate the lower camel casing, but I think the serialization will still be broken when deserializing an incoming request, and serializing and outgoing request. Are you planning to do work in the WebApi repo to reflect this?

@corranrogue9 I tested it in a Web API project that uses the EDMModel generated from ODataConventionModelBuilder (adding it to a specific route). When invoking the API with OData route, the enum properties in the response have the value camel cased.

When using the enum property in the OData query filter, I have to set the value of the enum property as camel cased (filter=MyEnumProperty eq 'myEnumValue'). If I specify the value as pascal cased in the query (filter=MyEnumProperty eq 'MyEnumValue'), it does not work.

@xuzhg xuzhg merged commit a6b09a5 into OData:main Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants