Releases: kontent-ai/delivery-sdk-net
19.0.0-beta-2
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
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
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
Kontent.ai .NET delivery SDK 18.3.0
Features
- adds support for sync API v2 (more info in the changelog)
Related PRs
- 404 sync api v2 by @sevcik-martin in #405
Full Changelog: 18.2.0...18.3.0
18.2.0
Kontent.ai .NET delivery SDK 18.2.0
Features
- adds support for newly introduced used in endpoints in form of
GetItemUsedInandGetAssetUsedInmethods, more info in the product changelog
Related PRs
- Add support for used in endpoints by @winklertomas in #403
Full Changelog: 18.1.1...18.2.0
18.1.1
18.1.0
What's Changed
- Add support for exclude parameter by @zdenekjurka in #391
New Contributors
- @zdenekjurka made their first contribution in #391
Full Changelog: 18.0.0...18.1.0
18.0.0
Kontent.ai .NET delivery SDK v18
Breaking changes
- targets .NET 8.0 only
- all references to
project,projectIdand all related methods were renamed toenvironment, to match the current in-app stateWithProjectId→WithEnvironmentIdDeliveryOptions.ProjectId→DeliveryOptions.EnvironmentId- ...
What's Changed
Full Changelog: 17.9.0...18.0.0
17.9.0
17.8.0
17.7.0
What's Changed
- 378 Fix the problem with IDateTimeContent BSON serialization/deserialization by @dzmitryk-kontent-ai in #379
Full Changelog: 17.6.0...17.7.0