Skip to content
Back to skills

Dotnet Csharp Knowledge Patch

ASecurity

.NET and C#

  • 25 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 5, 2026
developmentgoc#expressapisecurity

Works with

  • terminal
  • cli
  • api

Security analysis

A100/100

Pro scans all 8 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill dotnet-csharp-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Dotnet Csharp Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Dotnet Csharp Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-dotnet-csharp-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-dotnet-csharp-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: dotnet-csharp-knowledge-patch
description: .NET and C#
version: null
license: MIT
metadata:
  author: Nevaberry
---



# .NET and C# Compatibility Guidance

Load this skill when updating .NET or C# code, reviewing API compatibility,
or changing runtime, serialization, networking, SDK, build, and test workflows.
Use the quick references below for common changes and the topic files for
complete guidance and examples.

> [!CAUTION]
> Prerelease guidance may change before stable release. Individual entries
> identify the guidance that is prerelease.

## Topic index

| Reference | Topics |
| --- | --- |
| [Language and compiler](references/language.md) | API compatibility, span receivers, lambdas, partial members, unions, closed hierarchies, extension indexers, control flow, memory safety |
| [Runtime and I/O](references/runtime-and-io.md) | Layout, time, normalization, intrinsics, numerics, tensors, collections, streams, archives, processes, tracing, metrics |
| [Security, networking, and interop](references/security-networking-and-interop.md) | Servicing, PKCS#12, key wrapping, post-quantum cryptography, OpenSSL, native lookup, TLS, HTTP, DNS, QUIC |
| [Serialization, hosting, and data](references/serialization-hosting-and-data.md) | JSON contracts and streaming, XML, CBOR, AOT validation, asynchronous validation, startup options |
| [SDK, CLI, build, and test](references/sdk-cli-build-and-test.md) | CLI defaults, tools, file-based apps, formatting, MSBuild, workloads, restore, watch, test runners, results |
| [Deployment and UI](references/deployment-and-ui.md) | Console containers, local container runtimes, reproducible image digests, Blazor browser refresh |

## Breaking changes and compatibility

### Ref returns and parameters

An ordinary nonvirtual method can change a `ref readonly` return to `ref`
compatibly. Changing a virtual or interface method from `ref readonly` to
`ref` is breaking, as is changing any writable `ref` return to `ref readonly`.
Changing a `ref` parameter to `ref readonly` preserves explicit `ref` calls.
Changing an `in` parameter to `ref readonly` can break builds that treat
warnings as errors because callers that omitted `in` now get a warning.

### Struct initialization and overload defaults

Adding any instance field to a struct with only public fields or no fields
can break callers that initialize a local field by field. Already compiled
callers using `[SkipLocalsInit]` can leave the added field uninitialized, so
initialize the whole local with `default` before assigning individual fields.
When adding an overload, you can move the existing 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()` still compiles and existing binaries keep
their original target.

### Extension binding and union evolution

C# 14 can infer `T` and convert an array to `ReadOnlySpan<T>` when binding a
span extension method; the new conversions can change overload selection.
Moving a C# 14 extension method from a `this` parameter declaration into an
`extension` block preserves source and binary compatibility when the callable
signature stays the same.
Adding a union case makes switches that covered all the original cases
non-exhaustive and can make compiled switch expressions throw on the new value.
Removing a case removes its constructor, breaking callers that use it.

### Runtime and native-library changes

- `BufferedStream.WriteByte` leaves flushing to the caller. Call `Flush()`
  where subsequent code needs buffered bytes to reach the underlying stream.
- Remove explicit `Size` from `StructLayout` on types marked with `InlineArray`.
  The runtime requires size to follow from the element type and array length.
- The runtime leaves termination signal handling to the application or host.
  Register a handler if shutdown code depended on the runtime's default handlers.
- Unix deployments using OpenSSL require version 1.1.1 or later. Switch macOS
  callers of OpenSSL cryptographic primitives to platform-neutral APIs.
- Use `DOTNET_OPENSSL_VERSION_OVERRIDE` for OpenSSL and
  `DOTNET_ICU_VERSION_OVERRIDE` for ICU in launch environments.
- 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 prior probing.

### Serialization and networking changes

- `XmlSerializer` includes properties marked with `ObsoleteAttribute` in normal
  member selection. Use `[XmlIgnore]` when a property must stay out of the contract.
- Publishing with `<PublishTrimmed>true</PublishTrimmed>` disables HTTP/3 by default.
- Browser HTTP clients stream response bodies by default. Explicitly buffer
  response content when the complete body is needed in memory.
- Check `CoseSigner.Key` for null before dereferencing it.
- Replace `SecretKey` with `PrivateKey` in renamed `MLDsa` and `SlhDsa` members.

### SDK, restore, and build changes

- 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"`. Disable with
  `<RestoreEnablePackagePruning>false</RestoreEnablePackagePruning>`.
- The SDK defaults to workload sets mode. Scripts depending on loose manifests
  must select that mode explicitly.
- Target framework constants in `DefineConstants` are unavailable during project
  evaluation. Use target framework properties for those evaluation-time conditions.
- `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.
- 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.

## Common APIs and workflows

### Security servicing

Update .NET 10 deployments to runtime `10.0.11` for the security fixes listed
in the security reference. SDK versions `10.0.400`, `10.0.303`, and `10.0.111`
include that runtime. The release recommends installing the latest update to
Visual Studio 18.9 on Windows.

### Strict JSON and AOT validation

`JsonSerializerOptions.Strict` rejects unmapped and duplicate properties,
binds property 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`.
Supply the display name to construct a `ValidationContext` for Native AOT:
`new ValidationContext(instance, "Options", null, null)`.

### Post-quantum keys

`MLKem`, `MLDsa`, and `SlhDsa` generate and import keys through static methods
such as `MLKem.GenerateKey(MLKemAlgorithm.MLKem768)`. Check the type's
`IsSupported` property first: 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.

### macOS client TLS

Set `AppContext.SetSwitch("System.Net.Security.UseNetworkFramework", true)` or
launch with `DOTNET_SYSTEM_NET_SECURITY_USENETWORKFRAMEWORK=1` to enable
Network.framework-backed client TLS for `SslStream` and `HttpClient`.
The new stack may drop TLS 1.0 and 1.1 support and may reject some Unicode
hostnames, for which ASCII A-labels are preferable.

### Tool invocation and command discovery

`dotnet tool exec dotnetsay@0.1.0 "Hello"` pins a one-shot invocation's version.
Without a pin, the CLI uses a nearby tool manifest's version when present and
otherwise selects the latest version. It prompts before downloading a tool
unavailable locally. Run `dotnet clean --cli-schema` for JSON argument, option,
and subcommand definitions; the option also works on subcommands.

### File-based app directives

The .NET 10 SDK disallows double quotes in file-level directives. For example,
use `#:property TargetFramework=net10.0`. The .NET 11 SDK supports quoted
`#:property` values such as `#:property AssemblyTitle="Sample App"` and trailing
`Name=Value` metadata on `#:package`, `#:project`, and `#:ref` directives.
`dotnet format` supports file-based apps. In folder mode it discovers
`.editorconfig` files only in ancestor directories of files included in the run.

## Prerelease quick references

### 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 arguments to its target
type's constructor or factory method:

```csharp
HashSet<string> names = [with(StringComparer.OrdinalIgnoreCase), "Ada", "ADA"];
```

### 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.

### 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`.

### Asynchronous data validation

> **Prerelease (`net-and-c-dotnet-whats-new-current`):** This guidance may change before stable release.

Use `AsyncValidationAttribute` for asynchronous attribute validators and
`IAsyncValidatableObject` for object-level validation. Invoke validation through
`Validator.ValidateObjectAsync`.

Files in this skill

  • SKILL.md8.9 KB
  • coverage.json865 B
  • references/deployment-and-ui.md1.9 KB
  • references/language.md2.9 KB
  • references/runtime-and-io.md3.1 KB
  • references/sdk-cli-build-and-test.md4 KB
  • references/security-networking-and-interop.md3.2 KB
  • references/serialization-hosting-and-data.md2.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.