csharp12-features-guide

Explain C#12 and C#13 features with Unity 6 GC and hot-path safety.

71|11|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/nlelouche/Unity-SkillForge --skill csharp12-features-guide
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp12-features-guide
Source: https://github.com/nlelouche/Unity-SkillForge/tree/main/.agent/skills/00-core-engineering/csharp12-features-guide
Command: npx skills add https://github.com/nlelouche/Unity-SkillForge --skill csharp12-features-guide

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers understand and safely implement modern C#12 and C#13 language features within the Unity 6 / CoreCLR environment, focusing on performance and avoiding common pitfalls.

Core Features & Use Cases

  • Feature Mapping: Explains primary constructors, collection expressions, ref readonly parameters, Span<T>, inline arrays, and nameof.
  • GC Implications: Details GC allocation for each feature, identifying hot-path safe usage.
  • Unity Context: Provides Unity-specific rules and best practices for each feature.
  • Use Case: A developer needs to use collection expressions for initializing a list of game tags. This Skill guides them to use it safely during initialization rather than in an Update loop to prevent frame-rate drops.

Quick Start

Use the csharp12-features-guide skill to understand the performance implications of using Span<T> in Unity 6.

Frequently Asked Questions about csharp12-features-guide

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

FAQPage Schema
Can I use C#12 collection expressions in Unity 6 without triggering GC allocations?

C#12 collection expressions in Unity 6 do trigger GC allocations, making them unsafe for hot-paths. You should restrict collection expression initialization to setup phases rather than Update loops to prevent frame-rate drops.

How do primary constructors impact performance in Unity 6 with CoreCLR?

Primary constructors in Unity 6 CoreCLR provide cleaner syntax without adding runtime overhead. They are safe for hot-path execution when used correctly, though you must understand their specific GC implications to avoid unnecessary allocations.

What is the safest way to use Span<T> idioms in Unity 6?

The safest way to use Span<T> in Unity 6 is to leverage it for memory-safe operations that avoid GC allocations. This Skill guides you through Span<T> idioms and their performance implications to ensure hot-path safety in your game loops.

Does Unity 6 support ref readonly parameters for performance optimization?

Unity 6 with CoreCLR supports ref readonly parameters to prevent unnecessary data copying. This feature is detailed for Unity-specific use cases, allowing you to safely pass large structs without allocating memory on the garbage collected heap.

When should I avoid using new C#13 language features in Unity?

You should avoid using new C#13 language features in Unity hot-paths if they trigger GC allocations, such as improper collection expression usage. This guide identifies these constraints, helping you restrict allocation-heavy features to initialization phases.

Do I need prior C# experience to implement C#12 features in Unity 6?

You need a solid understanding of C# language fundamentals and Unity development practices to implement C#12 features. This guide builds on that foundation to explain Unity-specific rules, GC implications, and hot-path safety for modern language features.