Skip to main content
ClaudeWave
Skill429 estrellas del repoactualizado 10d ago

system-text-json-net11

This skill documents new `System.Text.Json` APIs introduced in .NET 11, including strongly-typed `JsonTypeInfo<T>` access via `GetTypeInfo<T>()` and `TryGetTypeInfo<T>()` methods, plus the `JsonNamingPolicy.PascalCase` property for PascalCase serialization. Use this when serializing or deserializing JSON in .NET 11 or later projects requiring type-safe metadata access or PascalCase property naming conventions.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/managedcode/dotnet-skills /tmp/system-text-json-net11 && cp -r /tmp/system-text-json-net11/catalog/Platform/Official-DotNet-Dotnet11/skills/system-text-json-net11 ~/.claude/skills/system-text-json-net11
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# System.Text.Json — .NET 11

New APIs added to `System.Text.Json` across .NET 11 releases.

## When to Use

- Serializing or deserializing JSON in a .NET 11 (or later) project
- Needing strongly-typed `JsonTypeInfo<T>` access instead of the untyped `JsonTypeInfo` overload
- Wanting to safely check whether type metadata is available without catching exceptions (`TryGetTypeInfo<T>`)
- Requiring PascalCase property naming during JSON serialization

## When Not to Use

- The project targets .NET 10 or earlier — these APIs are not available before .NET 11
- Using a JSON library that is not `System.Text.Json` (e.g., Newtonsoft.Json)
- The existing untyped `GetTypeInfo(Type)` / `TryGetTypeInfo(Type, ...)` overloads are sufficient

## Target Framework

```xml
<TargetFramework>net11.0</TargetFramework>
```

## New APIs

### Typed `JsonTypeInfo` Access

#### `JsonSerializerOptions.GetTypeInfo<T>()`

Returns a strongly-typed `JsonTypeInfo<T>` for the specified type, using the
options' configured type-info resolver.

```csharp
JsonTypeInfo<T> GetTypeInfo<T>()
```

#### `JsonSerializerOptions.TryGetTypeInfo<T>(out JsonTypeInfo<T>?)`

Attempts to retrieve typed metadata without throwing if the type is not resolved.

```csharp
bool TryGetTypeInfo<T>(out JsonTypeInfo<T>? typeInfo)
```

### `JsonNamingPolicy.PascalCase`

A new static property that converts property names to PascalCase during
serialization.

```csharp
static JsonNamingPolicy PascalCase { get; }
```

## Examples

### Get Typed JsonTypeInfo

```csharp
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;

var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);

// Retrieve strongly-typed metadata for MyClass
JsonTypeInfo<MyClass> typeInfo = options.GetTypeInfo<MyClass>();
Console.WriteLine($"Type: {typeInfo.Type.Name}");
```

### TryGetTypeInfo for Safe Access

```csharp
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;

var options = new JsonSerializerOptions(JsonSerializerDefaults.Web);

if (options.TryGetTypeInfo<MyClass>(out var info))
{
    Console.WriteLine($"Resolved type info for {info!.Type.Name}");
}
else
{
    Console.WriteLine("Type info not available");
}
```

### PascalCase Naming Policy

```csharp
using System.Text.Json;

var opts = new JsonSerializerOptions
{
    PropertyNamingPolicy = JsonNamingPolicy.PascalCase
};

var obj = new { firstName = "John", lastName = "Doe" };
string json = JsonSerializer.Serialize(obj, opts);
Console.WriteLine(json);
// Output: {"FirstName":"John","LastName":"Doe"}
```

### Combined: Serialize with Typed Metadata

```csharp
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;

var options = new JsonSerializerOptions
{
    PropertyNamingPolicy = JsonNamingPolicy.PascalCase
};

JsonTypeInfo<Person> typeInfo = options.GetTypeInfo<Person>();
string json = JsonSerializer.Serialize(new Person("Jane", 30), typeInfo);
Console.WriteLine(json);
// Output: {"Name":"Jane","Age":30}

public record Person(string Name, int Age);
```
aspnet-coreSkill

Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET. USE FOR: working on ASP.NET Core apps, services, or middleware; changing auth, routing, configuration, hosting, or deployment behavior; deciding between ASP.NET Core sub-stacks. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

aspireSkill

Build, upgrade, and operate .NET Aspire 13.3.x application hosts with current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, and Azure deployment patterns for distributed apps. USE FOR: Aspire.AppHost.Sdk, Aspire.Hosting.*, DistributedApplication.CreateBuilder, WithReference, WaitFor, AddProject, AddRedis, AddPostgres, aspire run, aspire init, aspire. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

azure-functionsSkill

Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR: working on Azure Functions in .NET; migrating from the in-process model to the isolated worker model; adding Durable Functions, bindings, or host configuration. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

blazorSkill

Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices. USE FOR: building interactive web UIs with C# instead of JavaScript; choosing between Server, WebAssembly, or Auto render modes; designing component hierarchies and state. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

entity-framework6Skill

Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is not the right next step. USE FOR: EF6 codebases; runtime versus ORM migration decisions; EDMX, code-first, ObjectContext, and legacy data-access review. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

entity-framework-coreSkill

Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and EF6 migration decisions. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

mauiSkill

Build, review, or migrate .NET MAUI applications across Android, iOS, macOS, and Windows with correct cross-platform UI, platform integration, and native packaging assumptions. USE FOR: working on cross-platform mobile or desktop UI in .NET MAUI; integrating device capabilities, navigation, or platform-specific code; migrating Xamarin.Forms or aligning. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.

mlnetSkill

Use ML.NET to train, evaluate, or integrate machine-learning models into .NET applications with realistic data preparation, inference, and deployment expectations. USE FOR: ML.NET integration; local model training or retraining; inference pipelines, model loading, evaluation, and deployment review. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.