Skip to content

Add annotation term for Org.OData.Community.UrlEscape.V1.UrlEscapeFunction. - #1307

Merged
biaol-odata merged 3 commits into
OData:masterfrom
biaol-odata:oneDriveGetByPathSegment
Nov 14, 2018
Merged

biaol-odata merged 3 commits into
OData:masterfrom
biaol-odata:oneDriveGetByPathSegment

Conversation

@biaol-odata

Copy link
Copy Markdown
Contributor

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)

  • Test cases added
  • Build and test with one-click build and test script passed

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.

@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch 6 times, most recently from 7dd5ebd to c85867d Compare October 27, 2018 21:08
@biaol-odata biaol-odata self-assigned this Oct 27, 2018

@xuzhg xuzhg Oct 29, 2018 •

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.

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

@biaol-odata biaol-odata Oct 29, 2018 •

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.

As we discussed, I have moved the UrlEscapeFunction term into a new CommunityVocabularies.xml, keeping existing AlternativeKeysVocabularies.xml unchanged (will be deprecated later). #Closed

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.

Resolved: have updated namespace and alias to community.


In reply to: 229003178 [](ancestors = 229003178)

/// Parse Alternate Keys Vocabulary Model from CommunityVocabularies.xml
///
static AlternateKeysVocabularyModel()
{

@xuzhg xuzhg Oct 29, 2018 •

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.

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

@biaol-odata biaol-odata Oct 29, 2018 •

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.

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

///
/// Representing Url Escape Vocabulary Model.
///
public static class UrlEscapeVocabularyModel

@xuzhg xuzhg Oct 29, 2018 •

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.

Maybe it's better in a new file. #Closed


static UrlEscapeVocabularyModel()
{
UrlEscapeFunctionTerm = Instance.FindDeclaredTerm(UrlEscapeVocabularyConstants.UrlEscapeFunction);

@xuzhg xuzhg Oct 29, 2018 •

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.

Same as the execution of the order. #Resolved

StringWriter swAlternateKeys = new StringWriter();
IEnumerable 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 }))

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.

do "whitespace" clean


string output = swUrlEscape.ToString();
Assert.True(expectedUrlEscape == output, $"expectedUrlEscape not matching");

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.

remove

}

[Fact]
public void TestUrlEscapeVocabularyModel()

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.

Add test cases in:

  1. Create Edm function with the "urlEscape" annotation and can write it to CSDL ((inline and outline)
  2. Can reader the CSDL with the Edm function decorated with "UrlEscape" annotation, (inline and outline)

@@ -1,5 +1,5 @@
//---------------------------------------------------------------------
//

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.

Maybe it's better to "[Obsolete]" for the existing "AlternateKeys*" classes and files.

Meantime, to create new for "Community*" classes and files?

@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch from c85867d to 30bfbd2 Compare October 29, 2018 21:38
@biaol-odata

biaol-odata commented Oct 29, 2018 •

Copy link
Copy Markdown
Contributor Author

@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

@biaol-odata biaol-odata reopened this Oct 29, 2018
@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch 4 times, most recently from 85ab2a5 to 91e371f Compare October 31, 2018 08:18
- Move the UrlEscapeFuntion into new Community vocabularies; AlternateKeys will be moved later.
@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch from 91e371f to 4783300 Compare October 31, 2018 18:44
namespace Microsoft.OData.Edm.Vocabularies.Community.V1
{
///
/// Representing Url Escape Vocabulary Model.

@xuzhg xuzhg Oct 31, 2018 •

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.

Url Escape [](start = 21, length = 10)

it should be "Community" #Closed

@biaol-odata biaol-odata Oct 31, 2018 •

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.

fixed. #Closed

private readonly IEdmModel model = CommunityVocabularyModel.Instance;

[Fact]
public void TestCommunitySchemaModel()

@xuzhg xuzhg Oct 31, 2018 •

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.

Schema [](start = 33, length = 6)

TestCommunityVocabularyModel ? #Resolved

@biaol-odata biaol-odata Oct 31, 2018 •

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.

updated. #Resolved


namespace Microsoft.OData.Edm.Tests.Vocabularies
{
public class CommunityVocabularyTests

@xuzhg xuzhg Oct 31, 2018 •

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.

CommunityVocabularyTests [](start = 17, length = 24)

Maybe add test cases:

  1. In the CsdlWriter, create the model with function decorated with this term?

  2. In the CsdlReader, read the csdl with function decorated with this term. #Resolved

@biaol-odata biaol-odata Oct 31, 2018 •

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.

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

@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.

:shipit:

@xuzhg

xuzhg commented Oct 31, 2018

Copy link
Copy Markdown
Contributor

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)

@mikepizzo mikepizzo Nov 7, 2018 •

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.

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
{
/// OData.Community.V1.UrlEscapeFunction
internal const string UrlEscapeFunction = "Org.OData.Community.V1.UrlEscapeFunction";

@mikepizzo mikepizzo Nov 7, 2018 •

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.

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

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.

updated.


In reply to: 231620168 [](ancestors = 231620168)

@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.

🕐

@biaol-odata biaol-odata added the Ready for review Use this label if a pull request is ready to be reviewed label Nov 7, 2018
@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch from 571f620 to 16e3908 Compare November 8, 2018 00:40
@biaol-odata
biaol-odata force-pushed the oneDriveGetByPathSegment branch from 16e3908 to 00d649e Compare November 8, 2018 01:10

@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:

@biaol-odata

Copy link
Copy Markdown
Contributor Author

@mikepizzo and @xuzhg: Thanks for the CR! I will add additional terms per incoming requests.

@biaol-odata biaol-odata reopened this Nov 14, 2018
@biaol-odata
biaol-odata merged commit 4c9c57e into OData:master Nov 14, 2018
@biaol-odata
biaol-odata deleted the oneDriveGetByPathSegment branch November 14, 2018 20:09
@biaol-odata biaol-odata changed the title Add annotation term for OData.Community.UrlEscape.V1.UrlEscapeFunction. Add annotation term for Org.OData.Community.UrlEscape.V1.UrlEscapeFunction. Nov 19, 2018
biaol-odata added a commit to biaol-odata/odata.net that referenced this pull request Nov 19, 2018
…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.
biaol-odata added a commit that referenced this pull request Nov 20, 2018
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Use this label if a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants