From 0df145a7417996d71620232304a58b3a08634bb8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 3 Mar 2023 12:45:40 +0100 Subject: [PATCH] Use Unsafe.As to reinterpret ImmutableArray values --- .../D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs | 4 ++-- .../PixelShaderEffect{T}.Properties.Sources.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ComputeSharp.D2D1.Uwp/Loaders/D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs b/src/ComputeSharp.D2D1.Uwp/Loaders/D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs index 4399ec7c..23b2a081 100644 --- a/src/ComputeSharp.D2D1.Uwp/Loaders/D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs +++ b/src/ComputeSharp.D2D1.Uwp/Loaders/D2D1ImmutableArrayResourceTextureDescriptionsLoader.cs @@ -30,7 +30,7 @@ internal struct D2D1ImmutableArrayResourceTextureDescriptionsLoader : ID2D1Resou } /// - unsafe void ID2D1ResourceTextureDescriptionsLoader.LoadResourceTextureDescriptions(ReadOnlySpan data) + void ID2D1ResourceTextureDescriptionsLoader.LoadResourceTextureDescriptions(ReadOnlySpan data) { if (data.IsEmpty) { @@ -47,7 +47,7 @@ internal struct D2D1ImmutableArrayResourceTextureDescriptionsLoader : ID2D1Resou indices[i] = descriptions[i].Index; } - this.indices = *(ImmutableArray*)&indices; + this.indices = Unsafe.As>(ref indices); } } } \ No newline at end of file diff --git a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Sources.cs b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Sources.cs index 3d36a9ea..167d43cf 100644 --- a/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Sources.cs +++ b/src/ComputeSharp.D2D1.Uwp/PixelShaderEffect{T}.Properties.Sources.cs @@ -208,7 +208,7 @@ partial class PixelShaderEffect /// Gets the collection of valid indices for the current effect. /// /// The collection of valid indices for the current effect. - private static unsafe ImmutableArray GetIndices() + private static ImmutableArray GetIndices() { int inputCount = D2D1PixelShader.GetInputCount(); @@ -224,7 +224,7 @@ partial class PixelShaderEffect indices[i] = i; } - return *(ImmutableArray*)&indices; + return Unsafe.As>(ref indices); } } } \ No newline at end of file