Skip to content

Remove more fixed buffers and replace them with InlineArray - #125574

Merged
EgorBo merged 12 commits into
dotnet:mainfrom
EgorBo:more-fixed-buffers
Mar 16, 2026
Merged

Remove more fixed buffers and replace them with InlineArray#125574
EgorBo merged 12 commits into
dotnet:mainfrom
EgorBo:more-fixed-buffers

Conversation

@EgorBo

@EgorBoEgorBo commented Mar 15, 2026

Copy link
Copy Markdown
Member

This PR replaces the remaining fixed buffers with InlineArrays. Very minor diffs.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the migration away from fixed buffers in structs by using C# inline arrays (InlineArray / InlineArrayN<T>) and span-based access patterns, primarily in interop and low-level encoding/networking code.

Changes:

  • Replace fixed buffers with inline arrays (and conditional #if NET fallbacks where needed).
  • Update call sites to use span slicing / pointer casts compatible with inline-array-backed fields.
  • Adjust a few Windows interop usages (WinHTTP connection info, RtlGetVersion / OS version string, time zone structs) to work with the new buffer representations.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csSwitch Webcil header magic to InlineArray4<byte> under #if NET.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitialize WebcilHeader with default to support inline array field assignment.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csReplace fixed ulong[128] with an inline array buffer under #if NET.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csUpdate service-pack string construction for inline array buffer.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csUse inline-array-to-span slicing for MAC address extraction.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csUpdate UTF-8 name marshalling to use pointer to inline array buffer.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdate interface name and address parsing to use inline-array-backed spans.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUpdate native IP address span creation to slice from inline array.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUpdate gateway address creation to slice from inline array.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csUpdate endpoint address parsing to slice from inline array.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUpdate physical/IP address parsing to slice from inline array.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUse inline-array-backed span for WinHTTP remote address under #if NET.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplace fixed address buffers with inline array buffers under #if NET.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csReplace fixed CSD string buffer with inline array under #if NET and adjust P/Invoke usage.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplace fixed timezone name buffers with inline arrays and update string accessors.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csReplace fixed buffers in interface/address structs with InlineArrayN<T>.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csReplace fixed endpoint address buffer with InlineArray16<byte>.

CopilotAI review requested due to automatic review settings March 15, 2026 03:23

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the ongoing effort to remove fixed buffers and unsafe string/pointer patterns by adopting C# inline arrays ([InlineArray] / InlineArrayN<T>) and span-based accessors across interop-heavy areas.

Changes:

  • Replaced multiple fixed-size buffers in interop structs (WinHTTP, NtDll, Kernel32 timezone, msquic, Unix network info) with inline arrays.
  • Updated call sites to use span conversions / slicing instead of pointer-based access and Buffer.MemoryCopy.
  • Simplified a few APIs by removing unsafe where it’s no longer required (e.g., OS version string handling).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csReplaces Webcil header fixed byte[4] with inline array under #if NET.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitializes WebcilHeader to default to satisfy definite assignment with inline arrays.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csSwitches the ASCII preescape table to an inline array buffer under #if NET.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csRemoves pointer-based CSD version string creation in favor of span slicing.
src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.csReplaces several fixed buffers with inline array buffers in generated MsQuic interop structs.
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicTlsSecret.csUpdates secret extraction to use span casts over inline array buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csUses span slicing + ToArray() instead of Buffer.MemoryCopy for MAC address copy.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csAdjusts UTF-8 marshalling call to use pointer to inline array name buffer.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdates name/address handling to work with inline array buffers and spans.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUses span cast + slicing over inline array buffers for IP creation.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUses span cast + slicing over inline array buffers for gateway IP creation.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csMigrates endpoint address creation to span slicing over inline array buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUses span cast + slicing over inline array buffers for IP/MAC creation.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUses span access for WinHTTP remote address when inline arrays are enabled.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplaces fixed address buffers with [InlineArray(128)] when NET is defined.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csConverts fixed CSD version buffer to inline array (and updates P/Invoke to pointer-based signature).
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplaces fixed char buffers with inline arrays and span-to-string helpers.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csReplaces multiple Unix network fixed buffers with InlineArrayN<T> generics.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csReplaces BSD endpoint fixed buffer with InlineArray16<byte>.

EgorBoand others added 2 commits March 15, 2026 15:30
…fier
- Fix checked cast syntax errors in BsdIPGlobalProperties.cs: (int] -> (int)
- Restore 'unsafe' on AsciiPreescapedData struct for #else fixed buffer branch
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CopilotAI review requested due to automatic review settings March 15, 2026 14:31

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the repo-wide effort to replace fixed buffers with C# InlineArray-based representations, reducing unsafe usage while keeping the same native layouts for interop-heavy structs.

Changes:

  • Replace multiple fixed buffer fields in interop structs with InlineArray*<T> or [InlineArray(N)] buffer structs (often under #if NET).
  • Update call sites to use span casts / slicing instead of pointer-based span construction or Buffer.MemoryCopy.
  • Remove some unsafe usages where no longer needed (e.g., OS version / timezone string extraction).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csReplaces header magic fixed buffer with InlineArray on .NET builds.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitializes WebcilHeader to default before writing InlineArray / fixed-buffer elements.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csReplaces a fixed ulong[128] buffer with an InlineArray-backed buffer under #if NET.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csAvoids pointer-based string construction by slicing the InlineArray-backed CSD version buffer.
src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.csReplaces several fixed buffers with InlineArray-backed buffers in MsQuic interop structs.
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicTlsSecret.csUpdates TLS secret span creation to use InlineArray span casts + slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csUses InlineArray span slicing + ToArray() for MAC address extraction.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csUpdates name marshalling to account for InlineArray name buffer.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdates name, MAC, and IP address extraction for InlineArray buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUpdates IP creation from native info to use InlineArray span slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUpdates gateway address extraction for InlineArray span slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csUpdates endpoint IP parsing to use InlineArray span slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUpdates MAC + IP address extraction to use InlineArray span slicing.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUses InlineArray span conversion on .NET builds for WinHTTP sockaddr storage.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplaces fixed address buffers with InlineArray-backed buffer under #if NET.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csSwitches to pointer-based LibraryImport + InlineArray-backed CSD buffer under #if NET.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplaces fixed timezone name buffers with InlineArray-backed buffers and span-based string extraction.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csReplaces fixed buffers in Unix network enumeration interop structs with InlineArray*<T>.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csReplaces fixed AddressBytes buffer with InlineArray16<byte>.

Comment threadsrc/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@EgorBo
EgorBo marked this pull request as ready for review March 15, 2026 16:25
CopilotAI review requested due to automatic review settings March 15, 2026 16:25

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the effort to reduce unsafe fixed buffers by replacing them with C# inline arrays (InlineArrayN<T> or [InlineArray(N)] buffers), primarily in interop structs and related call sites, so the code can rely more on spans and less on raw pointers.

Changes:

  • Replace multiple fixed-size buffers in interop structs with inline arrays (including InlineArray2/3/4/8/16<T> and custom [InlineArray(N)] buffers).
  • Update consumers to use span-based access patterns (casts to Span<T> / ReadOnlySpan<T>, slicing) rather than fixed + pointer arithmetic.
  • Adjust a few APIs to no longer require unsafe at the method level when it’s no longer needed.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csReplace header magic fixed buffer with InlineArray4<byte> under #if NET.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitialize WebcilHeader with default to support safe inline-array field initialization.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csReplace fixed ulong[128] with [InlineArray(128)] buffer on NET and update indexing.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csRemove unsafe usage and switch to span-based extraction of szCSDVersion.
src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.csReplace several fixed buffers with inline arrays / [InlineArray] buffers in generated MsQuic interop.
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicTlsSecret.csUpdate access to MsQuic TLS secret buffers using span casts + slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csReplace Buffer.MemoryCopy MAC extraction with span slicing + ToArray().
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csAdjust UTF-8 name marshalling to take address of inline-array field.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdate interface name/address parsing to use span casts over inline arrays.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUse span slicing over inline array for IP address construction.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUse span slicing over inline array for gateway IP address construction.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csUse span slicing over inline arrays for TCP/UDP endpoint parsing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUse span slicing over inline arrays for MAC and IP address parsing.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUse inline-array span access for WINHTTP_CONNECTION_INFO.RemoteAddress under #if NET.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplace WINHTTP_CONNECTION_INFO fixed buffers with [InlineArray(128)] buffers under #if NET.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csReplace fixed char buffer with inline array under #if NET; change P/Invoke to pointer + fixed.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplace timezone name/key fixed buffers with inline arrays and span-based string creation.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csReplace multiple fixed buffers in unix network structs with InlineArrayN<T>.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csReplace IPEndPointInfo.AddressBytes fixed buffer with InlineArray16<byte>.

@EgorBo

Copy link
Copy Markdown
MemberAuthor

@MihuBot

…uicTlsSecret.cs
Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
CopilotAI review requested due to automatic review settings March 15, 2026 18:30
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the repo-wide modernization effort to remove fixed buffers in favor of C# InlineArray patterns, reducing unsafe usage and simplifying buffer access across tasks, libraries, and interop layers.

Changes:

  • Replaced multiple fixed buffers with InlineArray (or [InlineArray(N)]-annotated buffers) in interop structs and internal helpers.
  • Updated call sites to use span-based indexing/slicing for these buffers (e.g., ReadOnlySpan<T> / Span<T> conversions and range slicing).
  • Simplified some Windows string extraction from inline buffers by using ReadOnlySpan<char> + null-terminator search rather than pointer-based new string(char*).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csSwitches Webcil header magic ID storage from fixed to InlineArray on NET.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitializes WebcilHeader with default for safe field writes after buffer change.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csReplaces a fixed ulong[128] with an inline-array buffer on NET and updates indexing.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csRemoves pointer-based string creation for CSD version and uses span-based null-terminated slicing.
src/libraries/System.Net.Quic/src/System/Net/Quic/Interop/msquic_generated.csReplaces several msquic fixed buffers with inline-array buffers / InlineArray16<byte>.
src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicTlsSecret.csUpdates secret extraction to use spans over inline-array buffers with slicing to SecretLength.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csSimplifies link-layer address copying via span slicing + ToArray().
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csUpdates name marshalling to work with inline-array Name storage.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdates name and address span creation for inline-array fields.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUpdates IPAddress creation to slice spans from inline-array address buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUpdates gateway IP creation to slice spans from inline-array address buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csUpdates endpoint IP creation to slice spans from inline-array address buffers.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUpdates MAC and IP address span creation for inline-array buffers.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUses span conversion for WINHTTP_CONNECTION_INFO.RemoteAddress on NET.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplaces fixed byte[128] address buffers with an inline-array buffer type on NET.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csReplaces a fixed char[128] buffer with inline-array storage on NET and updates P/Invoke signature usage.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplaces multiple fixed char[] buffers with inline-array buffers and uses span-based string creation.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csConverts network interface interop structs from fixed buffers to InlineArrayN<T>.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csConverts endpoint address buffer from fixed to InlineArray16<byte>.

… more-fixed-buffers
# Conflicts:
#	src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/MsQuicTlsSecret.cs
CopilotAI review requested due to automatic review settings March 15, 2026 20:30
@EgorBo
EgorBoforce-pushed the more-fixed-buffers branch from e573d14 to ac6c192CompareMarch 15, 2026 20:30

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR continues the repo-wide migration away from fixed buffers, replacing remaining fixed-size buffers with C# inline arrays (either the built-in InlineArrayN<T> types or [InlineArray(N)]-annotated buffers) and updating call sites to use span-based access patterns.

Changes:

  • Replace fixed buffers in several interop / header structs with inline array buffers under #if NET (keeping fixed buffers for non-NET targets where needed).
  • Update consumers to use span indexing / slicing for inline-array-backed buffers (e.g., MAC addresses, IP addresses, SOCKADDR storage, OS version strings).
  • Minor safety / clarity adjustments related to definite assignment and null-terminated string extraction.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
FileDescription
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilHeader.csSwitch Webcil header ID buffer to InlineArray4<byte> under #if NET.
src/tasks/Microsoft.NET.WebAssembly.Webcil/WebcilConverter.csInitialize WebcilHeader to default so inline-array element assignment is valid.
src/libraries/System.Text.Encodings.Web/src/System/Text/Encodings/Web/OptimizedInboxTextEncoder.Ascii.csReplace fixed ulong[128] with [InlineArray(128)] buffer under #if NET and adjust indexing.
src/libraries/System.Private.CoreLib/src/System/Environment.Windows.csUse span-based extraction of szCSDVersion rather than pointer-based string creation.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/UnixNetworkInterface.csUse span slicing over inline-array-backed native buffers to materialize MAC addresses.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/NetworkInterfacePal.Android.csUpdate UTF-8 name marshalling to take a byte* to the inline-array field.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.csUpdate native buffer reads (name / MAC / IP bytes) for inline arrays using spans.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/IPAddressUtil.csUpdate IPAddress creation from native inline-array-backed buffers via spans.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIpInterfaceProperties.csUpdate gateway address materialization to use span slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/BsdIPGlobalProperties.csUpdate endpoint address materialization to use span slicing.
src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/AndroidNetworkInterface.csUpdate MAC/IP address materialization to use span slicing.
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http/WinHttpRequestCallback.csUse inline-array span access for WINHTTP_CONNECTION_INFO.RemoteAddress under #if NET.
src/libraries/Common/src/Interop/Windows/WinHttp/Interop.winhttp_types.csReplace fixed byte[128] with [InlineArray(128)] buffers under #if NET.
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.csMove OS version struct’s string buffer to inline array under #if NET and use pointer-based P/Invoke signature.
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.csReplace fixed char[] name buffers with inline arrays and use span-based string creation.
src/libraries/Common/src/Interop/Unix/System.Native/Interop.EnumerateInterfaceAddresses.csReplace fixed buffers in Unix native structs with InlineArrayN<T> buffers.
src/libraries/Common/src/Interop/BSD/System.Native/Interop.TcpConnectionInfo.csReplace fixed byte[16] endpoint buffer with InlineArray16<byte>.

@EgorBo

Copy link
Copy Markdown
MemberAuthor

PTAL @stephentoub@MihaZupan@tannergooding, failures aren't related

@EgorBo

Copy link
Copy Markdown
MemberAuthor

/ba-g deadletters + filed #125638

@EgorBo
EgorBo enabled auto-merge (squash) March 16, 2026 23:08
@EgorBo
EgorBo merged commit 133f6a8 into dotnet:mainMar 16, 2026
154 of 164 checks passed
CopilotAI added a commit that referenced this pull request Mar 17, 2026
…e structs
Reverts the InlineArray<T> replacements in networking-related P/Invoke structs
that were introduced by #125574. The generic InlineArray<byte> types (e.g.,
InlineArray16<byte>, InlineArray8<byte>) caused a Crst level violation:
CrstLoaderAllocatorReferences (level 17) cannot be acquired while holding
CrstILStubGen (level 14), which happens during IL stub generation for P/Invoke
methods that use these structs.
Reverted files:
- Interop.EnumerateInterfaceAddresses.cs: restored fixed byte buffers
- Interop.TcpConnectionInfo.cs: restored fixed byte buffers
- All callers in System.Net.NetworkInformation updated to use pointer-based span construction
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Apr 16, 2026
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@EgorBo@tannergooding@MihaZupan