You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CustomUriFunctions is a static class. Registering a function with it by calling AddCustomUriFunction is irreversible. This is a problem for unit testing and object lifecycle in the application itself.
Assemblies affected
Microsoft.OData.Core, Version=7.0.0.0
Reproduce steps
Register a custom function.
Expected result
ODataUriParser can be created with and without the custom functions regardless of global state.
Actual result
CustomUriFunctions.AddCustomUriFunction(...) is the way to register custom functions. ODataUriParser uses CustomUriFunctions to look up signatures, so it's not possible to supply it with a list independent of other instances of ODataUriParser. It's not possible to unregister a function once it's registered, either.
Additional details
In addition, CustomUriFunctions.AddCustomUriFunction(...) can only be called once with the same signature, otherwise it throws an exception with the CustomUriFunctions_AddCustomUriFunction_CustomFunctionOverloadExists error message.
Why is this necessary? Even checking the built-in functions - what is the harm of registering the same signature twice? The implementation is not part of the registration, so this error handling seems counterproductive. It forces the user to lock and check to make sure registration hasn't already happened before calling AddCustomUriFunction.
This wouldn't be an issue if registration was not at a global/class level but at an instance level.
CustomUriFunctions is a static class. Registering a function with it by calling AddCustomUriFunction is irreversible. This is a problem for unit testing and object lifecycle in the application itself.
Assemblies affected
Microsoft.OData.Core, Version=7.0.0.0
Reproduce steps
Register a custom function.
Expected result
ODataUriParser can be created with and without the custom functions regardless of global state.
Actual result
CustomUriFunctions.AddCustomUriFunction(...) is the way to register custom functions. ODataUriParser uses CustomUriFunctions to look up signatures, so it's not possible to supply it with a list independent of other instances of ODataUriParser. It's not possible to unregister a function once it's registered, either.
Additional details
In addition, CustomUriFunctions.AddCustomUriFunction(...) can only be called once with the same signature, otherwise it throws an exception with the CustomUriFunctions_AddCustomUriFunction_CustomFunctionOverloadExists error message.
Why is this necessary? Even checking the built-in functions - what is the harm of registering the same signature twice? The implementation is not part of the registration, so this error handling seems counterproductive. It forces the user to lock and check to make sure registration hasn't already happened before calling AddCustomUriFunction.
This wouldn't be an issue if registration was not at a global/class level but at an instance level.
Copied from: OData/WebApi#949
The text was updated successfully, but these errors were encountered: