Skip to content

Releases: kontent-ai/delivery-sdk-net

19.0.0-beta-2

26 Oct 22:06

Choose a tag to compare

19.0.0-beta-2 Pre-release
Pre-release

Kontent.ai .NET delivery SDK 19.0.0-beta-2

Fixed: Strongly-Typed Linked Items Resolution

Linked items elements (modular content) are now automatically hydrated to strongly-typed embedded content, bringing the same developer experience as rich text embedded content to linked items elements.

Fixed: Loosened accessors

Filter class was marked internal, preventing users from instantiating filters to be used in .Where filtering methods. Filter serialization moved to an internal extension method.

Fixed: Incorrect naming for types filtering method, missing examples in the docs

What's New

Previously, linked items were returned as simple string arrays (IEnumerable<string>) containing only codenames. Now they're fully hydrated to
IEnumerable<IEmbeddedContent> with runtime type resolution, providing:

  • Compile-time type safety via pattern matching with IEmbeddedContent<TModel>
  • Runtime type resolution - each item gets its own type based on content type from the API
  • Full metadata access - codename, ID, content type, name for all items
  • Mixed content types - collections can contain different content types
  • LINQ support - filter by type using .OfType<IEmbeddedContent<Article>>()
  • Consistent API - same patterns as rich text embedded content

Example Usage

Before:

public record Article
{
    [JsonPropertyName("related_articles")]
    public IEnumerable<string>? RelatedArticles { get; init; } // Just codenames
}

// Could only see codenames
var codenames = article.RelatedArticles; // ["article_1", "article_2"]

After:
public record Article
{
    [JsonPropertyName("related_articles")]
    public IEnumerable<IEmbeddedContent>? RelatedArticles { get; init; } // Fully hydrated
}

// Pattern matching for type-safe access
foreach (var linkedItem in article.RelatedArticles!)
{
    switch (linkedItem)
    {
        case IEmbeddedContent<Article> relatedArticle:
            Console.WriteLine($"Article: {relatedArticle.Elements.Title}");
            Console.WriteLine($"Summary: {relatedArticle.Elements.Summary}");
            break;

        case IEmbeddedContent<Product> product:
            Console.WriteLine($"Product: {product.Elements.Name}");
            Console.WriteLine($"Price: ${product.Elements.Price}");
            break;
    }
}

// LINQ filtering
var articles = article.RelatedArticles!
    .OfType<IEmbeddedContent<Article>>()
    .ToList();

// Extract models without wrapper
var articleElements = article.RelatedArticles!
    .OfType<IEmbeddedContent<Article>>()
    .Select(a => a.Elements)
    .ToList();

Breaking Changes

⚠️ Model Updates Required: Linked items properties must be updated from IEnumerable to IEnumerable

Migration:

  // Old model
  public record Article
  {
      [JsonPropertyName("related_articles")]
      public IEnumerable<string>? RelatedArticles { get; init; }
  }

  // New model
  public record Article
  {
      [JsonPropertyName("related_articles")]
      public IEnumerable<IEmbeddedContent>? RelatedArticles { get; init; }
  }

If you were previously accessing linked items as strings, update your code to use the new strongly-typed API shown in the examples above.

Technical Details

Implementation:

  • Added EmbeddedContentFactory for shared reflection-based type construction
  • Extended ElementsPostProcessor to process modular_content elements
  • Updated IsComplexElementType to recognize modular_content as complex element
  • Refactored RichTextParser to use EmbeddedContentFactory (reduced code duplication)
  • Added comprehensive test coverage (9 new tests in StronglyTypedLinkedItemsTests)

Files Changed:

  • Kontent.Ai.Delivery/Extensions/JsonElementExtensions.cs - Added modular_content support
  • Kontent.Ai.Delivery/ContentItems/Processing/EmbeddedContentFactory.cs - NEW - Shared factory
  • Kontent.Ai.Delivery/ContentItems/Processing/ElementsPostProcessor.cs - Linked items processing
  • Kontent.Ai.Delivery/ContentItems/Processing/RichTextParser.cs - Refactored to use factory
  • Test models updated (Article.cs, Home.cs, AboutUs.cs)
  • Documentation updated (README.md, ReadmeExamples.cs)

Performance:

  • Parallel hydration using Task.WhenAll for efficient processing
  • Cached reflection constructors for optimal type construction
  • Integrated with existing dependency tracking for cache invalidation

Documentation

Updated documentation includes:

  • New section "Working with Linked Items" in README.md
  • Pattern matching examples
  • LINQ filtering examples
  • Mixed content type handling
  • Metadata access patterns
  • 5 new compiled examples in ReadmeExamples.cs

Full Changelog: 7afd757...vnext

19.0.0-beta

22 Oct 12:07

Choose a tag to compare

19.0.0-beta Pre-release
Pre-release

Kontent.ai .NET delivery SDK 19.0.0-beta

  • this is a first beta release following the modernization effort
  • a complete revamp of the architecture, aimed at improving the developer experience, reduce boilerplate and adopt modern .NET practices
  • addresses majority of issues submitted over the years
  • migration guide: TBD (the complexity of the overhaul inevitably led to a number of breaking changes. until a migration guide is finalized, see the readme for usage examples)
  • model generator: TBD (generated models were simplified for testing purposes but the model generator hasn't been updated yet. inspect models such as Article.cs in the repository for an example model implementation)

Full Changelog: 18.3.0...19.0.0-beta

18.3.0

14 Jul 11:56

Choose a tag to compare

Kontent.ai .NET delivery SDK 18.3.0

Features

  • adds support for sync API v2 (more info in the changelog)

Related PRs

Full Changelog: 18.2.0...18.3.0

18.2.0

09 Apr 11:15

Choose a tag to compare

Kontent.ai .NET delivery SDK 18.2.0

Features

  • adds support for newly introduced used in endpoints in form of GetItemUsedIn and GetAssetUsedIn methods, more info in the product changelog

Related PRs

Full Changelog: 18.1.1...18.2.0

18.1.1

20 Jan 14:39
479011a

Choose a tag to compare

What's Changed

  • Patched vulnerable dependencies

New Contributors

Full Changelog: 18.1.0...18.1.1

18.1.0

06 Mar 09:21

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 18.0.0...18.1.0

18.0.0

27 Feb 14:32

Choose a tag to compare

Kontent.ai .NET delivery SDK v18

Breaking changes

  • targets .NET 8.0 only
  • all references to project, projectId and all related methods were renamed to environment, to match the current in-app state
    • WithProjectIdWithEnvironmentId
    • DeliveryOptions.ProjectIdDeliveryOptions.EnvironmentId
    • ...

What's Changed

Full Changelog: 17.9.0...18.0.0

17.9.0

12 Dec 12:26

Choose a tag to compare

What's Changed

Full Changelog: 17.8.0...17.9.0

17.8.0

30 Oct 10:36
6086535

Choose a tag to compare

What's Changed

  • Issue/383 by @pokornyd in #385
    • updated model to match sync API response
    • added support for runtime type resolution to sync API methods

Full Changelog: 17.7.0...17.8.0

17.7.0

04 Aug 08:55
c712ba7

Choose a tag to compare

What's Changed

Full Changelog: 17.6.0...17.7.0