OData / OData/ModelBuilder

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

Open
#29 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
22
Forks
24
PR merge metrics
No merged PRs in 30d

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.

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.

Research direction

Start with VocabularyTermConfigurationExtensions.cs and the HasDescription methods, then compare them with GetDescriptionAnnotation in the EDM ExtensionMethods.cs reference. Run the Program.cs reproduction using ModelBuilder 1.0.9 and EDM 7.9.4; done means the console prints "A collection of books." instead of null.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.