diff --git a/CHANGELOG.md b/CHANGELOG.md index 315ef10..4f1fe16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Silence CS1701/CS1702 warnings emitted by `Add-Type` when importing the module on PowerShell hosts whose runtime `System.Runtime` version differs from the one `Sentry.dll` was compiled against ([#129](https://github.com/getsentry/sentry-powershell/pull/129)) + ## 0.4.0 ### Fixes diff --git a/modules/Sentry/Sentry.psm1 b/modules/Sentry/Sentry.psm1 index 595b59d..11366ef 100644 --- a/modules/Sentry/Sentry.psm1 +++ b/modules/Sentry/Sentry.psm1 @@ -5,7 +5,16 @@ $moduleInfo = Import-PowerShellDataFile (Join-Path (Split-Path -Parent $MyInvoca . "$privateDir/Get-SentryAssembliesDirectory.ps1" $sentryDllPath = (Join-Path (Get-SentryAssembliesDirectory) 'Sentry.dll') -Add-Type -TypeDefinition (Get-Content "$privateDir/SentryEventProcessor.cs" -Raw) -ReferencedAssemblies $sentryDllPath -Debug:$false +$addTypeParams = @{ + TypeDefinition = (Get-Content "$privateDir/SentryEventProcessor.cs" -Raw) + ReferencedAssemblies = $sentryDllPath + Debug = $false +} +# -CompilerOptions is PS Core only; suppress CS1701/CS1702 (harmless binding-redirect noise) when available. +if ($PSEdition -eq 'Core') { + $addTypeParams['CompilerOptions'] = '/nowarn:CS1701;CS1702' +} +Add-Type @addTypeParams . "$privateDir/SentryEventProcessor.ps1" Get-ChildItem $publicDir -Filter '*.ps1' | ForEach-Object {