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

Custom Uri Functions #378 #430

Closed
wants to merge 5 commits into from
Closed

Conversation

YogiBear52
Copy link

  • CustomUriFunctions - public API to add/remove custom functions or override built-In functions.
  • CustomUriFunctions and BuiltInUriFunctions tests.
  • Renamed class from 'BuiltInFunctions' to 'BuiltInUriFunctions'.
  • The new class 'UriFunctionsHelper' contains general usage for both Built-In and Custom functions.

* CustomUriFunctions - public API to add/remove or override builtIn functions.
* CustomUriFunctions and BuiltInFunctions tests
* Changed class name from 'BuiltInFunctions' to 'BuiltInUriFunctions'.
* The new class 'UriFunctionsHelper' contains general usage for both BuiltIn and Custom functions.
@msftclas
Copy link

Hi @YogiBear52, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

YogiBear52 added 2 commits January 2, 2016 13:24
* Changed name of some methods :
'MatchSignatureToBuiltInFunction' to 'MatchSignatureToUriFunction'.
'BindAsBuiltInFunction' to 'BindAsUriFunction'.
if (!BuiltInFunctions.TryGetBuiltInFunction(functionName, out signatures))

// Try to find the function in the user custom functions
if (!CustomUriFunctions.TryGetCustomFunction(functionName, out signatures))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search built-in first, then custom

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method 'AddCustomUriFunction' in 'CustomUriFunctions' class gets a 'overrideBuiltInFunction' parameter which indicates whether to override the existing built-in function with the same name of the given custom function.
As I mentioned in a comment: "It overrides the BuiltIn function because search is first on CustomFunctions and then on BuiltInFunctions. Another option is to remove the BuiltIn function - seems like a worse option.".
I gave the user an option to to override the built in functions with the same name, so the OData protocol stay with no changes. I could have removed the Built-In function, but it seems like the worse option because if the user will removed a custom function, which had been overrided and removed a built-in function, there will be no "true roll-back". I define a "true roll-back" as to add the removed built-in function again.
When searching first on CustomUriFunction and then on BuiltInUriFunction, adding an overriding custom function will be easy,
so when an overriding CustomUriFunction will be removed, the built-in function will always stay the same and make sure the OData protocol standstill.

  • This is why I added some tests about who is searched first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YogiBear52, What i get from the code is that the AddCustomUriFunction could add a new custom function which has a different signature from all the same named built-in functions. if the signatures are same, the code will throw CustomUriFunctions_AddCustomUriFunction_BuiltInExistsFullSignature exception, right?
So i think, maybe we should return both the built-in and custom functions with the name if 'overrideBuiltInFunction' is true.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you say that we keep the 'AddCustomUriFunction' method as is, and modify the 'GetUriFunctionSignatures' method to combine the overloads of both Built-In functions and CustomFunctions. Seems like a better solution : )

Confirm that this is what you ment and I will code, document and add tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YogiBear52,It is exactly what I mean. Thanks.

YogiBear52 added 2 commits January 9, 2016 00:52
- Usage of 'ExceptionUtils'
- Typo fixes
- lock 'TryGetCustomFunction' method
…lt-In and Custom uri functions signatures.

- 'AddCustomUriFunction' method 'addAsOverloadToBuiltInFunction' paramater name changed from 'overrideBuiltInFunction'.
LaylaLiu pushed a commit to LaylaLiu/odata.net that referenced this pull request Jan 13, 2016
- Usage of 'ExceptionUtils'
- Typo fixes
- lock 'TryGetCustomFunction' method
@LaylaLiu
Copy link
Contributor

Have commited by e975bcd

@YogiBear52
Copy link
Author

This request has solved issue #378. Do you want to close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants