aot-json-serializer-context

Generate AOT JsonSerializerContext for Refit-generated C# contracts using Roslyn.

413|64|Updated Feb 7, 2023
One-click install
npx skills add https://github.com/christianhelle/refitter --skill aot-json-serializer-context
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aot-json-serializer-context
Source: https://github.com/christianhelle/refitter/tree/main/.squad/skills/aot-json-serializer-context
Command: npx skills add https://github.com/christianhelle/refitter --skill aot-json-serializer-context

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generate AOT JsonSerializerContext for generated contracts without regex-based type discovery, ensuring correct serialization contexts.

Core Features & Use Cases

  • Roslyn-based contract parsing to accurately collect types and namespaces.
  • Correct handling of nested types and namespace paths to emit Outer.Inner structures.
  • Register only closed generic usages to avoid open generic registrations.
  • Emit [JsonSerializable(typeof(...))] attributes on the proper partial context class within the contracts namespace.
  • Support both single-file and multi-file generation paths for the serializer context.
  • Applicable to Refitter-generated contracts to improve serialization performance and type safety.

Quick Start

Generate the AOT serializer context for your generated contracts using Roslyn and place it in the correct namespace.

Frequently Asked Questions about aot-json-serializer-context

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a JsonSerializerContext for Refitter without using regex for type discovery?

You can generate an AOT JsonSerializerContext for Refitter contracts using Roslyn to accurately parse types and namespaces, ensuring correct serialization contexts without relying on regex-based type discovery.

How does Roslyn handle nested and generic contracts when creating an AOT serialization context?

Roslyn parses contracts to handle nested types and namespace paths, emitting Outer.Inner structures. It registers only closed generic usages to avoid open generic registrations in the serialization context.

Can I emit [JsonSerializable] attributes in the correct namespace for multi-file Refitter outputs?

Yes, you can emit [JsonSerializable(typeof(...))] attributes on a proper partial context class within the contracts namespace, supporting both single-file and multi-file generation paths for the serializer context.

Why does my regex-based type discovery fail to create correct AOT serialization contexts for C# contracts?

Regex-based type discovery lacks the semantic accuracy needed for complex C# structures. Using Roslyn to parse contracts ensures correct handling of nested types, namespaces, and closed generic usages for AOT serialization.

When do I need an AOT JsonSerializerContext for generated C# contracts?

You need an AOT JsonSerializerContext for generated C# contracts when requiring strongly-typed serialization contexts to improve serialization performance and type safety, particularly in Ahead-of-Time compilation scenarios.

Does the aot-json-serializer-context Skill support open generic type registrations?

No, the Skill registers only closed generic usages to avoid open generic registrations, ensuring accurate and compilable [JsonSerializable] attributes for your generated contracts.