Skip to content

Fix null reference error when matching binding type - #1700

Merged
KanishManuja-MS merged 2 commits into
masterfrom
Fix-NullRefError
Mar 23, 2020
Merged

KanishManuja-MS merged 2 commits into
masterfrom
Fix-NullRefError

Conversation

@KanishManuja-MS

Copy link
Copy Markdown
Contributor

Issues

This pull request fixes issue reported by Microsoft Graph

Description

This is an experiment. The nuget package from this build will be used to verify if the problem stops from happening.

@xuzhg

xuzhg commented Mar 12, 2020

Copy link
Copy Markdown
Contributor

rebase & squash

Comment thread src/Microsoft.OData.Core/UriParser/Binders/SelectPathSegmentTokenBinder.cs Outdated

@xuzhg xuzhg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🕐

fix null ref error for same name functions

Update ModelBuildingHelpers.cs

fix typos

Update SelectPathSegmentTokenBinder.cs

Update ODataUriResolver.cs

Revert filtering bound and unbound operations.

var function2 = new EdmFunction("Test", "Function", new EdmEntityTypeReference(vegetableType, true), false /*isBound*/, null /*entitySetPath*/, false);
function2.AddParameter("p1", new EdmEntityTypeReference(vegetableType, true));
function2.AddParameter("p2", EdmCoreModel.Instance.GetInt32(false));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this pass model validation? It should not -- you shouldn't be able to have two overloads of the same unbound function with the same parameter names.

@KanishManuja-MS KanishManuja-MS Mar 19, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@mikepizzo Yes. I will follow up on that. In the meanwhile, it is a valid scenario for action overloads which differ by the binding type and there the parameter name does not even matter. Hypothetically, can the parameter name be the same but differ in type for a bound action.

To be on the safe side, I changed the above test to be a valid scenario with a different name. I will follow up with the behavior in model validation separately.

@mikepizzo mikepizzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

:shipit:

@mikepizzo

Copy link
Copy Markdown
Contributor

I'm okay with the changes as being more protective, but the added test case seems dubious; by spec, we should not allow multiple overloads of the same nonbinding function name with the same parameter names. I assume this is just testing the logic for unbound functions and not a real life scenario, but would also be interested if calling Validate() on the model succeeded (if so, we should file a separate issue to add this check to model validation).

@KanishManuja-MS
KanishManuja-MS requested review from xuzhg and removed request for xuzhg March 19, 2020 23:30
@KanishManuja-MS
KanishManuja-MS merged commit 9de483b into master Mar 23, 2020
@mikepizzo
mikepizzo deleted the Fix-NullRefError branch January 6, 2022 18:05
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