type-design-performance

Guide .NET type design with sealing, immutable patterns, and efficient enumeration.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/tientt010/Dotnet-JiraLite-Microservices --skill type-design-performance-tientt010
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: type-design-performance
Source: https://github.com/tientt010/Dotnet-JiraLite-Microservices/tree/main/.github/skills/csharp-type-design-performance
Command: npx skills add https://github.com/tientt010/Dotnet-JiraLite-Microservices --skill type-design-performance-tientt010

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Design decisions for high-performance .NET types are complex and error-prone; this guide helps teams align on sealing, immutable patterns, and efficient enumeration to maximize runtime efficiency and API clarity.

Core Features & Use Cases

  • Seal non-inheritance points to enable JIT devirtualization.
  • Prefer readonly structs for immutable value types.
  • Favor static pure functions to reduce state and improve testability.
  • Defer enumeration and return immutable collections at API boundaries.
  • Use appropriate collection types to balance performance and semantics.

Quick Start

Refactor an existing domain by sealing relevant types, converting small value types to readonly structs, and replacing instance methods with static pure functions where feasible.

Frequently Asked Questions about type-design-performance

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

FAQPage Schema
How do I design high-performance .NET types for better runtime efficiency?

Design high-performance .NET types by sealing non-inheritance points to enable JIT devirtualization, preferring readonly structs for immutable values, and favoring static pure functions to reduce state and improve testability.

When should I seal .NET classes and structs to optimize performance?

Seal .NET types at non-inheritance points to enable JIT devirtualization, which maximizes runtime efficiency. This is particularly important when designing new libraries and APIs or reviewing existing code for performance improvements.

What is the best way to choose between class, struct, and record for high-performance .NET APIs?

Choose between class, struct, and record by preferring readonly structs for immutable value types and sealing classes where inheritance is unnecessary. This ensures efficient API boundaries and maximizes runtime performance.

How do I return immutable collections and defer enumeration at .NET API boundaries?

Defer enumeration and return immutable collections at API boundaries to balance performance and semantics. This approach maintains immutable API boundaries while ensuring efficient data processing across libraries.

Why does converting instance methods to static pure functions improve .NET performance?

Static pure functions improve .NET performance by reducing state and improving testability. Converting instance methods to static pure functions where feasible eliminates hidden dependencies and enables better runtime optimization.

Can I use this type design guide for refactoring existing .NET libraries?

Yes, you can refactor an existing domain by sealing relevant types, converting small value types to readonly structs, and replacing instance methods with static pure functions where feasible to improve performance.