type-design-performance

Enforces .NET type design best practices including readonly structs and immutable collections to prevent performance pitfalls.

1|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/woutervanranst/Arius7 --skill type-design-performance-woutervanranst
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: type-design-performance
Source: https://github.com/woutervanranst/Arius7/tree/main/.agents/skills/csharp-type-design-performance
Command: npx skills add https://github.com/woutervanranst/Arius7 --skill type-design-performance-woutervanranst

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Performance pitfalls in .NET type design lead to unnecessary allocations, devirtualization costs, and fragile APIs. The guidelines help engineers craft efficient, maintainable types by applying proven principles.

Core Features & Use Cases

  • Seal classes by default to enable JIT devirtualization and clarify extension points.
  • Use readonly structs for immutable value types to avoid defensive copies.
  • Prefer static pure functions to minimize state, improve testability, and reduce allocations.
  • Defer enumeration and choose appropriate collection types to minimize allocations and timing costs.
  • Apply these guidelines to API surfaces, library internals, and performance-critical components.

Quick Start

Analyze a codebase to identify types that should be sealed and convert small value types to readonly structs.

Frequently Asked Questions about type-design-performance

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

FAQPage Schema
How do I optimize .NET type design for maximum performance?

To optimize .NET type design for performance, seal classes by default to enable JIT devirtualization, use readonly structs to avoid defensive copies, and prefer static pure functions to minimize state and reduce allocations.

Why does sealing classes improve C# application performance?

Sealing classes improves C# performance by enabling JIT devirtualization, which removes the overhead of virtual method dispatch, while also clarifying intended extension points and reducing memory footprints in performance-sensitive code.

What is the best way to avoid unnecessary allocations in .NET library internals?

The best way to avoid allocations in .NET library internals is deferring enumeration, choosing appropriate immutable collection types, and applying static pure functions to minimize state and memory footprints.

When do I need readonly structs in C# architecture?

You need readonly structs in C# architecture when designing immutable value types, which prevents the compiler from generating costly defensive copies during method calls in performance-critical components.

Does using static pure functions improve API design maintainability?

Using static pure functions improves API design maintainability by minimizing state, improving testability, and reducing allocations, which collectively solve performance pitfalls and create efficient, maintainable .NET types.

What are the limitations of deferring enumeration in .NET collection types?

Deferring enumeration in .NET collection types requires careful lifecycle management to avoid multiple evaluations, but when applied correctly it minimizes allocation timing costs and optimizes performance-sensitive API surfaces.