-
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
Add annotation term for Org.OData.Community.UrlEscape.V1.UrlEscapeFunction. #1307
Add annotation term for Org.OData.Community.UrlEscape.V1.UrlEscapeFunction. #1307
Conversation
7dd5ebd
to
c85867d
Compare
</Property> | ||
</ComplexType> | ||
</Schema> | ||
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="OData.Community.UrlEscape.V1" Alias="UrlEscape"> |
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 name space and the alias should be better, not only for the "UrlEscape". I think we will add more into this schema for more community terms. Check with @mikepizzo for better naming. #Closed
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.
As we discussed, I have moved the UrlEscapeFunction term into a new CommunityVocabularies.xml, keeping existing AlternativeKeysVocabularies.xml unchanged (will be deprecated later). #Closed
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.
Resolved: have updated namespace and alias to community.
In reply to: 229003178 [](ancestors = 229003178)
/// </summary> | ||
static AlternateKeysVocabularyModel() | ||
{ |
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.
From the C# spec:
A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
I am wondering about the order of execution about the static field "Instance" and the static constructor. For example:
If I access the "AlternateKeysVocabularyModel.Instance", before any code, what will happen?
If static constructor executed before field access, "Instance" is a null reference.
Maybe I am wrong, please make sure the calling is in correct order.
#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.
As we checked off line, the AlternateKeysVocabularyModel.Instance could be a null reference depends on initialization order of static intances / fields. But when it is null, it will be initialized first before it's used. So the static field should not be null when it is used. #Resolved
/// <summary> | ||
/// Representing Url Escape Vocabulary Model. | ||
/// </summary> | ||
public static class UrlEscapeVocabularyModel |
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.
Maybe it's better in a new file. #Closed
|
||
static UrlEscapeVocabularyModel() | ||
{ | ||
UrlEscapeFunctionTerm = Instance.FindDeclaredTerm(UrlEscapeVocabularyConstants.UrlEscapeFunction); |
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.
Same as the execution of the order. #Resolved
IEnumerable<EdmError> errors; | ||
using (var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 })) | ||
using (var xwAlternateKeys = XmlWriter.Create(swAlternateKeys, new XmlWriterSettings { Indent = true, Encoding = Encoding.UTF8 })) |
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.
do "whitespace" clean
|
||
string output = swUrlEscape.ToString(); | ||
Assert.True(expectedUrlEscape == output, $"expectedUrlEscape not matching"); | ||
|
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.
remove
} | ||
|
||
[Fact] | ||
public void TestUrlEscapeVocabularyModel() |
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.
Add test cases in:
- Create Edm function with the "urlEscape" annotation and can write it to CSDL ((inline and outline)
- Can reader the CSDL with the Edm function decorated with "UrlEscape" annotation, (inline and outline)
@@ -1,5 +1,5 @@ | |||
//--------------------------------------------------------------------- | |||
// <copyright file="AlternateKeysVocabularyConstants.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.
Maybe it's better to "[Obsolete]" for the existing "AlternateKeys*" classes and files.
Meantime, to create new for "Community*" classes and files?
c85867d
to
30bfbd2
Compare
@xuzhg @mikepizzo I have created a new CommunityVocabularies.xml to contain the UrlEscapeFunction term in the commit above. Can you please take a look? #Resolved |
85ab2a5
to
91e371f
Compare
- Move the UrlEscapeFuntion into new Community vocabularies; AlternateKeys will be moved later.
91e371f
to
4783300
Compare
namespace Microsoft.OData.Edm.Vocabularies.Community.V1 | ||
{ | ||
/// <summary> | ||
/// Representing Url Escape Vocabulary Model. |
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.
Url Escape [](start = 21, length = 10)
it should be "Community" #Closed
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.
fixed. #Closed
private readonly IEdmModel model = CommunityVocabularyModel.Instance; | ||
|
||
[Fact] | ||
public void TestCommunitySchemaModel() |
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.
Schema [](start = 33, length = 6)
TestCommunityVocabularyModel ? #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.
updated. #Resolved
|
||
namespace Microsoft.OData.Edm.Tests.Vocabularies | ||
{ | ||
public class CommunityVocabularyTests |
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.
CommunityVocabularyTests [](start = 17, length = 24)
Maybe add test cases:
-
In the CsdlWriter, create the model with function decorated with this term?
-
In the CsdlReader, read the csdl with function decorated with this term. #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.
Yes these tests will be added, as part of EDM model validation test along with bound function, in the task for upper layer and as a separate PR. This PR here is just to add the CommunityVocabulary. #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.
The vocabulary and related codes looks good to me. Biao said he will add more test cases when he implements the validation rules. So, I approved it. In reply to: 434092366 [](ancestors = 434092366) |
<edmx:DataServices> | ||
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="Org.OData.Community.V1" Alias="Community"> | ||
<Term AppliesTo="Function" Type="Core.Tag" Name="UrlEscapeFunction"> | ||
<Annotation Term="Core.Description" String="Annotates a function for converting a colon-escaped segment in Url path"/> |
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.
converting [](start = 77, length = 11)
The function doesn't do the conversion; maybe "Annotates a function to be substituted for a colon-escaped segment in a Url path." #Closed
public static class CommunityVocabularyConstants | ||
{ | ||
/// <summary>OData.Community.V1.UrlEscapeFunction </summary> | ||
internal const string UrlEscapeFunction = "Org.OData.Community.V1.UrlEscapeFunction"; |
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.
internal [](start = 8, length = 8)
Either make this public or make the class internal. Unless we think there is a client scenario that requires it, I would make the class internal -- we can always make it public later. #Closed
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.
🕐
571f620
to
16e3908
Compare
16e3908
to
00d649e
Compare
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.
@mikepizzo and @xuzhg: Thanks for the CR! I will add additional terms per incoming requests. |
…on. (OData#1307) * Add annotation term for OData.Community.UrlEscape.V1.UrlEscapeFunction. - Move the UrlEscapeFuntion into new Community vocabularies; AlternateKeys will be moved later. * Update per CR comments. * CR updates from Mike's comments.
…on. (#1307) * Add annotation term for OData.Community.UrlEscape.V1.UrlEscapeFunction. - Move the UrlEscapeFuntion into new Community vocabularies; AlternateKeys will be moved later. * Update per CR comments. * CR updates from Mike's comments.
Issues
This pull request is to add OData.Community.UrlEscape.V1.UrlEscapeFunction annotation, so that it is available for use in URI parsing (pending).
Description
Refactor community annotation schema with the additional schema ns "OData.Community.UrlEscape.V1".
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.