microsoft / microsoft/Vipr

Support custom annotation registration beyond Core and Capabilities

Open
#17 1 comment 0 reactions 1 assignee View on GitHub

@Sridhar-MS is already working on this.

Since Feb 19, 2015.

Annotations core model representation enhancement tracked
Dominant language
C#
Stars
111
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Issue by MrTomWhite
Friday Jan 23, 2015 at 23:08 GMT
Originally opened as https://github.com/Microsoft/vipr-old/issues/59


Status Quo

Our code writers will only need to consume annotations for Capabiltiies and Core vocabularies. Although it's not general or extensible, it's acceptable at the moment to hard-code references to these vocabularies. This entails registering a mapping from the vocabulary namespace to a namespace that contains implementations of complex types:

        // TODO: Extend / modify this to more clearly support custom annotation registration. 
        private static Dictionary<string, string> VocabularyNamespaceMappings = new Dictionary<string, string>()
        {
            { "Org.OData.Capabilities.V1", ViprCoreVocabularyRoot + ".Capabilities" }
        };

Additionally, this requires loading the Edm Model that defines entities in the referenced vocabulary.

// TODO: As above, Extend / modify this to more clearly support custom annotation registration. 
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(CapabilitiesXmlFilePath))
            { /*etc...*/ 
Reasons to fix

In the future, if we have consumers of Vipr that would like to write custom writers which use custom annotations for code generation (SAP may find this functionality useful, for example), this design will need to be changed.

A possible fix is to refactor registration to a static method that can be invoked with the namespace mapping and a path to the vocabulary definiton; the remainder of the vocabulary parsing code should be general enough to handle this case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.