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

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

Open
ghost opened this issue Jul 20, 2022 · 0 comments
Open

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

ghost opened this issue Jul 20, 2022 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 20, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants