Skip to content
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 optional annotation location parameter to AddVocabularyAnnotation #1941

Open
wants to merge 3 commits into
base: release-7.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Microsoft.OData.Edm/ExtensionMethods/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2027,6 +2027,18 @@ public static void AddAlternateKeyAnnotation(this EdmModel model, IEdmEntityType
model.SetVocabularyAnnotation(annotation);
}

/// <summary>
/// Adds a vocabulary annotation to this model.
/// </summary>
/// <param name="model">The model the annotation is added to.</param>
/// <param name="annotation">The annotation to be added.</param>
/// <param name="location">The location to add the allocation</param>
public static void AddVocabularyAnnotation(this EdmModel model, IEdmVocabularyAnnotation annotation, Csdl.EdmVocabularyAnnotationSerializationLocation location)
Copy link
Member

Choose a reason for hiding this comment

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

IEdmVocabularyAnnotation annotation, Csdl.EdmVocabularyAnnotationSerializationLocation location [](start = 72, length = 95)

It's not a deal for me to add such extensions. Because, there's only two line codes .

but, i have a question here: How can handle this scenario:

annotation itself has the Location setting, and that setting is different with the "location" given?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't aware the IEdmVocabularyAnnotation has a location. Will look into it.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It's probably be good to add the Csdl namespace with a using statement

{
model.AddVocabularyAnnotation(annotation);
annotation.SetSerializationLocation(model, location);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd love to see a unit test for this

}

/// <summary>
/// Checks whether the given entity type has the <paramref name="property"/> as one of the key properties.
/// </summary>
Expand Down