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

client support for custom uri functions #2631

Merged
merged 12 commits into from
Oct 26, 2023

Conversation

uffelauesen
Copy link
Contributor

@uffelauesen uffelauesen commented Mar 2, 2023

Issues

This pull request fixes #2630.

Description

A new method attribute UriFunction have been added. Can be used to decorate methods that is to be mapped to a Uri Function.

A boolean property allowClientSideEvaluation can be set that will specify if the method can be evaluated client side when all parameters are constants. If this is set to true. then the method is treated like the standard uri functions that will be resolved on the client when all parameters are constants. Setting it to false (default) or leaving it out will force it to be sent to the server regardless if parameters are constant or not.

An example of the attribute usage is client support for the standard V4 uri function now(). To get now() to be output in the query url we will need to decorate a static method with the [UriFunction] attribute ensuring that we do not specify that it can be evaluated on the client. This way it will be sent to the server even if the normal rules inside the Evaluator visitor would force it to be evaluated on the client as it has no parameters. A new visitor method VisitMethodCall have been added to Evaluator that will check for the UriFunctionAttribute and its AllowClientSideEvaluation value and bypass client side evaluation (regardless of parameters being constants or not) if it set to false (the default).

Checklist (Uncheck if it is not completed)

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

Additional work necessary

"Docs Needed" - Document the new attribute UriFunctionAttribute.

@habbes
Copy link
Contributor

habbes commented Mar 14, 2023

@uffelauesen thanks for this contribution. I'd suggest adding the following information to the description to make it easier to review:

  • More details about the feature being implemented by this PR and expected behaviour. e.g. what is the expected outcome of the CanBeResolved flag, and in what circumstances is it applicable
  • Overview of the changes made by the PR and how they fit together

uffelauesen and others added 2 commits March 14, 2023 14:55
@uffelauesen
Copy link
Contributor Author

@habbes thank you for the review. I have pushed relevant changes to the branch. I have also added some more info to the description - describing more about the UriFunction attribute and its allowClientSideEvaluation parameter.

Also - I am sorry for the inclusion of the addition changes to #2572 - they are as such not related to the support of (custom) uri functions. Please let me know if you prefer that I pull it out of this PR and create a separate PR for that.

Again thanks for the review.
Uffe

@KenitoInc
Copy link
Contributor

@uffelauesen Kindly resolve conflicts

@habbes
Copy link
Contributor

habbes commented Aug 9, 2023

Hi @uffelauesen looks good to me. Kindly resolve the conflicts so we can approve. Thanks.

@habbes
Copy link
Contributor

habbes commented Aug 18, 2023

Fixed conflicts.

habbes
habbes previously approved these changes Aug 18, 2023
KenitoInc
KenitoInc previously approved these changes Aug 23, 2023
@uffelauesen uffelauesen dismissed stale reviews from KenitoInc and habbes via 8ba52f3 August 28, 2023 08:35
habbes
habbes previously approved these changes Sep 5, 2023
@habbes
Copy link
Contributor

habbes commented Sep 22, 2023

Seems like the branch has conflicts again due to the recent release we made that changed the Unshipped.txt files. @uffelauesen are you in a position to fix these conflicts as well? I did try to fix the conflicts but for some reason I am unable to push the updates.

@pull-request-quantifier-deprecated

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


Quantification details

Label      : Medium
Size       : +138 -4
Percentile : 48.4%

Total files changed: 9

Change summary by file extension:
.cs : +120 -4
.txt : +6 -0
.bsl : +12 -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 detected.
  • 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.

KenitoInc
KenitoInc previously approved these changes Sep 28, 2023
@KenitoInc
Copy link
Contributor

@uffelauesen There are existing tests that are failing

AstoriaUnitTests.TDD.Tests.Client.DelayQueryTests.DelayQueryUrlTest
FluentAssertions.Execution.AssertionFailedException : Expected string to be 
"http://serviceroot/odata/Users?$filter=Inbox/Exchange.GetMessages(n=10)/$count gt 0" with a length of 83, but 
"http://serviceroot/odata/Users?$filter=InboxExchange.GetMessages(n=10)/$count gt 0" has a length of 82.
AstoriaUnitTests.TDD.Tests.Client.DelayQueryTests.DelayQueryUrlTest
FluentAssertions.Execution.AssertionFailedException : Expected string to be 
"http://serviceroot/odata/Users?$filter=Inbox/Exchange.GetMessages(n=10)/$count gt 0" with a length of 83, but 
"http://serviceroot/odata/Users?$filter=InboxExchange.GetMessages(n=10)/$count gt 0" has a length of 82.

@KenitoInc
Copy link
Contributor

@uffelauesen
Kindly update the baseline files

The output file 'D:\a\1\s\test\PublicApiTests\bin\Release\netcoreapp3.1\Microsoft.OData.PublicApi.net45.out' and
 Base line file 'test\PublicApiTests\BaseLine\Microsoft.OData.PublicApi.net45.bsl' do not match, please check.
Expected: True
Actual:   False
The output file 'D:\a\1\s\test\PublicApiTests\bin\Release\netcoreapp3.1\Microsoft.OData.PublicApi.netstandard2.0.out' and
 Base line file 'test\PublicApiTests\BaseLine\Microsoft.OData.PublicApi.netstandard2.0.bsl' do not match, please check.
Expected: True
Actual:   False

@KenitoInc KenitoInc self-assigned this Oct 26, 2023
@habbes habbes merged commit e1d1b69 into OData:master Oct 26, 2023
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.

Add Support for Custom Uri Functions in ODL Client
4 participants