Skip to content

Conversation

@Tyrrrz
Copy link
Owner

@Tyrrrz Tyrrrz commented Jan 3, 2026

No description provided.

@Tyrrrz Tyrrrz added the enhancement New feature or request label Jan 3, 2026
Copilot AI review requested due to automatic review settings January 3, 2026 18:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request makes unsafe code opt-in for consumers of the PolyShim package, rather than automatically enabling it. Previously, the package automatically enabled AllowUnsafeBlocks for all consumers, which could have security and compatibility implications.

Key changes:

  • Unsafe code is now opt-in: consumers must explicitly set <AllowUnsafeBlocks>true</AllowUnsafeBlocks> to use polyfills that require unsafe code (e.g., Span with stackalloc)
  • Conditional compilation is used to only include unsafe polyfill features when the consumer has enabled unsafe blocks
  • Comprehensive documentation added explaining when and how to enable unsafe code

Reviewed changes

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

Show a summary per file
File Description
Readme.md Added documentation section explaining unsafe code requirements, with examples showing how to enable it and when it's needed. Updated compatibility package example to better demonstrate System.Memory usage.
PolyShim/PolyShim.props Removed automatic AllowUnsafeBlocks setting that was previously forced on all consumers
PolyShim/PolyShim.targets Added conditional compilation constant ALLOW_UNSAFE_BLOCKS when consumer enables unsafe blocks
PolyShim/PolyShim.csproj Added AllowUnsafeBlocks for building the PolyShim package itself
PolyShim/NetCore21/Span.cs Changed unsafe constructor to be conditionally compiled based on ALLOW_UNSAFE_BLOCKS define. Simplified pointer arithmetic implementation from Unsafe.Read to direct pointer indexing.
PolyShim.Tests/PolyShim.Tests.csproj Enabled AllowUnsafeBlocks for test project to test unsafe polyfill features

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Tyrrrz Tyrrrz merged commit 798b682 into master Jan 3, 2026
5 checks passed
@Tyrrrz Tyrrrz deleted the unsafe-opt-in branch January 3, 2026 19:41
@codecov
Copy link

codecov bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (3766cff) to head (424b744).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@     Coverage Diff      @@
##   master   #69   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants