From c086b573585f09cc67006f2c7f704101268bafde Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Wed, 10 Mar 2021 08:54:01 -0500 Subject: [PATCH] [metal] Add nullability to (generated and manual) bindings (#10823) Removed some outdated comments (intro runs fine with them now) See [HOWTO](https://github.com/xamarin/xamarin-macios/wiki/Nullability) --- src/Metal/Defs.cs | 2 + src/Metal/MTLArgumentEncoder.cs | 6 ++- src/Metal/MTLArrays.cs | 2 + ...ssSampleBufferAttachmentDescriptorArray.cs | 2 + src/Metal/MTLCompat.cs | 6 ++- src/Metal/MTLComputeCommandEncoder.cs | 6 ++- ...ssSampleBufferAttachmentDescriptorArray.cs | 2 + src/Metal/MTLDevice.cs | 37 +++++++++++------- src/Metal/MTLEnums.cs | 2 + src/Metal/MTLIntersectionFunctionTable.cs | 6 ++- .../MTLRasterizationRateLayerDescriptor.cs | 6 ++- src/Metal/MTLRenderCommandEncoder.cs | 2 + src/Metal/MTLRenderPassDescriptor.cs | 2 + ...ssSampleBufferAttachmentDescriptorArray.cs | 2 + src/Metal/MTLResourceStateCommandEncoder.cs | 10 +++-- ...ssSampleBufferAttachmentDescriptorArray.cs | 2 + src/Metal/MTLVertexDescriptor.cs | 2 + src/metal.cs | 38 ++++++++++++------- tests/xtro-sharpie/MacCatalyst-Metal.todo | 21 ---------- tests/xtro-sharpie/iOS-Metal.ignore | 25 ------------ tests/xtro-sharpie/macOS-Metal.ignore | 25 ------------ tests/xtro-sharpie/tvOS-Metal.ignore | 25 ------------ 22 files changed, 94 insertions(+), 137 deletions(-) diff --git a/src/Metal/Defs.cs b/src/Metal/Defs.cs index 7426c7ce35..650f72d143 100644 --- a/src/Metal/Defs.cs +++ b/src/Metal/Defs.cs @@ -14,6 +14,8 @@ using Foundation; using ModelIO; using ObjCRuntime; +#nullable enable + namespace Metal { public struct MTLOrigin { diff --git a/src/Metal/MTLArgumentEncoder.cs b/src/Metal/MTLArgumentEncoder.cs index 301efa70ac..ee66c93b05 100644 --- a/src/Metal/MTLArgumentEncoder.cs +++ b/src/Metal/MTLArgumentEncoder.cs @@ -3,6 +3,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { @@ -11,9 +13,9 @@ namespace Metal { public static void SetBuffers (this IMTLArgumentEncoder encoder, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) { if (buffers == null) - throw new ArgumentNullException (nameof (buffers)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (buffers)); if (offsets == null) - throw new ArgumentNullException (nameof (offsets)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (offsets)); var bufferPtrArray = buffers.Length <= 1024 ? stackalloc IntPtr[buffers.Length] : new IntPtr [buffers.Length]; // get all intptr from the array to pass to the lower level call diff --git a/src/Metal/MTLArrays.cs b/src/Metal/MTLArrays.cs index 46d5c9dd49..8f639120d3 100644 --- a/src/Metal/MTLArrays.cs +++ b/src/Metal/MTLArrays.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { public partial class MTLRenderPipelineColorAttachmentDescriptorArray { diff --git a/src/Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs b/src/Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs index b514464a27..0c35458e49 100644 --- a/src/Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs +++ b/src/Metal/MTLBlitPassSampleBufferAttachmentDescriptorArray.cs @@ -1,5 +1,7 @@ using System; +#nullable enable + namespace Metal { public partial class MTLBlitPassSampleBufferAttachmentDescriptorArray { diff --git a/src/Metal/MTLCompat.cs b/src/Metal/MTLCompat.cs index 559956386c..938118e46b 100644 --- a/src/Metal/MTLCompat.cs +++ b/src/Metal/MTLCompat.cs @@ -4,6 +4,8 @@ using System; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { public partial class MTLSharedTextureHandle { @@ -27,7 +29,7 @@ namespace Metal { public static IMTLCounterSampleBuffer CreateIMTLCounterSampleBuffer (this IMTLDevice This, MTLCounterSampleBufferDescriptor descriptor, out NSError error) { if (descriptor == null) - throw new ArgumentNullException ("descriptor"); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (descriptor)); IntPtr errorValue = IntPtr.Zero; var ret = Runtime.GetINativeObject (global::ObjCRuntime.Messaging.IntPtr_objc_msgSend_IntPtr_ref_IntPtr (This.Handle, Selector.GetHandle ("newCounterSampleBufferWithDescriptor:error:"), descriptor.Handle, ref errorValue), owns: false); @@ -45,7 +47,7 @@ namespace Metal { public static void SampleCounters (this IMTLComputeCommandEncoder This, IMTLCounterSampleBuffer sampleBuffer, nuint sampleIndex, bool barrier) { if (sampleBuffer == null) - throw new ArgumentNullException ("sampleBuffer"); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (sampleBuffer)); global::ObjCRuntime.Messaging.void_objc_msgSend_IntPtr_nuint_bool (This.Handle, Selector.GetHandle ("sampleCountersInBuffer:atSampleIndex:withBarrier:"), sampleBuffer.Handle, sampleIndex, barrier); } } diff --git a/src/Metal/MTLComputeCommandEncoder.cs b/src/Metal/MTLComputeCommandEncoder.cs index 62da42bb9c..db5eded163 100644 --- a/src/Metal/MTLComputeCommandEncoder.cs +++ b/src/Metal/MTLComputeCommandEncoder.cs @@ -3,6 +3,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { #if XAMCORE_4_0 @@ -13,9 +15,9 @@ namespace Metal { public static void SetBuffers (this IMTLComputeCommandEncoder table, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) { if (buffers == null) - throw new ArgumentNullException (nameof (buffers)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (buffers)); if (offsets == null) - throw new ArgumentNullException (nameof (offsets)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (offsets)); var bufferPtrArray = buffers.Length <= 1024 ? stackalloc IntPtr[buffers.Length] : new IntPtr [buffers.Length]; // get all intptr from the array to pass to the lower level call diff --git a/src/Metal/MTLComputePassSampleBufferAttachmentDescriptorArray.cs b/src/Metal/MTLComputePassSampleBufferAttachmentDescriptorArray.cs index 806f198f5c..87ae1b8e56 100644 --- a/src/Metal/MTLComputePassSampleBufferAttachmentDescriptorArray.cs +++ b/src/Metal/MTLComputePassSampleBufferAttachmentDescriptorArray.cs @@ -1,5 +1,7 @@ using System; +#nullable enable + namespace Metal { public partial class MTLComputePassSampleBufferAttachmentDescriptorArray { diff --git a/src/Metal/MTLDevice.cs b/src/Metal/MTLDevice.cs index 88d05727d3..bcec1f3182 100644 --- a/src/Metal/MTLDevice.cs +++ b/src/Metal/MTLDevice.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { #if MONOMAC [Advice ("The 'NSString' argument will match a property of 'MTLDeviceNotificationHandler'.")] @@ -25,9 +27,9 @@ namespace Metal { [DllImport (Constants.MetalLibrary)] extern static IntPtr MTLCreateSystemDefaultDevice (); - static IMTLDevice system_default; + static IMTLDevice? system_default; - public static IMTLDevice SystemDefault { + public static IMTLDevice? SystemDefault { get { // Metal could be unavailable on the hardware (and we don't want to return an invalid instance) // also the instance could be disposed (by mistake) which would make the app unusable @@ -67,7 +69,7 @@ namespace Metal { public static IMTLDevice [] GetAllDevices (ref NSObject observer, MTLDeviceNotificationHandler handler) { if (observer == null) - throw new ArgumentNullException ("observer"); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (observer)); IntPtr handle = observer.Handle; @@ -108,7 +110,7 @@ namespace Metal { public static void RemoveObserver (NSObject observer) { if (observer == null) - throw new ArgumentNullException ("observer"); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (observer)); MTLRemoveDeviceObserver (observer.Handle); } @@ -116,8 +118,11 @@ namespace Metal { } public static partial class MTLDevice_Extensions { - public static IMTLBuffer CreateBuffer (this IMTLDevice This, T [] data, MTLResourceOptions options) where T : struct + public static IMTLBuffer? CreateBuffer (this IMTLDevice This, T [] data, MTLResourceOptions options) where T : struct { + if (data == null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (data)); + var handle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object. try { IntPtr ptr = handle.AddrOfPinnedObject (); @@ -129,8 +134,11 @@ namespace Metal { #if !XAMCORE_4_0 [Obsolete ("Use the overload that takes an IntPtr instead. The 'data' parameter must be page-aligned and allocated using vm_allocate or mmap, which won't be the case for managed arrays, so this method will always fail.")] - public static IMTLBuffer CreateBufferNoCopy (this IMTLDevice This, T [] data, MTLResourceOptions options, MTLDeallocator deallocator) where T : struct + public static IMTLBuffer? CreateBufferNoCopy (this IMTLDevice This, T [] data, MTLResourceOptions options, MTLDeallocator deallocator) where T : struct { + if (data == null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (data)); + var handle = GCHandle.Alloc (data, GCHandleType.Pinned); // This requires a pinned GCHandle, since it's not possible to use unsafe code to get the address of a generic object. IntPtr ptr = handle.AddrOfPinnedObject (); return This.CreateBufferNoCopy (ptr, (nuint)(data.Length * Marshal.SizeOf (typeof (T))), options, (pointer, length) => { @@ -142,6 +150,9 @@ namespace Metal { public unsafe static void GetDefaultSamplePositions (this IMTLDevice This, MTLSamplePosition [] positions, nuint count) { + if (positions == null) + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (positions)); + if (positions.Length < (nint)count) throw new ArgumentException ("Length of 'positions' cannot be less than 'count'."); fixed (void * handle = positions) @@ -153,9 +164,9 @@ namespace Metal { public static void ConvertSparseTileRegions (this IMTLDevice This, MTLRegion [] tileRegions, MTLRegion [] pixelRegions, MTLSize tileSize, nuint numRegions) { if (tileRegions == null) - throw new ArgumentNullException (nameof (tileRegions)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (tileRegions)); if (pixelRegions == null) - throw new ArgumentNullException (nameof (pixelRegions)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (pixelRegions)); var tileRegionsHandle = GCHandle.Alloc (tileRegions, GCHandleType.Pinned); var pixelRegionsHandle = GCHandle.Alloc (pixelRegions, GCHandleType.Pinned); @@ -173,9 +184,9 @@ namespace Metal { public static void ConvertSparsePixelRegions (this IMTLDevice This, MTLRegion [] pixelRegions, MTLRegion [] tileRegions, MTLSize tileSize, MTLSparseTextureRegionAlignmentMode mode, nuint numRegions) { if (tileRegions == null) - throw new ArgumentNullException (nameof (tileRegions)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (tileRegions)); if (pixelRegions == null) - throw new ArgumentNullException (nameof (pixelRegions)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (pixelRegions)); var tileRegionsHandle = GCHandle.Alloc (tileRegions, GCHandleType.Pinned); var pixelRegionsHandle = GCHandle.Alloc (pixelRegions, GCHandleType.Pinned); @@ -193,10 +204,10 @@ namespace Metal { #if !XAMCORE_4_0 [return: Release] [BindingImpl (BindingImplOptions.GeneratedCode | BindingImplOptions.Optimizable)] - public static IMTLLibrary CreateLibrary (this IMTLDevice This, global::CoreFoundation.DispatchData data, out NSError error) + public static IMTLLibrary? CreateLibrary (this IMTLDevice This, global::CoreFoundation.DispatchData data, out NSError error) { if (data == null) - throw new ArgumentNullException ("data"); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (data)); IntPtr errorValue = IntPtr.Zero; IMTLLibrary ret; @@ -206,7 +217,7 @@ namespace Metal { return ret; } - public static IMTLLibrary CreateDefaultLibrary (this IMTLDevice This, NSBundle bundle, out NSError error) + public static IMTLLibrary? CreateDefaultLibrary (this IMTLDevice This, NSBundle bundle, out NSError error) { return MTLDevice_Extensions.CreateLibrary (This, bundle, out error); } diff --git a/src/Metal/MTLEnums.cs b/src/Metal/MTLEnums.cs index b9b34829f5..bad668fcad 100644 --- a/src/Metal/MTLEnums.cs +++ b/src/Metal/MTLEnums.cs @@ -14,6 +14,8 @@ using Foundation; using ModelIO; using ObjCRuntime; +#nullable enable + namespace Metal { [Native] diff --git a/src/Metal/MTLIntersectionFunctionTable.cs b/src/Metal/MTLIntersectionFunctionTable.cs index 73ed5a18c3..3793966c3e 100644 --- a/src/Metal/MTLIntersectionFunctionTable.cs +++ b/src/Metal/MTLIntersectionFunctionTable.cs @@ -4,6 +4,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { // add some extension methods to make the API of the protocol nicer @@ -13,9 +15,9 @@ namespace Metal { public static void SetBuffers (this IMTLIntersectionFunctionTable table, IMTLBuffer[] buffers, nuint[] offsets, NSRange range) { if (buffers == null) - throw new ArgumentNullException (nameof (buffers)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (buffers)); if (offsets == null) - throw new ArgumentNullException (nameof (offsets)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (offsets)); var bufferPtrArray = buffers.Length <= 1024 ? stackalloc IntPtr[buffers.Length] : new IntPtr [buffers.Length]; // get all intptr from the array to pass to the lower level call diff --git a/src/Metal/MTLRasterizationRateLayerDescriptor.cs b/src/Metal/MTLRasterizationRateLayerDescriptor.cs index 058a501f56..ad13efc7e1 100644 --- a/src/Metal/MTLRasterizationRateLayerDescriptor.cs +++ b/src/Metal/MTLRasterizationRateLayerDescriptor.cs @@ -6,6 +6,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { public partial class MTLRasterizationRateLayerDescriptor { @@ -34,9 +36,9 @@ namespace Metal { static public MTLRasterizationRateLayerDescriptor Create (MTLSize sampleCount, float[] horizontal, float[] vertical) { if (horizontal == null) - throw new ArgumentNullException (nameof (horizontal)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (horizontal)); if (vertical == null) - throw new ArgumentNullException (nameof (vertical)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (vertical)); if (sampleCount.Width != horizontal.Length) throw new ArgumentOutOfRangeException ("Horizontal length should be equal to the sampleCount.Width."); if (sampleCount.Height != vertical.Length) diff --git a/src/Metal/MTLRenderCommandEncoder.cs b/src/Metal/MTLRenderCommandEncoder.cs index 02e9e6bc45..b150c3a168 100644 --- a/src/Metal/MTLRenderCommandEncoder.cs +++ b/src/Metal/MTLRenderCommandEncoder.cs @@ -6,6 +6,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { public static class IMTLRenderCommandEncoder_Extensions { [Mac (10,13), NoiOS, NoTV, NoWatch] diff --git a/src/Metal/MTLRenderPassDescriptor.cs b/src/Metal/MTLRenderPassDescriptor.cs index 8ae6f14b17..ceeeb4c9f0 100644 --- a/src/Metal/MTLRenderPassDescriptor.cs +++ b/src/Metal/MTLRenderPassDescriptor.cs @@ -1,6 +1,8 @@ #if !COREBUILD using System; +#nullable enable + namespace Metal { public partial class MTLRenderPassDescriptor { public unsafe void SetSamplePositions (MTLSamplePosition [] positions) diff --git a/src/Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs b/src/Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs index 69645bcf02..5e3867b09b 100644 --- a/src/Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs +++ b/src/Metal/MTLRenderPassSampleBufferAttachmentDescriptorArray.cs @@ -1,5 +1,7 @@ using System; +#nullable enable + namespace Metal { public partial class MTLRenderPassSampleBufferAttachmentDescriptorArray { diff --git a/src/Metal/MTLResourceStateCommandEncoder.cs b/src/Metal/MTLResourceStateCommandEncoder.cs index e9054f8622..27194e23b9 100644 --- a/src/Metal/MTLResourceStateCommandEncoder.cs +++ b/src/Metal/MTLResourceStateCommandEncoder.cs @@ -12,6 +12,8 @@ using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; +#nullable enable + namespace Metal { public static partial class MTLResourceStateCommandEncoder_Extensions { @@ -20,13 +22,13 @@ namespace Metal { public static void Update (this IMTLResourceStateCommandEncoder This, IMTLTexture texture, MTLSparseTextureMappingMode mode, MTLRegion[] regions, nuint[] mipLevels, nuint[] slices) { if (texture == null) - throw new ArgumentNullException (nameof (texture)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (texture)); if (regions == null) - throw new ArgumentNullException (nameof (regions)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (regions)); if (mipLevels == null) - throw new ArgumentNullException (nameof (mipLevels)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (mipLevels)); if (slices == null) - throw new ArgumentNullException (nameof (slices)); + ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (slices)); var regionsHandle = GCHandle.Alloc (regions, GCHandleType.Pinned); var mipLevelsHandle = GCHandle.Alloc (mipLevels, GCHandleType.Pinned); diff --git a/src/Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs b/src/Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs index edc1175c45..ab92e1685d 100644 --- a/src/Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs +++ b/src/Metal/MTLResourceStatePassSampleBufferAttachmentDescriptorArray.cs @@ -1,5 +1,7 @@ using System; +#nullable enable + namespace Metal { #if !TVOS diff --git a/src/Metal/MTLVertexDescriptor.cs b/src/Metal/MTLVertexDescriptor.cs index 98b2bf362d..24175d8abb 100644 --- a/src/Metal/MTLVertexDescriptor.cs +++ b/src/Metal/MTLVertexDescriptor.cs @@ -6,6 +6,8 @@ using ModelIO; using ObjCRuntime; using Metal; +#nullable enable + namespace Metal { public partial class MTLVertexDescriptor { diff --git a/src/metal.cs b/src/metal.cs index 90763319ad..9cbb4d741c 100644 --- a/src/metal.cs +++ b/src/metal.cs @@ -105,9 +105,11 @@ namespace Metal { nuint Stride { get; } [Export ("elementStructType")] + [return: NullAllowed] MTLStructType ElementStructType (); [Export ("elementArrayType")] + [return: NullAllowed] MTLArrayType ElementArrayType (); [Mac (10,13), iOS (11,0), TV (11,0), NoWatch] @@ -1992,9 +1994,8 @@ namespace Metal { [Export ("compareFunction")] MTLCompareFunction CompareFunction { get; set; } - // [NullAllowed] we can't allow setting null - even if the default value is null - // /SourceCache/AcceleratorKit/AcceleratorKit-14.9/Framework/MTLSampler.m:240: failed assertion `label must not be nil.' [Export ("label")] + [NullAllowed] string Label { get; set; } [Mac (10, 13), iOS (11,0), TV (11,0), NoWatch] @@ -2018,9 +2019,8 @@ namespace Metal { [BaseType (typeof (NSObject))] partial interface MTLRenderPipelineDescriptor : NSCopying { - // [NullAllowed] we can't allow setting null - even if the default value is null - // /SourceCache/AcceleratorKit/AcceleratorKit-14.9/Framework/MTLRenderPipeline.mm:627: failed assertion `label must not be nil.' [Export ("label")] + [NullAllowed] string Label { get; set; } [NullAllowed] // by default this property is null @@ -2032,6 +2032,7 @@ namespace Metal { IMTLFunction FragmentFunction { get; set; } [Export ("vertexDescriptor", ArgumentSemantic.Copy)] + [NullAllowed] MTLVertexDescriptor VertexDescriptor { get; set; } [Export ("sampleCount")] @@ -2126,7 +2127,7 @@ namespace Metal { MTLRenderPipelineColorAttachmentDescriptor ObjectAtIndexedSubscript (nuint attachmentIndex); [Export ("setObject:atIndexedSubscript:"), Internal] - void SetObject (MTLRenderPipelineColorAttachmentDescriptor attachment, nuint attachmentIndex); + void SetObject ([NullAllowed] MTLRenderPipelineColorAttachmentDescriptor attachment, nuint attachmentIndex); } interface IMTLRenderPipelineState {} @@ -2198,14 +2199,14 @@ namespace Metal { MTLVertexBufferLayoutDescriptor ObjectAtIndexedSubscript (nuint index); [Export ("setObject:atIndexedSubscript:"), Internal] - void SetObject (MTLVertexBufferLayoutDescriptor bufferDesc, nuint index); + void SetObject ([NullAllowed] MTLVertexBufferLayoutDescriptor bufferDesc, nuint index); } [iOS (10,0), TV (10,0), NoWatch, Mac (10,12)] [BaseType (typeof(NSObject))] interface MTLAttribute { - [NullAllowed, Export ("name")] + [Export ("name")] string Name { get; } [Export ("attributeIndex")] @@ -2588,15 +2589,19 @@ namespace Metal { #if XAMCORE_4_0 [Export ("structType")] + [NullAllowed] MTLStructType StructType { get; } [Export ("arrayType")] + [NullAllowed] MTLArrayType ArrayType { get; } #else [Export ("structType")] + [return: NullAllowed] MTLStructType StructType (); [Export ("arrayType")] + [return: NullAllowed] MTLArrayType ArrayType (); #endif @@ -2620,6 +2625,7 @@ namespace Metal { MTLStructMember [] Members { get; } [Export ("memberByName:")] + [return: NullAllowed] MTLStructMember Lookup (string name); } @@ -2648,14 +2654,15 @@ namespace Metal { bool DepthWriteEnabled { [Bind ("isDepthWriteEnabled")] get; set; } [Export ("frontFaceStencil", ArgumentSemantic.Copy)] + [NullAllowed] MTLStencilDescriptor FrontFaceStencil { get; set; } [Export ("backFaceStencil", ArgumentSemantic.Copy)] + [NullAllowed] MTLStencilDescriptor BackFaceStencil { get; set; } - // [NullAllowed] we can't allow setting null - even if the default value is null - // /SourceCache/AcceleratorKit/AcceleratorKit-14.9/Framework/MTLDepthStencil.m:393: failed assertion `label must not be nil.' [Export ("label")] + [NullAllowed] string Label { get; set; } } @@ -3238,6 +3245,7 @@ namespace Metal { [BaseType (typeof (NSObject))] interface MTLRenderPipelineReflection { [Export ("vertexArguments")] + [NullAllowed] #if XAMCORE_4_0 MTLArgument [] VertexArguments { get; } #else @@ -3245,6 +3253,7 @@ namespace Metal { #endif [Export ("fragmentArguments")] + [NullAllowed] #if XAMCORE_4_0 MTLArgument [] FragmentArguments { get; } #else @@ -3338,7 +3347,7 @@ namespace Metal { MTLRenderPassColorAttachmentDescriptor ObjectAtIndexedSubscript (nuint attachmentIndex); [Export ("setObject:atIndexedSubscript:"), Internal] - void SetObject (MTLRenderPassColorAttachmentDescriptor attachment, nuint attachmentIndex); + void SetObject ([NullAllowed] MTLRenderPassColorAttachmentDescriptor attachment, nuint attachmentIndex); } [iOS (8,0)][Mac (10,11)] @@ -3349,9 +3358,11 @@ namespace Metal { MTLRenderPassColorAttachmentDescriptorArray ColorAttachments { get; } [Export ("depthAttachment", ArgumentSemantic.Copy)] + [NullAllowed] MTLRenderPassDepthAttachmentDescriptor DepthAttachment { get; set; } [Export ("stencilAttachment", ArgumentSemantic.Copy)] + [NullAllowed] MTLRenderPassStencilAttachmentDescriptor StencilAttachment { get; set; } [NullAllowed] // by default this property is null @@ -3622,14 +3633,13 @@ namespace Metal { [iOS (9,0)][Mac (10,11)] [BaseType (typeof (NSObject))] interface MTLComputePipelineDescriptor : NSCopying { - // it's marked as `nullable` but it asserts with - // /BuildRoot/Library/Caches/com.apple.xbs/Sources/Metal/Metal-54.18/Framework/MTLComputePipeline.mm:216: failed assertion `label must not be nil.' + [Export ("label")] + [NullAllowed] string Label { get; set; } - // it's marked as `nullable` but it asserts with - // /BuildRoot/Library/Caches/com.apple.xbs/Sources/Metal/Metal-54.18/Framework/MTLComputePipeline.mm:230: failed assertion `computeFunction must not be nil.' [Export ("computeFunction", ArgumentSemantic.Strong)] + [NullAllowed] IMTLFunction ComputeFunction { get; set; } [Export ("threadGroupSizeIsMultipleOfThreadExecutionWidth")] diff --git a/tests/xtro-sharpie/MacCatalyst-Metal.todo b/tests/xtro-sharpie/MacCatalyst-Metal.todo index bff3f4d69e..2c71020272 100644 --- a/tests/xtro-sharpie/MacCatalyst-Metal.todo +++ b/tests/xtro-sharpie/MacCatalyst-Metal.todo @@ -1,4 +1,3 @@ -!extra-null-allowed! 'System.String Metal.MTLAttribute::get_Name()' has a extraneous [NullAllowed] on return type !incorrect-protocol-member! MTLArgumentEncoder::newArgumentEncoderForBufferAtIndex: is REQUIRED and should be abstract !incorrect-protocol-member! MTLArgumentEncoder::setAccelerationStructure:atIndex: is REQUIRED and should be abstract !incorrect-protocol-member! MTLArgumentEncoder::setComputePipelineState:atIndex: is REQUIRED and should be abstract @@ -123,26 +122,6 @@ !missing-field! MTLDeviceRemovalRequestedNotification not bound !missing-field! MTLDeviceWasAddedNotification not bound !missing-field! MTLDeviceWasRemovedNotification not bound -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_FragmentArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_VertexArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLArrayType::ElementArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLStructMember::ArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructMember Metal.MTLStructType::Lookup(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLArrayType::ElementStructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLStructMember::StructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_ComputeFunction(Metal.IMTLFunction)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_BackFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_FrontFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPassColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_DepthAttachment(Metal.MTLRenderPassDepthAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_StencilAttachment(Metal.MTLRenderPassStencilAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPipelineColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_VertexDescriptor(Metal.MTLVertexDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLSamplerDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLVertexBufferLayoutDescriptorArray::SetObject(Metal.MTLVertexBufferLayoutDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 !missing-pinvoke! MTLCopyAllDevices is not bound !missing-pinvoke! MTLCopyAllDevicesWithObserver is not bound !missing-pinvoke! MTLRemoveDeviceObserver is not bound diff --git a/tests/xtro-sharpie/iOS-Metal.ignore b/tests/xtro-sharpie/iOS-Metal.ignore index 5320b0cdd1..eb6a937ec2 100644 --- a/tests/xtro-sharpie/iOS-Metal.ignore +++ b/tests/xtro-sharpie/iOS-Metal.ignore @@ -97,31 +97,6 @@ !missing-selector! MTLRasterizationRateMapDescriptor::setLabel: not bound !missing-selector! MTLRasterizationRateMapDescriptor::setScreenSize: not bound -# Initial result from new rule extra-null-allowed -!extra-null-allowed! 'System.String Metal.MTLAttribute::get_Name()' has a extraneous [NullAllowed] on return type - -# Initial result from new rule missing-null-allowed -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_FragmentArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_VertexArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLArrayType::ElementArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLStructMember::ArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructMember Metal.MTLStructType::Lookup(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLArrayType::ElementStructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLStructMember::StructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_ComputeFunction(Metal.IMTLFunction)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_BackFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_FrontFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPassColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_DepthAttachment(Metal.MTLRenderPassDepthAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_StencilAttachment(Metal.MTLRenderPassStencilAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPipelineColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_VertexDescriptor(Metal.MTLVertexDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLSamplerDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLVertexBufferLayoutDescriptorArray::SetObject(Metal.MTLVertexBufferLayoutDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 - # new methods added to a protocol, they will be abstract in XAMCORE_4 !incorrect-protocol-member! MTLArgumentEncoder::setAccelerationStructure:atIndex: is REQUIRED and should be abstract !incorrect-protocol-member! MTLArgumentEncoder::setIntersectionFunctionTable:atIndex: is REQUIRED and should be abstract diff --git a/tests/xtro-sharpie/macOS-Metal.ignore b/tests/xtro-sharpie/macOS-Metal.ignore index 9f85ae5099..54f26b6b84 100644 --- a/tests/xtro-sharpie/macOS-Metal.ignore +++ b/tests/xtro-sharpie/macOS-Metal.ignore @@ -94,31 +94,6 @@ !missing-selector! MTLRasterizationRateMapDescriptor::setLabel: not bound !missing-selector! MTLRasterizationRateMapDescriptor::setScreenSize: not bound -# Initial result from new rule extra-null-allowed -!extra-null-allowed! 'System.String Metal.MTLAttribute::get_Name()' has a extraneous [NullAllowed] on return type - -# Initial result from new rule missing-null-allowed -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_FragmentArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_VertexArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLArrayType::ElementArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLStructMember::ArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructMember Metal.MTLStructType::Lookup(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLArrayType::ElementStructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLStructMember::StructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_ComputeFunction(Metal.IMTLFunction)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_BackFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_FrontFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPassColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_DepthAttachment(Metal.MTLRenderPassDepthAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_StencilAttachment(Metal.MTLRenderPassStencilAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPipelineColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_VertexDescriptor(Metal.MTLVertexDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLSamplerDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLVertexBufferLayoutDescriptorArray::SetObject(Metal.MTLVertexBufferLayoutDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 - # new methods added to a protocol, they will be abstract in XAMCORE_4 !incorrect-protocol-member! MTLArgumentEncoder::setAccelerationStructure:atIndex: is REQUIRED and should be abstract !incorrect-protocol-member! MTLArgumentEncoder::setComputePipelineState:atIndex: is REQUIRED and should be abstract diff --git a/tests/xtro-sharpie/tvOS-Metal.ignore b/tests/xtro-sharpie/tvOS-Metal.ignore index 1964cf0d47..b70a448ed7 100644 --- a/tests/xtro-sharpie/tvOS-Metal.ignore +++ b/tests/xtro-sharpie/tvOS-Metal.ignore @@ -46,31 +46,6 @@ !missing-selector! MTLHeapDescriptor::setType: not bound !missing-selector! MTLHeapDescriptor::type not bound -# Initial result from new rule extra-null-allowed -!extra-null-allowed! 'System.String Metal.MTLAttribute::get_Name()' has a extraneous [NullAllowed] on return type - -# Initial result from new rule missing-null-allowed -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_FragmentArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Foundation.NSObject[] Metal.MTLRenderPipelineReflection::get_VertexArguments()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLArrayType::ElementArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLArrayType Metal.MTLStructMember::ArrayType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructMember Metal.MTLStructType::Lookup(System.String)' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLArrayType::ElementStructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'Metal.MTLStructType Metal.MTLStructMember::StructType()' is missing an [NullAllowed] on return type -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_ComputeFunction(Metal.IMTLFunction)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLComputePipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_BackFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_FrontFaceStencil(Metal.MTLStencilDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLDepthStencilDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPassColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_DepthAttachment(Metal.MTLRenderPassDepthAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPassDescriptor::set_StencilAttachment(Metal.MTLRenderPassStencilAttachmentDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineColorAttachmentDescriptorArray::SetObject(Metal.MTLRenderPipelineColorAttachmentDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLRenderPipelineDescriptor::set_VertexDescriptor(Metal.MTLVertexDescriptor)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLSamplerDescriptor::set_Label(System.String)' is missing an [NullAllowed] on parameter #0 -!missing-null-allowed! 'System.Void Metal.MTLVertexBufferLayoutDescriptorArray::SetObject(Metal.MTLVertexBufferLayoutDescriptor,System.nuint)' is missing an [NullAllowed] on parameter #0 - # new methods added to a protocol, they will be abstract in XAMCORE_4 !incorrect-protocol-member! MTLDevice::newBinaryArchiveWithDescriptor:error: is REQUIRED and should be abstract !incorrect-protocol-member! MTLDevice::newDynamicLibrary:error: is REQUIRED and should be abstract