Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Dotnet Csharp Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-dotnet-csharp-knowledge-patch)
---
name: dotnet-csharp-knowledge-patch
description: .NET and C#
version: null
license: MIT
metadata:
author: Nevaberry
---
# .NET and C# Knowledge Patch
Load this skill when applying .NET and C# compatibility changes or using the
language features, runtime APIs, and development tools covered in the references.
> [!CAUTION]
> Prerelease guidance may change before stable release. Affected items carry
> a prerelease marker beside their guidance.
## Reference index
| Reference | Topics |
| --- | --- |
| [Language](references/language.md) | API compatibility, span binding, lambdas, partial declarations, unions, extensions, memory safety |
| [Runtime and I/O](references/runtime-io.md) | Streams, filesystems, archives, normalization, layout, intrinsics, tensors, numeric APIs, LINQ |
| [Hosting and interop](references/hosting-platform-interop.md) | Processes, signals, crash reports, file locking, native library lookup, Runtime Async |
| [Security and networking](references/security-networking.md) | Security servicing, cryptographic platforms, key wrapping, post-quantum keys, TLS, HTTP, DNS, QUIC |
| [Serialization, data, and diagnostics](references/serialization-data-diagnostics.md) | JSON, XML, CBOR, validation, trace propagation, telemetry schemas, metrics |
| [SDK, CLI, and packaging](references/sdk-cli-packaging.md) | Restore, package feeds, MSBuild, tools, file-based apps, formatting, watch, testing, containers |
## Public API compatibility
- An ordinary nonvirtual method can change a `ref readonly` return to `ref`
compatibly. The same change on a virtual or interface method is breaking;
changing any writable `ref` return to `ref readonly` is also breaking.
- Changing a `ref` parameter to `ref readonly` preserves explicit `ref` calls.
Changing `in` to `ref readonly` can break builds that treat warnings as errors
because callers that omitted `in` now get a warning.
- Adding an instance field to a struct with only public fields or no fields can
break field-by-field initialization. Already compiled callers using
`[SkipLocalsInit]` can leave the added field uninitialized; initialize the whole
local with `default` before assigning individual fields.
- When adding an overload, you can move an existing optional default to the new overload
to avoid ambiguity: evolve `M(int a = 1)` into `M(int a)` and
`M(int a = 1, int b = 2)` so `M()` compiles and existing binaries keep their target.
- Adding a union case makes previously exhaustive switches non-exhaustive and can
make existing compiled switch expressions throw on the new value. Removing a
case removes its constructor, breaking callers that use it.
- Moving a C# 14 extension method from a `this` parameter declaration into an
`extension` block preserves source and binary compatibility when its callable
signature stays the same.
## Runtime, I/O, and deployment changes
- `BufferedStream.WriteByte` leaves flushing to the caller. Call `Flush()` where
subsequent code needs the buffered bytes to reach the underlying stream.
- Remove explicit `Size` from `StructLayout` on types marked with `InlineArray`;
inline array size must follow from the element type and array length.
- Pass an explicit mask to Arm64 SVE nonfaulting-load intrinsics when rebuilding.
- On Linux, `DriveInfo.DriveFormat` returns Linux filesystem type names; update
comparisons that rely on the previous values.
- `GnuTarEntry` and `PaxTarEntry` omit `atime` and `ctime` by default. Supply those
timestamps explicitly when the entries need to carry them.
- The runtime leaves termination signal handling to the application or host.
Register a handler if shutdown code depended on the runtime's default handlers.
- Single-file deployment drops executable-directory search for native libraries.
`DllImportSearchPath.AssemblyDirectory` restricts lookup to the assembly directory;
configure an explicit location if deployment depended on previous probing.
- Use `DOTNET_OPENSSL_VERSION_OVERRIDE` for OpenSSL and
`DOTNET_ICU_VERSION_OVERRIDE` for ICU in launch environments.
- Unix deployments using OpenSSL require version 1.1.1 or later. Switch macOS
callers of OpenSSL cryptographic primitives to platform-neutral APIs.
## Restore, build, and CLI changes
- `dotnet restore` drops `project.json` support. Migrate its package references to
an SDK-style project file.
- HTTP feed warnings are errors in `dotnet package list` and
`dotnet package search`. Use an HTTPS feed URL to avoid those failures.
- When a project targets .NET 10 or later, package pruning is enabled for all its
target frameworks. Framework-supplied packages can disappear from `.deps.json`;
affected direct references get `PrivateAssets="all"` and `IncludeAssets="none"`.
Set `<RestoreEnablePackagePruning>false</RestoreEnablePackagePruning>` to disable it.
- Target framework constants in `DefineConstants` are unavailable during project
evaluation. Use target framework properties for evaluation-time conditions.
- The SDK defaults to workload sets mode. Scripts that depend on loose manifests
must select that mode explicitly.
- The CLI permits prompts by default in interactive terminals, including
credential prompts. Pass `--interactive false` to disable prompting.
- `dotnet` logs unrelated to command results and `dotnet watch` logs go to stderr.
Capture stderr if scripts collect those logs.
- `EnableDynamicNativeInstrumentation` defaults to `false`; set it to `true` in
coverage configuration if the run needs dynamic native instrumentation.
## Networking, serialization, and cryptographic compatibility
- `<PublishTrimmed>true</PublishTrimmed>` disables HTTP/3 support by default.
- Browser HTTP clients stream response bodies by default. Explicitly buffer
response content when code needs the complete body in memory.
- The default trace context propagator follows W3C Trace Context. Use W3C headers
when relying on that default to propagate traces across services.
- `XmlSerializer` includes properties marked with `ObsoleteAttribute` in normal
member selection. Use `[XmlIgnore]` when a property must stay out of the contract.
- Check `CoseSigner.Key` for null before dereferencing it; a signer can expose null.
- Replace `SecretKey` with `PrivateKey` in renamed `MLDsa` and `SlhDsa` members.
- Update .NET 10 deployments to runtime `10.0.11` for the security fixes listed in
the security reference.
## C# binding and declarations
C# 14 can infer `T` and convert an array to `ReadOnlySpan<T>` when binding a span
extension method. The conversions can change which overload an existing call selects.
Lambda parameters with inferred types can use `scoped`, `ref`, `in`, `out`, or
`ref readonly`. Use explicitly typed parameters for a lambda with `params`.
```csharp
TryParse<int> parse = (text, out value) => int.TryParse(text, out value);
delegate bool TryParse<T>(string text, out T value);
```
Each partial instance constructor or event requires one defining and one implementing
declaration. Put `this(...)` or `base(...)` on the implementing constructor; pair a
field-like event declaration with an implementation defining both `add` and `remove`.
## JSON, validation, and tensor APIs
`JsonSerializerOptions.Strict` rejects unmapped and duplicate properties, binds names
case-sensitively, and honors nullable annotations and required constructor parameters.
To reject duplicates alone, set `AllowDuplicateProperties = false` on
`JsonSerializerOptions` or on `JsonDocumentOptions` when parsing with `JsonDocument`.
For Native AOT, supply the display name when constructing a `ValidationContext`,
for example `new ValidationContext(instance, "Options", null, null)`.
Stable tensor APIs come from `System.Numerics.Tensors`; slices share source storage.
Use nongeneric `IReadOnlyTensor` for shape and stride metadata. Arithmetic such as
`tensor + tensor` depends on the corresponding generic math interface on the element
type. Unsupported overlapping storage layouts are rejected; custom strides that yield
such layouts can fail.
## Cryptographic operations
For `MLKem`, `MLDsa`, and `SlhDsa`, check the type's `IsSupported` property before
generating or importing keys: platform support requires OpenSSL 3.5+ or Windows CNG
with post-quantum support. `MLDsa`, `SlhDsa`, and
`CompositeMLDsa` carry experimental diagnostic `SYSLIB5006`; some `MLKem` methods
are also experimental.
Use `certificate.ExportPkcs12(Pkcs12ExportPbeParameters.Pbes2Aes256Sha256, password)`
for AES-256 and SHA-256 PFX export. Use `Pkcs12TripleDesSha1` for legacy readers or
`PbeParameters` to select algorithms and iteration count explicitly.
For macOS client TLS 1.3, use
`AppContext.SetSwitch("System.Net.Security.UseNetworkFramework", true)` or
`DOTNET_SYSTEM_NET_SECURITY_USENETWORKFRAMEWORK=1` for `SslStream` and `HttpClient`.
The stack may drop TLS 1.0 and 1.1 and may reject some Unicode hostnames, for which
ASCII A-labels are preferable.
## Tool invocation and file-based apps
`dotnet tool exec dotnetsay@0.1.0 "Hello"` pins a one-shot tool invocation. Without a
pin, the CLI uses a nearby tool manifest's version when present, otherwise the latest
version. It prompts before downloading a tool unavailable locally.
Use `dotnet clean --cli-schema` for JSON argument, option, and subcommand definitions.
Generate native shell completions with `dotnet completions script SHELL`.
The .NET 10 SDK disallows double quotes in file-level directives. The .NET 11
SDK supports quoted `#:property` values and trailing `Name=Value` item metadata
on `#:package`, `#:project`, and `#:ref` directives.
```csharp
#:property AssemblyTitle="Sample App"
#:package Newtonsoft.Json@13.0.3 PrivateAssets=all
System.Console.WriteLine("Hello");
```
`dotnet format` supports file-based apps. In folder mode, it discovers `.editorconfig`
files only in ancestor directories of files included in the run.
## Prerelease language features
### Collection expression arguments
> **Prerelease (`net-and-c-csharp-whats-new-current`):** This guidance may change before stable release.
Put `with(...)` first in a collection expression to pass constructor or factory
arguments: `HashSet<string> names = [with(StringComparer.OrdinalIgnoreCase), "Ada", "ADA"];`.
### Union types
> **Prerelease (`net-and-c-csharp-whats-new-current`):** This guidance may change before stable release.
Declare case types with `union` and assign case values through implicit conversion.
A `switch` expression can cover the union by matching each case type. The runtime
exposes `UnionAttribute` and `IUnion` starting in .NET 11 Preview 5.
### Memory safety at member boundaries
> **Prerelease (`net-and-c-csharp-whats-new-current`):** This guidance may change before stable release.
The preview compiler recognizes `safe` on `extern` members and explicit-layout fields.
Assembly opt-in via `System.Runtime.CompilerServices.MemorySafetyRulesAttribute` and
enforcement of `unsafe` at call sites are still pending.
## Prerelease runtime and tooling
### Runtime Async opt-in
> **Prerelease (`net-and-c-dotnet-whats-new-current`):** This guidance may change before stable release.
Projects targeting `net11.0` can drop `<EnablePreviewFeatures>true</EnablePreviewFeatures>`
if Runtime Async was their only reason to enable it.
### CLI and build server defaults
> **Prerelease (`net-and-c-dotnet-whats-new-current`):** This guidance may change before stable release.
The Native AOT CLI and MSBuild build server are enabled by default. Leaving
`DOTNET_CLI_USE_MSBUILD_SERVER` unset allows the CLI to use the server.
### Test run controls
> **Prerelease (`net-and-c-dotnet-whats-new-current`):** This guidance may change before stable release.
`dotnet test` supports run-level `--timeout` and `--maximum-failed-tests` limits,
`--use-current-runtime`, and runner selection through `DOTNET_TEST_RUNNER`.