fix: Silence CS1701/CS1702 warnings from Add-Type on PowerShell Core#129
Open
jamescrosswell wants to merge 3 commits into
Open
fix: Silence CS1701/CS1702 warnings from Add-Type on PowerShell Core#129jamescrosswell wants to merge 3 commits into
jamescrosswell wants to merge 3 commits into
Conversation
Roslyn was emitting five CS1701 warnings when importing the module on PowerShell hosts whose runtime System.Runtime version differs from the one Sentry.dll was compiled against (e.g. pwsh on .NET 10 vs Sentry.dll for net9.0). The binding succeeds and the module works fine, but the warnings are noisy and look alarming to first-time users. Pass /nowarn:CS1701;CS1702 via -CompilerOptions on the Add-Type call so the harmless binding-redirect warnings are suppressed while real compile errors still surface. Closes #123 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
-CompilerOptions is not available on Add-Type in Windows PowerShell 5.1 (Desktop edition). Gate it on $PSEdition -eq 'Core' so the module still loads under powershell.exe while PS Core continues to suppress the CS1701/CS1702 binding-redirect noise.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
vaind
approved these changes
May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The module's
Add-Typecall inSentry.psm1was emitting fiveCS1701warnings on PowerShell Core whenever the host's runtimeSystem.Runtimeversion didn't match the oneSentry.dllwas compiled against (e.g. pwsh on .NET 10 loading thenet9.0build of Sentry). The binding succeeds and the module works, but the warnings are noisy and look alarming.Pass
/nowarn:CS1701;CS1702via-CompilerOptionsso the harmless binding-redirect warnings are suppressed while real compile errors still surface.Verified locally on pwsh 7.6.1: 5 CS1701 warnings before the change, 0 after, and
Invoke-Pester tests/still passes (65 passed, 3 skipped).Note
-CompilerOptionsdoesn't exist onAdd-Typein Windows PowerShell 5.1 (Desktop edition) — it's PowerShell Core only so we only add CompilerOptions when$PSEdition -eq 'Core'Closes #123