diff --git a/CHANGELOG.md b/CHANGELOG.md index baadd4e5e7..7750a26b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - In MAUI Android apps, generate and inject UUID to APK and upload ProGuard mapping to Sentry with the UUID ([#4532](https://github.com/getsentry/sentry-dotnet/pull/4532)) +- Fixed WASM0001 warning when building Blazor WebAssembly projects ([#4519](https://github.com/getsentry/sentry-dotnet/pull/4519)) ## 5.15.1 diff --git a/src/Sentry/Platforms/Native/CFunctions.cs b/src/Sentry/Platforms/Native/CFunctions.cs index 582112fc4c..5faa149720 100644 --- a/src/Sentry/Platforms/Native/CFunctions.cs +++ b/src/Sentry/Platforms/Native/CFunctions.cs @@ -322,14 +322,25 @@ private static Dictionary LoadDebugImagesOnce(IDiagnosticLogge [DllImport("sentry-native")] internal static extern void sentry_value_decref(sentry_value_t value); - // native union sentry_value_u/t - [StructLayout(LayoutKind.Explicit)] + // Mirrors the native `sentry_value_t` union (uint64_t or double). + // Implemented with a single ulong backing field and BitConverter + // to reinterpret values, since explicit unions cause issues with + // Blazor WASM interop generators. internal struct sentry_value_t { - [FieldOffset(0)] - internal ulong _bits; - [FieldOffset(0)] - internal double _double; + private ulong _bits; + + internal ulong Bits + { + readonly get => _bits; + set => _bits = value; + } + + internal double Double + { + readonly get => BitConverter.UInt64BitsToDouble(_bits); + set => _bits = BitConverter.DoubleToUInt64Bits(value); + } } [DllImport("sentry-native")]