microsoft/Vipr

Child Namespace Appearing Before Parent Namespace Causes Failure in Generation of OdcmModel Of an EntityType

Closed this issue · 0 comments

Vipr throws an InvalidOperationExeception when OdcmReader tries to generate an OdcmModel for the lifecycleWorkflowsContainer EntityType within the "microsoft.graph.identityGovernance" namespace.

This is caused by ordering of the namespaces in the OdcmReader.Writenamespaces method, such that by the time the id KeyProperty of the entityType is being evaluated here, it doesn't yet exist. The id KeyProperty should be inherited from the base namespace Microsoft.Graph but is not, because, in the _edmModel.DeclaredNamespaces here, the child namespace microsoft.graph.identityGovernance, precedes the parent namespace microsoft.graph. The _edmModel.DeclaredNamespaces appears to be depending on the order of definition of the namespaces in the metadata whereby in the stagingBeta metadata the "microsoft.graph.identityGovernance" namespace is defined before the "microsoft.graph" namespace.

Error details:

Running Typewriter...
03:05:57 Typewriter Typewriter is running with the following arguments: 
  -v Info -m /mnt/vss/_work/1/s/metadata/clean_metadata.xml -o /mnt/vss/_work/1/s/output -g Files
03:05:57 MetadataResolver Loading metadata from /mnt/vss/_work/1/s/metadata/clean_metadata.xml.
03:05:57 OdcmReader Generating OdcmModel
Unhandled exception. System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at Vipr.Reader.OData.v4.OdcmReader.ReaderDaemon.WriteNamespaceDeep(IEdmModel edmModel, String namespace) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/submodules/vipr/src/Readers/Vipr.Reader.OData.v4/OdcmReader.cs:line 342
   at Vipr.Reader.OData.v4.OdcmReader.ReaderDaemon.WriteNamespaces() in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/submodules/vipr/src/Readers/Vipr.Reader.OData.v4/OdcmReader.cs:line 200
   at Vipr.Reader.OData.v4.OdcmReader.ReaderDaemon.GenerateOdcmModel(IEnumerable`1 serviceMetadata) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/submodules/vipr/src/Readers/Vipr.Reader.OData.v4/OdcmReader.cs:line 116
   at Vipr.Reader.OData.v4.OdcmReader.GenerateOdcmModel(IEnumerable`1 serviceMetadata) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/submodules/vipr/src/Readers/Vipr.Reader.OData.v4/OdcmReader.cs:line 67
   at Typewriter.Generator.MetadataToClientSource(String edmxString, String targetLanguage, IEnumerable`1 properties, String endpointVersion) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/src/Typewriter/Generator.cs:line 166
   at Typewriter.Generator.GenerateFiles(String csdlContents, Options options) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/src/Typewriter/Generator.cs:line 29
   at Typewriter.Program.GenerateSDK(Options options, String[] args) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/src/Typewriter/Program.cs:line 35
   at Typewriter.Program.<>c__DisplayClass2_0.<Main>b__0(Options opts) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/src/Typewriter/Program.cs:line 18
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at Typewriter.Program.Main(String[] args) in /mnt/vss/_work/1/s/MSGraph-SDK-Code-Generator/src/Typewriter/Program.cs:line 17

Snapshot of the Metadata Description
image

Thanks @andrueastman for helping to debug this.