-
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
Enable Base term for IEdmTerm #1962
base: release-7.x
Are you sure you want to change the base?
Conversation
[Fact] | ||
public void ParseCsdlTermWithMembersWorksAsExpected() | ||
public void ParseCsdlTermWithBaseTermAndMembersWorksAsExpected() |
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.
ParseCsdlTermWithBaseTermAndMembersWorksAsExpected [](start = 20, length = 50)
Can you also add some XML test variants of reading/writing terms with base values? #Resolved
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.
There's no related test cases to test part of an XML Element.
I added a whole write test cases to cover it.
In reply to: 545398235 [](ancestors = 545398235)
@@ -815,6 +815,34 @@ public void VerifyTermWrittenCorrectly() | |||
}"); | |||
} | |||
|
|||
[Fact] | |||
public void VerifyTermWithBaseTermWrittenCorrectly() |
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.
VerifyTermWithBaseTermWrittenCorrectly [](start = 20, length = 38)
Please add XML Variation as well. #Resolved
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.
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.
/// <summary> | ||
/// Gets the base term of this term. | ||
/// </summary> | ||
IEdmTerm BaseTerm { get; } |
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 is my only real concern with the PR. We need to convince ourselves that we are the only ones implementing this interface, as anyone else providign a custom implementation will break when they update to the new library and have to modify their code to implement this property.
The fallback would be to define an IEdmTermWithBase : IEdmTerm, but that would require logic each place we consume IEdmTerm that we care about base to handle base as well, if the instance of IEdmTerm can be cast to IEdmTermWithBase. We could add IEdmTermWithBase in 7.9 and clean it up in 8.0, or we can convince ourselves that there aren't any custom implementations of IEdmTerm that we would break.
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.
That's also my concern. However, i have the following two reasons:
- To add new into a public interface is less "harmful" than to remove or to change element in the public interface.
- I can't find any reason why there's a customer who need to implement this interface.
In reply to: 545401071 [](ancestors = 545401071)
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.
I think I'm understand the high-level concern but missing the specifics for our case. Could we not have this property be of type BaseTerm : IEdmTerm
that has an internal
constructor so we have full control over the behavior?
What are the ramifications of introducing a base Term? Do consumers of the API need to do anything different? i.e., for structured types, a base type implies that all of the properties of the base type are available on the derived type. a client that looks only at the declared properties of the derived type will miss the properties inherited from the base type. Are there similar ramifications for consumers of a derived term? |
Quick answer is that" It's the same usage of "Base type" and "Base Term". When we create the annotation, we can create the PropertyValue for the "Property" defined in the base term. In reply to: 747701313 [](ancestors = 747701313) |
@@ -1383,6 +1383,11 @@ public enum EdmErrorCode | |||
/// </summary> | |||
AnnotationApplyToNotAllowedAnnotatable = 400, | |||
|
|||
/// <summary> | |||
/// This ter, type is part of a cycle. |
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.
Fix docstring
{ | ||
} | ||
} | ||
} |
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.
nit: Add newline
@@ -7742,21 +7756,6 @@ public abstract class Microsoft.OData.Client.OperationResponse { | |||
int StatusCode { public get; } | |||
} | |||
|
|||
[ |
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 is from a merged PR. Have you rebased your branch?
@@ -7774,21 +7788,6 @@ public abstract class Microsoft.OData.Client.OperationResponse { | |||
int StatusCode { public get; } | |||
} | |||
|
|||
[ |
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 is from a merged PR. Have you rebased your branch?
@@ -3080,6 +3080,7 @@ public enum Microsoft.OData.Edm.Validation.EdmErrorCode : int { | |||
BadCyclicComplex = 227 | |||
BadCyclicEntity = 229 | |||
BadCyclicEntityContainer = 228 | |||
BadCyclicTerm = 401 |
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.
Assigning value of 401 seems to have affected other enum values. Is that okay?
// Evaluate the inductive step to detect cycles. | ||
// Overriding BaseTerm getter from concrete type implementing IEdmTerm will be invoked to | ||
// detect cycles. The object assignment is required by compiler only. | ||
IEdmTerm baseTerm2 = baseTerm.BaseTerm; |
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.
I'm not familiar, but does this mean that we expect baseTerm.BaseTerm
to throw or something if there is a cycle?
protected string GetCyclicBaseTermName(string baseTermName) | ||
{ | ||
IEdmTerm schemaBaseTerm = this.Context.FindTerm(baseTermName); | ||
return (schemaBaseTerm != null) ? schemaBaseTerm.FullName() : baseTermName; |
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.
super nit: I prefer the null propagation syntax here: return schemaBaseTerm?.FullName() ?? baseTermName
Issues
This pull request fixes issue #1955. & #1816
Description
*14.1.1 Specialized Term
A term MAY specialize another term in scope by specifying it as its base type.
When applying a term with a base term, the base term MUST also be applied with the same qualifier, and so on until a term without a base term is reached.
Attribute BaseTerm
The value of BaseTerm is the qualified name of the base term.
This PR is to enable the base term.
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.