-
Notifications
You must be signed in to change notification settings - Fork 351
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
Conversation
YogiBear52
commented
Dec 22, 2015
- 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.
Hi @YogiBear52, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! The agreement was validated by Microsoft and real humans are currently evaluating your PR. TTYL, MSBOT; |
* 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)) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
- Usage of 'ExceptionUtils' - Typo fixes - lock 'TryGetCustomFunction' method
…lt-In and Custom uri functions signatures. - 'AddCustomUriFunction' method 'addAsOverloadToBuiltInFunction' paramater name changed from 'overrideBuiltInFunction'.
- Usage of 'ExceptionUtils' - Typo fixes - lock 'TryGetCustomFunction' method
Have commited by e975bcd |
This request has solved issue #378. Do you want to close it? |