system-net-review

Guides writing and reviewing System.Net networking code in dotnet/runtime.

18.2k|5.6k|Updated Sep 24, 2019
One-click install
npx skills add https://github.com/dotnet/runtime --skill system-net-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: system-net-review
Source: https://github.com/dotnet/runtime/tree/main/.github/skills/system-net-review
Command: npx skills add https://github.com/dotnet/runtime --skill system-net-review

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing or modifying System.Net networking code in dotnet/runtime requires deep knowledge of resource lifecycle, connection pooling, cross-platform interop, protocol compliance, async patterns, and security defaults, and mistakes in these areas cause leaks, protocol violations, or security regressions.

Core Features & Use Cases

  • Decision Frameworks: Provides six structured decision trees covering resource lifecycle, connection pooling, P/Invoke interop, HTTP/QUIC protocol compliance, async patterns, and TLS security posture.
  • Code Patterns: Supplies concrete do/don't C# examples for NetEventSource tracing, SocketAsyncEventArgs reuse, pool returns, SslStream configuration, ArrayPool buffers, HTTP/2 flow control, and cancellation plumbing.
  • Review Delegation: Routes full code reviews to the @system-net-review agent with severity-weighted checklists while this skill supplies authoring guidance.
  • Use Case: When modifying SocketsHttpHandler connection pooling logic, consult the pooling framework to ensure connections are validated before return, locks are never held across awaits, and pool disposal drains all waiters.

Quick Start

Ask the assistant to review or help write System.Net networking code, such as "review my changes to SslStream certificate validation using the system-net-review guidance."

Frequently Asked Questions about system-net-review

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

FAQPage Schema
How do I write async networking code in System.Net libraries?

Use ValueTask<T> when synchronous completion is common, always apply ConfigureAwait(false) in library code, and accept a CancellationToken linked with internal timeout tokens. Never await inside a lock; use SemaphoreSlim for async mutual exclusion instead.

How should I handle connection pooling in SocketsHttpHandler?

Validate connection state before returning it to the pool and dispose connections with unread data or protocol errors. Never hold locks while awaiting I/O, prefer Interlocked for hot-path counters, and ensure pool disposal drains all waiters and closes connections.

What is the correct way to add P/Invoke declarations in dotnet/runtime?

Use [LibraryImport] rather than [DllImport], place declarations under Common/src/Interop/<platform>/, and wrap native handles in SafeHandle subclasses. Use Utf8 string marshalling on Unix and Utf16 on Windows, and verify struct layouts across x86, x64, and arm64.

Does System.Net testing require real network access?

No, functional tests use in-process loopback servers such as LoopbackServer for HTTP/1.1, Http2LoopbackServer, Http3LoopbackServer, and LoopbackProxyServer. Platform-specific tests use ConditionalFact or ConditionalTheory with PlatformDetection.

What TLS defaults should SslStream code use?

Set EnabledSslProtocols to SslProtocols.None so the OS negotiates the best protocol, and never hardcode TLS 1.0 or 1.1. The default certificate validation callback must reject invalid certificates, and credentials must never be logged or cached beyond the session.