-
Notifications
You must be signed in to change notification settings - Fork 352
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
Fixes #1817: support key alias #3145
base: main
Are you sure you want to change the base?
Conversation
I'd like to move the key alias feature forward. |
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.
Copilot reviewed 8 out of 23 changed files in this pull request and generated 1 suggestion.
Files not reviewed (15)
- src/Microsoft.OData.Edm/Microsoft.OData.Edm.csproj: Language not supported
- src/Microsoft.OData.Edm/Microsoft.OData.Edm.txt: Language not supported
- src/Microsoft.OData.Edm/PublicAPI/net8.0/PublicAPI.Unshipped.txt: Language not supported
- src/Microsoft.OData.Edm/Csdl/Serialization/EdmModelCsdlSchemaWriter.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Parsing/SchemaJsonParser.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Semantics/BadElements/UnresolvedPropertyRef.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Serialization/EdmModelCsdlSchemaXmlWriter.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Serialization/EdmModelCsdlSerializationVisitor.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Microsoft.OData.Edm.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Parsing/CsdlDocumentParser.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Validation/EdmErrorCode.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Csdl/Parsing/Ast/CsdlPropertyReference.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Parameterized.Microsoft.OData.Edm.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Schema/Interfaces/IEdmEntityType.cs: Evaluated as low risk
- src/Microsoft.OData.Edm/Schema/EdmEntityType.cs: Evaluated as low risk
Comments skipped due to low confidence (1)
src/Microsoft.OData.Edm/Schema/Interfaces/IEdmPropertyRef.cs:29
- [nitpick] The description for PropertyAlias could be more detailed to explain its purpose and usage.
string PropertyAlias { get; }
} | ||
|
||
IEdmProperty edmProperty = FindPropertyOnType(edmStructuredType, segment); | ||
if (i == segment.Length - 1) |
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 condition should be 'if (i == segments.Length - 1)' to correctly identify the last segment in the path.
if (i == segment.Length - 1) | |
if (i == segments.Length - 1) |
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.
Introduce the IEdmPropertyRef interface Use default interface method for IEdmEntityType avoid breaking changes This change focus on Edm lib, if it's ready and will move to OData.Core.
943889a
to
8540bc5
Compare
@@ -0,0 +1,30 @@ | |||
//--------------------------------------------------------------------- | |||
// <copyright file="UnresolvedProperty.cs" company="Microsoft"> |
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.
This should be UnresolvedPropertyRef.cs
instead of UnresolvedProperty.cs
// <copyright file="UnresolvedProperty.cs" company="Microsoft"> | |
// <copyright file="UnresolvedPropertyRef.cs" company="Microsoft"> | |
@@ -650,21 +650,37 @@ internal static CsdlKey ParseCsdlKey(string name, JsonElement keyArray, JsonPars | |||
Debug.Assert(keyArray.ValueKind == JsonValueKind.Array); | |||
Debug.Assert(name == "$Key", "The name should be $Key."); |
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.
What if the $Key
is in lowercase: $key
foreach (CsdlPropertyReference keyProperty in this.entity.Key.Properties) | ||
{ | ||
IEdmStructuralProperty structuralProperty = this.FindProperty(keyProperty.PropertyName) as IEdmStructuralProperty; | ||
IEdmStructuralProperty structuralProperty = FindKeyProperty(keyProperty.PropertyName); |
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.
IEdmStructuralProperty structuralProperty = FindKeyProperty(keyProperty.PropertyName); | |
IEdmStructuralProperty structuralProperty = this.FindKeyProperty(keyProperty.PropertyName); | |
Or define FindKeyProperty
as static
method
@@ -2155,6 +2157,200 @@ public void CanWriteUrlEscapeFunction() | |||
}"); | |||
} | |||
|
|||
[Fact] | |||
public void CanWriteEntityType_WithSimpleKey_WithOrWithoutAlias() |
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.
You can add equivalent Async
tests for these Sync
tests
Fixes #1817: support key alias
Introduce the IEdmPropertyRef interface
Use default interface method for IEdmEntityType avoid breaking changes
This change focus on Edm lib, if it's ready and will move to OData.Core.