Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 5.67 KB

File metadata and controls

92 lines (66 loc) · 5.67 KB

.NET Libraries in .NET 11 Preview 2 - Release Notes

.NET 11 Preview 2 includes new .NET Libraries features & enhancements:

.NET Libraries updates in .NET 11:

Generic GetTypeInfo for System.Text.Json

A common pattern when working with System.Text.Json type metadata is to retrieve a JsonTypeInfo<T> from JsonSerializerOptions, which previously required a manual downcast from the non-generic GetTypeInfo(Type) method (dotnet/runtime#118468). New generic GetTypeInfo<T>() and TryGetTypeInfo<T>() methods on JsonSerializerOptions eliminate this cast and return strongly-typed metadata directly (dotnet/runtime#123940).

// Before: manual downcast required
JsonTypeInfo<MyType> info = (JsonTypeInfo<MyType>)options.GetTypeInfo(typeof(MyType));

// After: generic method returns the right type directly
JsonTypeInfo<MyType> info = options.GetTypeInfo<MyType>();

// TryGetTypeInfo variant for cases where the type may not be registered
if (options.TryGetTypeInfo<MyType>(out JsonTypeInfo<MyType>? typeInfo))
{
    // Use typeInfo
}

This is particularly useful when working with source generation, NativeAOT, and polymorphic serialization scenarios where type metadata access is common.

Tar Archive Format Selection

New overloads on TarFile.CreateFromDirectory accept a TarEntryFormat parameter, giving you direct control over the archive format (dotnet/runtime#123407). Previously, CreateFromDirectory always produced Pax archives. The new overloads support all four tar formats — Pax, Ustar, GNU, and V7 — for compatibility with specific tools and environments (dotnet/runtime#121819).

// Create a GNU format tar archive for Linux compatibility
TarFile.CreateFromDirectory("/source/dir", "/dest/archive.tar",
    includeBaseDirectory: true, TarEntryFormat.Gnu);

// Create a Ustar format archive for broader compatibility
TarFile.CreateFromDirectory("/source/dir", outputStream,
    includeBaseDirectory: false, TarEntryFormat.Ustar);

// Async version
await TarFile.CreateFromDirectoryAsync("/source/dir", "/dest/archive.tar",
    includeBaseDirectory: true, TarEntryFormat.Pax, cancellationToken);

Thank you @kasperk81 for this contribution!

Matrix4x4.GetDeterminant ~15% Faster

Matrix4x4.GetDeterminant now uses an SSE-vectorized implementation, improving performance by approximately 15% (dotnet/runtime#123954).

Scenario Before After Improvement
GetDeterminantBenchmark 3.487 ns 2.971 ns ~15% faster

Thank you @alexcovington for this contribution!

Bug fixes

This release includes bug fixes and quality improvements across several areas:

  • System.Collections
  • System.IO.Compression
    • Fixed ZipArchiveEntry.ExtractToFile preserving files on extraction failure with overwrite: true (dotnet/runtime#123991)
  • System.Linq
  • System.Net.Http
  • System.Numerics
  • System.Reflection
    • Fixed MetadataLoadContext returning internal array types instead of Type[] from several methods (dotnet/runtime#124251, reported by @smdn)
  • System.Runtime

Community contributors

Thank you contributors! ❤️