Repository navigation
Enroll System.IO.Compression and its tests in unsafe-v2 - #136657
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Unmodified output of the migration driver across net12.0-windows, net12.0-unix, net12.0-browser, net12.0-wasi, and net12.0. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Unmodified output of the fixed migration driver across net12.0-windows, net12.0-unix, and net12.0-browser. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Enable the two affected consumer test projects to compile the migrated shared helper. Neither project is enrolled in unsafe-v2. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
|
Azure Pipelines: Successfully started running 4 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. |
|
Tagging subscribers to this area: @karelz, @dotnet/area-system-io-compression |
Try all valid block candidates before unsafe expressions, including expression-body conversions. Keep expressions as a fallback and preserve the explicit expression-first action. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Retain unsafe-v2 enrollment and approved consumer settings. Restore only the previous automatic migration output before regenerating contexts with the updated fixer. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Untouched output of a full driver replay from pre-migration sources across all five library TFMs. Control-flow headers and convertible expression bodies now prefer unsafe blocks. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
Untouched output of the fixed migration driver across all three test TFMs. Co-authored-by: Copilot <[email protected]> Copilot-Session: 5d9d8def-16fe-4105-9e0f-b8aad187abce
|
PTAL @agocke @jkotas @jjonescz. It contains a small fix (and tests) for UnsafeContext injector (to prioritize statements over expressions). Tracking issue: #136664 I don't expect a PR per assembly, I think many of them could be batched. (say up to 2000 LOC of changes or more). |
|
NOTE: there are no functional changes here, it's really about agreeing on the format. |
|
@EgorBo are we as IO.Compression owners expected to review this? If so, what should we be looking for? |
I have requested the review for awareness - to make sure that the area owners are comfortable with assuming the ownership of these annotations. |
|
I see, and I assume once this is merged, it is up to us to fill in those security annotations? Is there some document/playbook summarizing the approach? I may have gaps in how unsafe-v2 is supposed to work so I could use some examples to work from. |
unsafe-v2 spec: https://github.com/dotnet/csharplang/blob/main/proposals/unsafe-evolution.md The clean up work can be done by code owners or we'll just send an AI PR that you can review. The work is:
// Compression level functions
[LibraryImport(Libraries.CompressionNative)]
internal static unsafe partial int ZSTD_minCLevel();looks like a perfect candidate for Optional: replace unsafe{} with a code that doesn't require it. |
rzikm
left a comment
There was a problem hiding this comment.
LGTM from IO.Compression perspective, I will raise the follow-up PR with the required annotations.
|
@EgorBo Are we waiting for review from others or can I merge this? |
A member's safety contract is its RequiresUnsafe marker plus its <safety> prose. dotnet/runtime has begun enrolling implementation projects in the updated memory-safety rules (dotnet/runtime#136657), so later runtime packs may mark their own members, including non-public ones the reference assembly omits. The reference surface stays authoritative for members it declares; the implementation supplies the contract only for members the surface omits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* State the Platform surface and implementation roles A Platform Library gets the same two roles as a package Library: the reference-pack assembly is its surface (Type list, declarations, counts, Opportunities, explicit memory-safety contracts, row navigation) and the same-named runtime-pack assembly is its implementation (bodies, Metadata, Integrations, Performance, Unsafe body evidence, call graphs). Ref-less assemblies keep the shared-role rule, ref-only assemblies report implementation views unavailable, facades keep their reference surface, and forwarded-Type activation stays on runtime-pack evidence. Memory-safety contracts make the split load-bearing: .NET 11 runtime-pack assemblies carry no RequiresUnsafe or MemorySafetyRules markers; only the reference pack does. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Assign safety contracts to the declaring Platform role A member's safety contract is its RequiresUnsafe marker plus its <safety> prose. dotnet/runtime has begun enrolling implementation projects in the updated memory-safety rules (dotnet/runtime#136657), so later runtime packs may mark their own members, including non-public ones the reference assembly omits. The reference surface stays authoritative for members it declares; the implementation supplies the contract only for members the surface omits. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ompression Co-authored-by: Copilot <[email protected]> Copilot-Session: 9190ec1a-b880-4650-942f-d7f17a4d06f8
Taking the address of an unassigned out parameter now requires an unsafe context. Co-authored-by: Copilot <[email protected]> Copilot-Session: 9190ec1a-b880-4650-942f-d7f17a4d06f8
|
@rzikm I just got back from vacation. We plan to stop requiring unsafe for stackalloc (via dotnet/roslyn#86294), but this PR has only a few of them, so it's probably fine to merge as is (and then remove the redundant unsafe{} once we update Roslyn). Can you re-approve it? |
|
ping @rzikm |
|
/ba-g merge stuck |
I chose
System.IO.Compression(and its tests) as the first target because it's relatively small and interop-heavy.This PR covers only the mechanical migration: there is no AI-driven work to fill in safety comments or decide which methods might need a caller-unsafe contract. This lets the review focus entirely on the code fixer output.
References
A prompt for reading all the relevant documentation and running the driver script:
(I also tell it where to find a prebuilt dotnet/runtime in WSL so it can handle Linux targets there.)