From 57ea8dbb9147848b573113661494d34e6ab23c64 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Thu, 20 Jun 2019 15:16:18 +0200 Subject: [PATCH] [CoreFoundation] Remove StructLayout from the DispatchBlock class. (#6383) The StructLayout is not needed on our classes, since we should never pass them directly to P/Invokes (the .Handle property should always be used). So remove the attribute from the DispatchBlock class. It seems DispatchBlock was a struct in the initial implementation, then became a class as the pull request in question evolved, but the StructLayout attribute remained. Removing it also has another advantage: P/Invokes will throw a marshalling exception if such a class is passed in (instead of the native function doing random things because we passed in garbage). --- src/CoreFoundation/DispatchBlock.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CoreFoundation/DispatchBlock.cs b/src/CoreFoundation/DispatchBlock.cs index 71a2d27ff3..9ec768efdd 100644 --- a/src/CoreFoundation/DispatchBlock.cs +++ b/src/CoreFoundation/DispatchBlock.cs @@ -16,7 +16,6 @@ using Foundation; namespace CoreFoundation { #if !COREBUILD - [StructLayout (LayoutKind.Sequential)] [iOS (8, 0)] [Mac (10, 10)] public sealed class DispatchBlock : NativeObject {