You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Direct value annotations are missing after parsing a CSDL model from JSON.
Assemblies affected
Which assemblies and versions are known to be affected e.g. OData .Net lib 8.1.0.0
Reproduce steps
The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.
The following code demonstrates the issue. Even though direct annotations are written into the output JSON document, they are
ignored when reading it back and reported as "Unexpected element".
Note that a similar test that uses XML reader / writer correctly imports direct value annotations and sets them on the corresponding schema elements.
varmodelIn=new EdmModel();vartype=new EdmComplexType("MyNamespace","MyType");varproperty= type.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
modelIn.DirectValueAnnotationsManager.SetAnnotationValue(
property,"MyNamespace","ColumnSize",new EdmIntegerConstant(EdmCoreModel.Instance.GetInt16(false),8));
modelIn.AddElement(type);varmemoryStream=new MemoryStream();usingvarwriter=new Utf8JsonWriter(memoryStream);
Assert.IsTrue(CsdlWriter.TryWriteCsdl(modelIn, writer,outIEnumerable<EdmError> errors));
Assert.IsNotNull(errors);
Assert.IsFalse(errors.Any());varjson= Encoding.UTF8.GetString(memoryStream.ToArray());
StringAssert.Contains(json,"ColumnSize");varreader=new Utf8JsonReader(memoryStream.ToArray());
Assert.IsTrue(CsdlReader.TryParse(ref reader,new CsdlJsonReaderSettings(),out IEdmModel modelOut,out errors));
Assert.IsNotNull(modelOut);
Assert.AreEqual(1, modelOut.SchemaElements.Count());// This fails because of "Unexpected element 'ColumnSize' error"
Assert.IsFalse(errors.Any());
Expected result
When reading CSDL model from JSON we would expect direct value annotations to be imported the same way they are when de-serializing from XML.
What would happen if there wasn't a bug.
Actual result
What is actually happening.
Additional detail
Optional, details of the root cause if known. Delete this section if you have no additional details to add.
The text was updated successfully, but these errors were encountered:
Direct value annotations are missing after parsing a CSDL model from JSON.
Assemblies affected
Which assemblies and versions are known to be affected e.g. OData .Net lib 8.1.0.0
Reproduce steps
The simplest set of steps to reproduce the issue. If possible, reference a commit that demonstrates the issue.
The following code demonstrates the issue. Even though direct annotations are written into the output JSON document, they are
ignored when reading it back and reported as "Unexpected element".
Note that a similar test that uses XML reader / writer correctly imports direct value annotations and sets them on the corresponding schema elements.
Expected result
When reading CSDL model from JSON we would expect direct value annotations to be imported the same way they are when de-serializing from XML.
What would happen if there wasn't a bug.
Actual result
What is actually happening.
Additional detail
Optional, details of the root cause if known. Delete this section if you have no additional details to add.
The text was updated successfully, but these errors were encountered: