Skip to content

Enroll the Microsoft.* libraries and their tests in unsafe-v2 (net11.0+) - #136720

Open
EgorBo wants to merge 26 commits into
dotnet:mainfrom
EgorBo:egorbo/unsafe-v2-microsoft-libs
Open

EgorBo wants to merge 26 commits into
dotnet:mainfrom
EgorBo:egorbo/unsafe-v2-microsoft-libs

Conversation

@EgorBo

@EgorBo EgorBo commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Enrolls the Microsoft.* libraries and their tests in unsafe-v2 for net11.0 and later and applies the output of the migration driver, one commit per project, untouched.

  • Enrollment: MemorySafetyRulesVersion=2 for net11.0+ in 43 libraries and 44 test project files. net10.0 and older keep the legacy rules: the LibraryImportGenerator in those targeting packs stamps unsafe on generated types, an unfixable CS9377 under the new rules. Microsoft.Bcl.* is not included.
  • Driver output: 12 libraries and 7 test projects needed changes; the rest build as is. No public or protected member requires unsafe.
  • AllowUnsafeBlocks: Microsoft.Extensions.Configuration.EnvironmentVariables and Microsoft.Extensions.Hosting.Functional.Tests opt in.
  • Tooling, separate commits: UnsafeMigrationFixAllProvider merges each fix as one minimal edit (a conflict used to silently drop every fix in a file), and UnsafeContextPlanner gets the block-first ordering from Enroll System.IO.Compression and its tests in unsafe-v2 #136657 without its test updates. Drop that commit once Enroll System.IO.Compression and its tests in unsafe-v2 #136657 lands.
Enrolled assemblies (43)
  • Microsoft.CSharp
  • Microsoft.Extensions.Caching.Abstractions
  • Microsoft.Extensions.Caching.Memory
  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.Configuration.Abstractions
  • Microsoft.Extensions.Configuration.Binder
  • Microsoft.Extensions.Configuration.CommandLine
  • Microsoft.Extensions.Configuration.EnvironmentVariables
  • Microsoft.Extensions.Configuration.FileExtensions
  • Microsoft.Extensions.Configuration.Ini
  • Microsoft.Extensions.Configuration.Json
  • Microsoft.Extensions.Configuration.UserSecrets
  • Microsoft.Extensions.Configuration.Xml
  • Microsoft.Extensions.DependencyInjection
  • Microsoft.Extensions.DependencyInjection.Abstractions
  • Microsoft.Extensions.DependencyInjection.Specification.Tests
  • Microsoft.Extensions.DependencyModel
  • Microsoft.Extensions.Diagnostics
  • Microsoft.Extensions.Diagnostics.Abstractions
  • Microsoft.Extensions.FileProviders.Abstractions
  • Microsoft.Extensions.FileProviders.Composite
  • Microsoft.Extensions.FileProviders.Physical
  • Microsoft.Extensions.FileSystemGlobbing
  • Microsoft.Extensions.Hosting
  • Microsoft.Extensions.Hosting.Abstractions
  • Microsoft.Extensions.Hosting.Systemd
  • Microsoft.Extensions.Hosting.WindowsServices
  • Microsoft.Extensions.Http
  • Microsoft.Extensions.Logging
  • Microsoft.Extensions.Logging.Abstractions
  • Microsoft.Extensions.Logging.Configuration
  • Microsoft.Extensions.Logging.Console
  • Microsoft.Extensions.Logging.Debug
  • Microsoft.Extensions.Logging.EventLog
  • Microsoft.Extensions.Logging.EventSource
  • Microsoft.Extensions.Logging.TraceSource
  • Microsoft.Extensions.Options
  • Microsoft.Extensions.Options.ConfigurationExtensions
  • Microsoft.Extensions.Options.DataAnnotations
  • Microsoft.Extensions.Primitives
  • Microsoft.Win32.Registry
  • Microsoft.Win32.Registry.AccessControl
  • Microsoft.Win32.SystemEvents

Related: #131451 (tracking), #136664 (enrollment tracking), #136621 (infrastructure), #136657 (System.IO.Compression).

Blocked by #136657 (has to be merged first).

EgorBo and others added 26 commits October 30, 2026 17:28
…ect interior insertions

Document.GetTextChangesAsync can return scattered non-minimal edits for a single
extern fix (e.g. RuntimeHandles.GetMethodDef in CoreLib), which then overlapped
with the edit of a neighboring diagnostic and made SourceText.WithChanges throw
'The changes must not overlap', silently dropping every CS9389 fix in the file.
Diff by trimming the common prefix/suffix instead, and treat an insertion inside
another edit as a conflict.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…on driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…he migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…gration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…e migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…ion driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
… the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…ration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…h the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…uched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…er (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…gration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…Variables

It compiles the shared ValueStringBuilder, which now contains unsafe blocks under unsafe-v2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…0 and later

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
… (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…2 with the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…th the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
… migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…v2 with the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…n driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…ation driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
It compiles extern declarations that now need an explicit unsafe contract.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
…th the migration driver (untouched output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 516325d9-9475-4e86-88ca-7b28389c6572
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Oct 30, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Runtime.InteropServices linkable-framework Issues associated with delivering a linker friendly framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant