Skip to content

[main] Source code updates from dotnet/roslyn - #6291

Merged
wtgodbe merged 31 commits into
mainfrom
darc-main-9221f731-a449-4f70-9703-fe8d50550540
May 7, 2026
Merged

wtgodbe merged 31 commits into
mainfrom
darc-main-9221f731-a449-4f70-9703-fe8d50550540

Conversation

@dotnet-maestro

@dotnet-maestro dotnet-maestro Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Note

This is a codeflow update. It may contain both source code changes from
the source repo
as well as dependency updates. Learn more here.

This pull request brings the following source code changes

From https://github.com/dotnet/roslyn

Diff the source with this PR branch
darc vmr diff --name-only https://github.com/dotnet/roslyn:2428f0c72de5d2eed863b9c420f840b78080f5cb..https://github.com/dotnet/dotnet:darc-main-9221f731-a449-4f70-9703-fe8d50550540

@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

Note

PRs from original repository included in this codeflow update:

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team April 27, 2026 13:46
@wtgodbe
wtgodbe enabled auto-merge (squash) April 27, 2026 19:49
@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

wtgodbe and others added 3 commits April 28, 2026 11:57
The generator dropped the net8.0 ItemGroup for System.Formats.Asn1.
This matches what exists in the 8.0.0 csproj.

Co-authored-by: Copilot <[email protected]>
@dotnet-maestro

Copy link
Copy Markdown
Contributor Author

Important

While this PR was open, the source repository has received code changes from this repository (an opposite codeflow merged).
To avoid complex conflicts, the codeflow cannot continue until this PR is closed or merged.

You can continue with one of the following options:

  • Ignore this and merge this PR as usual without waiting for the new changes.
    Once merged, Maestro will create a new codeflow PR with the new changes.
  • Close this PR and wait for Maestro to open a new one with old and new changes included.
    You will lose any manual changes made in this PR.
    You can also manually trigger the new codeflow right away by running:
    darc trigger-subscriptions --id d73732dd-59bf-4276-a1f8-7543e9b03bc9
    
  • Force a codeflow into this PR at your own risk if you want the new changes.
    User commits made to this PR might be reverted.
    darc trigger-subscriptions --id d73732dd-59bf-4276-a1f8-7543e9b03bc9 --force
    

💡 You may consult the FAQ for more information or tag @dotnet/prodconsvcs for assistance.

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 1, 2026 00:17
@ericstj
ericstj force-pushed the darc-main-9221f731-a449-4f70-9703-fe8d50550540 branch from 13ae236 to 9dd7323 Compare May 1, 2026 00:25
@ericstj

ericstj commented May 1, 2026

Copy link
Copy Markdown
Member

So lots of warnings as errors due to dotnet/roslyn@5850036

// Under the updated memory safety rules, a stackalloc_expression is unsafe if being converted to Span/ROS,
// does not have an initializer, and is used within a member with SkipLocalsInitAttribute.

We can apply unsafe to all of those cases.

@wtgodbe

wtgodbe commented May 1, 2026

Copy link
Copy Markdown
Member

@copilot please clean up this duplicate unsafe declaration:

D:\a_work\1\s\src\runtime\src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.Pkcs12.cs(1199,17): error CS1004: Duplicate 'unsafe' modifier [D:\a_work\1\s\src\runtime\src\libraries\Microsoft.Bcl.Cryptography\src\Microsoft.Bcl.Cryptography.csproj::TargetFramework=netstandard2.0]

auto-merge was automatically disabled May 1, 2026 15:28

Head branch was pushed to by a user without write access

Copilot AI commented May 1, 2026

Copy link
Copy Markdown
Contributor

@copilot please clean up this duplicate unsafe declaration:

D:\a_work\1\s\src\runtime\src\libraries\Common\src\System\Security\Cryptography\X509Certificates\X509CertificateLoader.Pkcs12.cs(119...

Fixed in 5de6720. Removed the #if !NET conditional unsafe block since unsafe is now applied unconditionally, eliminating the duplicate modifier.

Copilot finished work on behalf of wtgodbe May 1, 2026 15:29
Copilot AI requested a review from wtgodbe May 1, 2026 15:29
@wtgodbe
wtgodbe enabled auto-merge (squash) May 1, 2026 15:35
@wtgodbe

wtgodbe commented May 1, 2026

Copy link
Copy Markdown
Member

@copilot we still need to fix 2 more usages of stackalloc:

/__w/1/s/src/runtime/src/libraries/System.Private.CoreLib/src/System/Enum.cs(1943,40): error CS9361: stackalloc expression without an initializer inside SkipLocalsInit may only be used in an unsafe context [/__w/1/s/src/runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
/__w/1/s/src/runtime/src/libraries/System.Private.CoreLib/src/System/Enum.cs(1987,40): error CS9361: stackalloc expression without an initializer inside SkipLocalsInit may only be used in an unsafe context [/__w/1/s/src/runtime/src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]

Fix these by applying unsafe - use b9422b1 as an example of what to do.

@wtgodbe

wtgodbe commented May 4, 2026

Copy link
Copy Markdown
Member

@copilot fix this build error. If your most recent change introduced any similar errors, fix those as well:

D:\a_work\1\s\src\runtime\src\libraries\System.IO.Pipelines\src\System\IO\Pipelines\PipeReaderStream.cs(58,36): error CS0227: Unsafe code may only appear if compiling with /unsafe [D:\a_work\1\s\src\runtime\src\libraries\System.IO.Pipelines\src\System.IO.Pipelines.csproj::TargetFramework=netstandard2.0]
D:\a_work\1\s\src\runtime\src\libraries\System.IO.Pipelines\src\System\IO\Pipelines\PipeReaderStream.cs(58,36): error CS0227: Unsafe code may only appear if compiling with /unsafe [D:\a_work\1\s\src\runtime\src\libraries\System.IO.Pipelines\src\System.IO.Pipelines.csproj::TargetFramework=net462]

Copilot AI commented May 4, 2026

Copy link
Copy Markdown
Contributor

@copilot fix this build error. If your most recent change introduced any similar errors, fix those as well:

D:\a_work\1\s\src\runtime\src\libraries\System.IO.Pipelines\src\System\IO\Pipelines...

Fixed in 9fb875d. Added <AllowUnsafeBlocks>true</AllowUnsafeBlocks> to System.IO.Pipelines.csproj — it was the only project I modified that targets netstandard2.0/net462 without already having unsafe blocks enabled.

Copilot finished work on behalf of wtgodbe May 4, 2026 19:38
wtgodbe and others added 3 commits May 4, 2026 16:09
Roslyn 5.7.0 (CS9361) now requires methods using stackalloc without
initializers inside SkipLocalsInit-attributed assemblies to be marked
as unsafe.

Affected libraries:
- System.Formats.Asn1 (5 methods)
- System.Text.RegularExpressions (4 methods)

Co-authored-by: Copilot <[email protected]>
…Init

Comprehensive scan of all libraries with SkipLocalsInit + stackalloc
without initializer. Covers:
- System.Text.RegularExpressions (22 methods across 8 files)
- System.Formats.Asn1 (1 more: AsnWriter.GeneralizedTime)
- System.Linq.Expressions (1: ILGen.EmitDecimal)
- System.Net.WebSockets.Client (1: CreateSecKeyAndSecWebSocketAccept)

Co-authored-by: Copilot <[email protected]>
Required for the unsafe method added in the previous commit (ILGen.EmitDecimal).

Co-authored-by: Copilot <[email protected]>
jjonescz and others added 4 commits May 5, 2026 12:35
…sionInfo

More libraries exposed by source-build reaching further into the build:
- System.IO.Compression (14 methods: ZipBlocks, ZipArchiveEntry, HuffmanTree, ZstandardStream)
- System.Security.Cryptography (4 methods: Aes, SP800108, X25519)
- System.Diagnostics.FileVersionInfo (1 method: ParseVersion)

The SDK failure in this build is the known TemplateEngine file lock
race (sdk#54020), unrelated to CS9361.

Co-authored-by: Copilot <[email protected]>
25 more methods across 17 files, mostly X509 certificate operations
and crypto primitives (Aes, DSA, HMAC, Base64, ECC, KMAC).

The SDK failure in the previous build was the known TemplateEngine file
lock race (sdk#54020), unrelated.

Co-authored-by: Copilot <[email protected]>
@ericstj

ericstj commented May 5, 2026

Copy link
Copy Markdown
Member

@wtgodbe -- if this takes much longer we can just nowarn the diagnostic in runtime and file an issue for folks to clean it up.

It's a bit annoying that these are difficult to repro locally. If we had a toolset package we could apply here it would help and we could have an agent fix everything, but since these are only hit in the offline source build - requiring a full sourcebuild / rebuild with latest. @jjonescz if you have any tips to drive to green without the full offline source build please suggest.

…rkInfo

30 more methods across 20 files:
- System.Security.Cryptography: ECDsa, HKDF, HMAC, IncrementalHash,
  KMAC, MD5/SHA*, PemEncoding, RandomNumberGenerator, Rfc2898,
  X25519, X509, XmlKeyHelper
- System.Net.NetworkInformation: IPv6 parsing, interface statistics
- System.Net.Ping: raw socket ping reply
- System.IO.Compression: WriteLocalFileHeader (missed in prior round)

Co-authored-by: Copilot <[email protected]>
@jjonescz

jjonescz commented May 6, 2026 •

Copy link
Copy Markdown
Member

if this takes much longer we can just nowarn the diagnostic in runtime and file an issue for folks to clean it up.

It's not a warning, it's an error.

if you have any tips to drive to green without the full offline source build please suggest.

If you install the corresponding compiler toolset package, you should be able to repro (modulo any runtime repo quirks I might be missing). I can try that with a local copilot loop, that's a good idea.

jjonescz and others added 5 commits May 6, 2026 09:56
23 methods across 11 files:
- System.Runtime.InteropServices.JavaScript (11: Func/Task marshaling)
- System.Security.Cryptography (8: platform-specific - Android, Windows, Apple, Browser)
- Microsoft.Win32.Registry (1: GetSubKeyNames)
- System.Net.NameResolution (1: CreateIPv6Address)

Co-authored-by: Copilot <[email protected]>
@jjonescz

jjonescz commented May 6, 2026

Copy link
Copy Markdown
Member

So I built locally to try to find all the errors at once, but now I realize it was -os linux only, that's why I missed src/runtime/src/libraries/System.Runtime.InteropServices.JavaScript.

@dotnet-policy-service
dotnet-policy-service Bot requested a review from a team May 6, 2026 23:41
@wtgodbe
wtgodbe merged commit c893036 into main May 7, 2026
15 of 16 checks passed
@wtgodbe
wtgodbe deleted the darc-main-9221f731-a449-4f70-9703-fe8d50550540 branch May 7, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants