Skip to content

Org.OData.Core.V1.Description Core Vocabulary Annotation Discrepancy #29

@ghost

Description

The DescriptionConfiguration class returned by extension methods such as HasDescription<TEntity>(this NavigationSourceConfiguration<TEntity> navigationSource) returns a record edm expression, while methods in the EDM library such as GetLongDescriptionAnnotation(this IEdmModel model, IEdmVocabularyAnnotatable target) expects it to be IEdmStringConstantExpression. The vocabulary at the OASIS-TC also specifies that the annotation should be a string.

Assemblies affected

OData ModelBuilder 1.0.9

Reproduce steps

Create a simple console project.

dotnet new console --use-program-main
dotnet add package Microsoft.OData.ModelBuilder --version 1.0.9
dotnet add package Microsoft.OData.Edm --version 7.9.4

Paste the following into Program.cs

using Microsoft.OData.Edm;
using Microsoft.OData.ModelBuilder;

namespace odata_core_vocab_fault;

record Book(string ISBN);

class Program
{
    static void Main(string[] args)
    {
        var builder = new ODataConventionModelBuilder();

        var books = builder.EntitySet<Book>("Books");
        books
            .EntityType
            .HasKey(e => e.ISBN);
        
        books
            .HasDescription()
            .HasDescription("A collection of books.");

        var edmModel = builder.GetEdmModel();

        var entityset = edmModel.FindDeclaredEntitySet("Books");

        var description = edmModel.GetDescriptionAnnotation(entityset);

        Console.WriteLine(description);
    }
}

Expected result

The console prints "A collection of books."

Actual result

The console prints nothing. Inspecting the result while debugging shows description as null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions