

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
12345# System.Net Interop — Folder-Specific Guidance67## P/Invoke Declarations89- Use `LibraryImport` (source-generated) for all new P/Invoke declarations — do not use `DllImport`10- Mark string parameters with `StringMarshalling.Utf16` (Windows) or `StringMarshalling.Utf8` (Unix) explicitly11- Use `[return: MarshalAs(UnmanagedType.Bool)]` for native functions returning BOOL to avoid misinterpretation of non-zero values12- Verify that `SetLastError = true` is set only when the native function documents setting the thread error code1314## SafeHandle Usage1516- Every native handle must be wrapped in a SafeHandle-derived type — never store raw IntPtr in managed fields17- Override `ReleaseHandle` to call the correct native close/free function — never throw from ReleaseHandle18- Use `DangerousAddRef`/`DangerousRelease` only when passing handles to native code that may outlive the managed call — prefer CriticalHandle patterns where possible19- Ensure SafeHandle instances are not disposed while a P/Invoke call using that handle is in flight2021## Error Code Mapping2223- Map Windows error codes (HRESULT, Win32, WSA*) to specific .NET exception types — do not use generic Exception24- Map Unix errno values to SocketException with the correct SocketError value25- Use `Marshal.GetLastPInvokeError()` (not `Marshal.GetLastWin32Error()`) to retrieve error codes after LibraryImport calls26- Preserve the native error code in the exception for diagnostic purposes (e.g., as NativeErrorCode or inner exception)2728## Native Memory Management2930- Allocate native memory with `NativeMemory.Alloc` or `Marshal.AllocHGlobal` — always free in a finally block or via SafeHandle31- Pin managed arrays with `GCHandle.Alloc(array, GCHandleType.Pinned)` before passing to native code — release in finally32- For variable-length native structures, allocate sufficient buffer space and handle ERROR_INSUFFICIENT_BUFFER / ERANGE retry patterns33- Never access native memory after the owning SafeHandle is disposed3435## Struct Layout and Marshaling3637- Use `[StructLayout(LayoutKind.Sequential)]` for all interop structs — verify field order matches the native definition38- Ensure struct sizes and field offsets are correct for both 32-bit and 64-bit architectures39- Use fixed-size buffers (`fixed byte[N]`) for inline arrays in native structs rather than MarshalAs.ByValArray40- Test struct marshaling on all target platforms — padding and alignment rules differ between Windows and Unix4142## Native PAL Code (pal_network*)4344- C PAL functions must return error codes, not throw — the managed caller is responsible for mapping errors45- Use portable POSIX APIs where possible; isolate platform-specific code behind #ifdef guards46- Ensure all native allocations are freed on both success and error paths47- Do not include system headers that are not available on all supported Unix platforms — check build on Linux, macOS, and FreeBSD48
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| dotnet/runtime.github/copilot-instructions.md · 18k | Copilot instructions | buildteststylearch+2 | 78/100 | 14 days ago | |
| dotnet/runtime.github/instructions/cdac.instructions.md · 18k | Copilot instructions | typesgitapidocs | 52/100 | 14 days ago | |
| dotnet/runtime.github/instructions/compression.instructions.md · 18k | Copilot instructions | testlint-formatstylesecurity+1 | 60/100 | 14 days ago | |
| dotnet/runtime.github/instructions/conventions.instructions.md · 18k | Copilot instructions | stylearchagent-behaviourdocs | 56/100 | 7 days ago | |
| dotnet/runtime.github/instructions/core-runtime.instructions.md · 18k | Copilot instructions | styleperformance | 43/100 | 14 days ago | |
| dotnet/runtime.github/instructions/csharp.instructions.md · 18k | Copilot instructions | lint-formatstylearchsecurity+3 | 59/100 | 7 days ago | |
| dotnet/runtime.github/instructions/extensions-caching.instructions.md · 18k | Copilot instructions | styleperformanceagent-behaviour | 48/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-common.instructions.md · 18k | Copilot instructions | styledependencies | 48/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-configuration.instructions.md · 18k | Copilot instructions | no sections | 44/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-di.instructions.md · 18k | Copilot instructions | teststyletesting-strategy | 52/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-hosting.instructions.md · 18k | Copilot instructions | teststyleagent-behaviour | 52/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-logging.instructions.md · 18k | Copilot instructions | securityperformance | 44/100 | 14 days ago | |
| dotnet/runtime.github/instructions/extensions-options.instructions.md · 18k | Copilot instructions | style | 48/100 | 14 days ago | |
| dotnet/runtime.github/instructions/illink.instructions.md · 18k | Copilot instructions | no sections | 16/100 | 7 days ago | |
| dotnet/runtime.github/instructions/jit.instructions.md · 18k | Copilot instructions | buildgit | 29/100 | 14 days ago | |
| dotnet/runtime.github/instructions/system-net-common.instructions.md · 18k | Copilot instructions | styledependenciesapi | 48/100 | 14 days ago | |
| dotnet/runtime.github/instructions/system-net-quic.instructions.md · 18k | Copilot instructions | teststyleperformance | 56/100 | 14 days ago | |
| dotnet/runtime.github/instructions/system-net-sockets.instructions.md · 18k | Copilot instructions | styleagent-behaviour | 48/100 | 14 days ago | |
| dotnet/runtime.github/instructions/system-security-cryptography.instructions.md · 18k | Copilot instructions | stylesecurity | 48/100 | 8 days ago | |
| dotnet/runtimeeng/common/AGENTS.md · 18k | AGENTS.md | no sections | 4/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 14 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 14 days ago | |
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 14 days ago | |
| dotnet/roslyn.github/instructions/Compiler.instructions.md · 21k | Copilot instructions | buildteststylearch+3 | 99/100 | 7 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 14 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 7 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 14 days ago | |
| thangaram611/second-brain.github/copilot-instructions.md · 0 | Copilot instructions | setupteststylearch+4 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/dotnet-runtime-github-instructions-system-net-interop-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.