From 80f6237f99bbc1576ad41b12d9eba814f20eb007 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 15 Aug 2025 13:51:54 -0400 Subject: [PATCH 01/10] Reduce duplicated code between Darwin's and Windows' image attachments. This PR cleans up the implementations of image attachments on Darwin and Windows so that we have less code duplication between the two. `_AttachableImageWrapper` is partially lowered to the main library (excepting the platform-specific bits) and `ImageAttachmentError` is lowered in its entirety. There are some adjustments to the (internal/package) interface of `_AttachableImageWrapper` to accomodate it not being able to specify conformance to `AttachableAsCGImage` or `AttachableAsIWICBitmapSource`. Namely, whatever code initializes an instance of it is responsible for copying `image` and providing a deinitializer function as needed. --- .../Attachments/AttachableAsCGImage.swift | 2 +- .../Attachment+AttachableAsCGImage.swift | 17 +++-- .../Attachments/ImageAttachmentError.swift | 34 ---------- ...hableImageWrapper+AttachableWrapper.swift} | 48 ++------------ .../AttachableAsIWICBitmapSource.swift | 2 +- ...achment+AttachableAsIWICBitmapSource.swift | 21 ++++--- ...hableImageWrapper+AttachableWrapper.swift} | 41 +----------- .../{ => Images}/AttachableImageFormat.swift | 0 .../Images}/ImageAttachmentError.swift | 42 +++++++++---- .../Images/_AttachableImageWrapper.swift | 63 +++++++++++++++++++ Sources/Testing/CMakeLists.txt | 3 + 11 files changed, 128 insertions(+), 145 deletions(-) delete mode 100644 Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift rename Sources/Overlays/_Testing_CoreGraphics/Attachments/{_AttachableImageWrapper.swift => _AttachableImageWrapper+AttachableWrapper.swift} (66%) rename Sources/Overlays/_Testing_WinSDK/Attachments/{_AttachableImageWrapper.swift => _AttachableImageWrapper+AttachableWrapper.swift} (77%) rename Sources/Testing/Attachments/{ => Images}/AttachableImageFormat.swift (100%) rename Sources/{Overlays/_Testing_WinSDK/Attachments => Testing/Attachments/Images}/ImageAttachmentError.swift (56%) create mode 100644 Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index 8ca2a0ae4..d19d321fc 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -35,7 +35,7 @@ private import ImageIO /// first convert it to an instance of one of the types above. @_spi(Experimental) @available(_uttypesAPI, *) -public protocol AttachableAsCGImage { +public protocol AttachableAsCGImage: SendableMetatype { /// An instance of `CGImage` representing this image. /// /// - Throws: Any error that prevents the creation of an image. diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index 866240e64..6a84b9382 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -48,8 +48,12 @@ extension Attachment { named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation - ) where AttachableValue == _AttachableImageWrapper { - let imageWrapper = _AttachableImageWrapper(image: image, imageFormat: imageFormat) + ) where T: AttachableAsCGImage, AttachableValue == _AttachableImageWrapper { + let imageWrapper = _AttachableImageWrapper( + image: image._copyAttachableValue(), + imageFormat: imageFormat, + deinitializingWith: { _ in } + ) self.init(imageWrapper, named: preferredName, sourceLocation: sourceLocation) } @@ -88,19 +92,20 @@ extension Attachment { named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation - ) where AttachableValue == _AttachableImageWrapper { + ) where T: AttachableAsCGImage, AttachableValue == _AttachableImageWrapper { let attachment = Self(image, named: preferredName, as: imageFormat, sourceLocation: sourceLocation) Self.record(attachment, sourceLocation: sourceLocation) } } +// MARK: - + @_spi(Experimental) // STOP: not part of ST-0014 @available(_uttypesAPI, *) extension Attachment where AttachableValue: AttachableWrapper, AttachableValue.Wrapped: AttachableAsCGImage { /// The image format to use when encoding the represented image. - @_disfavoredOverload - public var imageFormat: AttachableImageFormat? { - // FIXME: no way to express `where AttachableValue == _AttachableImageWrapper` on a property + @_disfavoredOverload public var imageFormat: AttachableImageFormat? { + // FIXME: no way to express `where AttachableValue == _AttachableImageWrapper` on a property (see rdar://47559973) (attachableValue as? _AttachableImageWrapper)?.imageFormat } } diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift deleted file mode 100644 index f957888b7..000000000 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/ImageAttachmentError.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2024 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for Swift project authors -// - -#if SWT_TARGET_OS_APPLE && canImport(CoreGraphics) -/// A type representing an error that can occur when attaching an image. -package enum ImageAttachmentError: Error, CustomStringConvertible { - /// The image could not be converted to an instance of `CGImage`. - case couldNotCreateCGImage - - /// The image destination could not be created. - case couldNotCreateImageDestination - - /// The image could not be converted. - case couldNotConvertImage - - public var description: String { - switch self { - case .couldNotCreateCGImage: - "Could not create the corresponding Core Graphics image." - case .couldNotCreateImageDestination: - "Could not create the Core Graphics image destination to encode this image." - case .couldNotConvertImage: - "Could not convert the image to the specified format." - } - } -} -#endif diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift similarity index 66% rename from Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper.swift rename to Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 61904936f..2ef6e974c 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -38,53 +38,13 @@ import UniformTypeIdentifiers /// (And no, the language does not let us write `where T: Self` anywhere /// useful.) -/// A wrapper type for image types such as `CGImage` and `NSImage` that can be -/// attached indirectly. -/// -/// You do not need to use this type directly. Instead, initialize an instance -/// of ``Attachment`` using an instance of an image type that conforms to -/// ``AttachableAsCGImage``. The following system-provided image types conform -/// to the ``AttachableAsCGImage`` protocol and can be attached to a test: -/// -/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) -/// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) -/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) -/// (macOS) -/// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) -/// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) -@_spi(Experimental) @available(_uttypesAPI, *) -public final class _AttachableImageWrapper: Sendable where Image: AttachableAsCGImage { - /// The underlying image. - /// - /// `CGImage` and `UIImage` are sendable, but `NSImage` is not. `NSImage` - /// instances can be created from closures that are run at rendering time. - /// The AppKit cross-import overlay is responsible for ensuring that any - /// instances of this type it creates hold "safe" `NSImage` instances. - nonisolated(unsafe) let image: Image - - /// The image format to use when encoding the represented image. - let imageFormat: AttachableImageFormat? - - init(image: Image, imageFormat: AttachableImageFormat?) { - self.image = image._copyAttachableValue() - self.imageFormat = imageFormat - } -} - -// MARK: - - -@available(_uttypesAPI, *) -extension _AttachableImageWrapper: AttachableWrapper { - public var wrappedValue: Image { - image - } - +extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsCGImage { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { let data = NSMutableData() // Convert the image to a CGImage. - let attachableCGImage = try image.attachableCGImage + let attachableCGImage = try wrappedValue.attachableCGImage // Create the image destination. let contentType = AttachableImageFormat.computeContentType(for: imageFormat, withPreferredName: attachment.preferredName) @@ -93,8 +53,8 @@ extension _AttachableImageWrapper: AttachableWrapper { } // Configure the properties of the image conversion operation. - let orientation = image._attachmentOrientation - let scaleFactor = image._attachmentScaleFactor + let orientation = wrappedValue._attachmentOrientation + let scaleFactor = wrappedValue._attachmentScaleFactor let properties: [CFString: Any] = [ kCGImageDestinationLossyCompressionQuality: CGFloat(imageFormat?.encodingQuality ?? 1.0), kCGImagePropertyOrientation: orientation, diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index cf23df63a..78c563526 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -112,7 +112,7 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// you have an image in another format that needs to be attached to a test, /// first convert it to an instance of one of the types above. @_spi(Experimental) -public protocol AttachableAsIWICBitmapSource { +public protocol AttachableAsIWICBitmapSource: SendableMetatype { /// Create a WIC bitmap source representing an instance of this type. /// /// - Returns: A pointer to a new WIC bitmap source representing this image. diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index ec0bb016b..49d13e414 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -46,8 +46,12 @@ extension Attachment { named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation - ) where AttachableValue == _AttachableImageWrapper { - let imageWrapper = _AttachableImageWrapper(image: image, imageFormat: imageFormat) + ) where T: AttachableAsIWICBitmapSource, AttachableValue == _AttachableImageWrapper { + let imageWrapper = _AttachableImageWrapper( + image: image._copyAttachableValue(), + imageFormat: imageFormat, + deinitializingWith: { $0._deinitializeAttachableValue() } + ) self.init(imageWrapper, named: preferredName, sourceLocation: sourceLocation) } @@ -86,8 +90,12 @@ extension Attachment { named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation - ) where AttachableValue == _AttachableImageWrapper { - let imageWrapper = _AttachableImageWrapper(image: image, imageFormat: imageFormat) + ) where T: AttachableAsIWICBitmapSource, AttachableValue == _AttachableImageWrapper { + let imageWrapper = _AttachableImageWrapper( + image: image._copyAttachableValue(), + imageFormat: imageFormat, + deinitializingWith: { $0._deinitializeAttachableValue() } + ) let attachment = Self(imageWrapper, named: preferredName, sourceLocation: sourceLocation) Self.record(attachment, sourceLocation: sourceLocation) } @@ -96,9 +104,8 @@ extension Attachment { @_spi(Experimental) extension Attachment where AttachableValue: AttachableWrapper, AttachableValue.Wrapped: AttachableAsIWICBitmapSource { /// The image format to use when encoding the represented image. - @_disfavoredOverload - public var imageFormat: AttachableImageFormat? { - // FIXME: no way to express `where AttachableValue == _AttachableImageWrapper` on a property + @_disfavoredOverload public var imageFormat: AttachableImageFormat? { + // FIXME: no way to express `where AttachableValue == _AttachableImageWrapper` on a property (see rdar://47559973) (attachableValue as? _AttachableImageWrapper)?.imageFormat } } diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift similarity index 77% rename from Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper.swift rename to Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 63931c378..733320ae1 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -13,44 +13,7 @@ internal import WinSDK -/// A wrapper type for image types such as `HBITMAP` and `HICON` that can be -/// attached indirectly. -/// -/// You do not need to use this type directly. Instead, initialize an instance -/// of ``Attachment`` using an instance of an image type that conforms to -/// ``AttachableAsIWICBitmapSource``. The following system-provided image types -/// conform to the ``AttachableAsIWICBitmapSource`` protocol and can be attached -/// to a test: -/// -/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) -/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) -/// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) -/// (including its subclasses declared by Windows Imaging Component) -@_spi(Experimental) -public final class _AttachableImageWrapper: Sendable where Image: AttachableAsIWICBitmapSource { - /// The underlying image. - nonisolated(unsafe) let image: Image - - /// The image format to use when encoding the represented image. - let imageFormat: AttachableImageFormat? - - init(image: borrowing Image, imageFormat: AttachableImageFormat?) { - self.image = image._copyAttachableValue() - self.imageFormat = imageFormat - } - - deinit { - image._deinitializeAttachableValue() - } -} - -// MARK: - - -extension _AttachableImageWrapper: AttachableWrapper { - public var wrappedValue: Image { - image - } - +extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsIWICBitmapSource { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { // Create an in-memory stream to write the image data to. Note that Windows // documentation recommends SHCreateMemStream() instead, but that function @@ -71,7 +34,7 @@ extension _AttachableImageWrapper: AttachableWrapper { } // Create the bitmap and downcast it to an IWICBitmapSource for later use. - let bitmap = try image._copyAttachableIWICBitmapSource(using: factory) + let bitmap = try wrappedValue._copyAttachableIWICBitmapSource(using: factory) defer { _ = bitmap.pointee.lpVtbl.pointee.Release(bitmap) } diff --git a/Sources/Testing/Attachments/AttachableImageFormat.swift b/Sources/Testing/Attachments/Images/AttachableImageFormat.swift similarity index 100% rename from Sources/Testing/Attachments/AttachableImageFormat.swift rename to Sources/Testing/Attachments/Images/AttachableImageFormat.swift diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/ImageAttachmentError.swift b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift similarity index 56% rename from Sources/Overlays/_Testing_WinSDK/Attachments/ImageAttachmentError.swift rename to Sources/Testing/Attachments/Images/ImageAttachmentError.swift index 1b37df4a9..273221fea 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/ImageAttachmentError.swift +++ b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift @@ -1,38 +1,54 @@ // // This source file is part of the Swift.org open source project // -// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Copyright (c) 2024 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // -#if os(Windows) -@_spi(Experimental) import Testing +/// A type representing an error that can occur when attaching an image. +package enum ImageAttachmentError: Error { +#if SWT_TARGET_OS_APPLE + /// The image could not be converted to an instance of `CGImage`. + case couldNotCreateCGImage -internal import WinSDK + /// The image destination could not be created. + case couldNotCreateImageDestination -/// A type representing an error that can occur when attaching an image. -enum ImageAttachmentError: Error { + /// The image could not be converted. + case couldNotConvertImage +#elseif os(Windows) /// A call to `QueryInterface()` failed. - case queryInterfaceFailed(Any.Type, HRESULT) + case queryInterfaceFailed(Any.Type, Int32) /// The testing library failed to create a COM object. - case comObjectCreationFailed(Any.Type, HRESULT) + case comObjectCreationFailed(Any.Type, Int32) /// An image could not be written. - case imageWritingFailed(HRESULT) + case imageWritingFailed(Int32) /// The testing library failed to get an in-memory stream's underlying buffer. - case globalFromStreamFailed(HRESULT) + case globalFromStreamFailed(Int32) /// A property could not be written to a property bag. - case propertyBagWritingFailed(String, HRESULT) + case propertyBagWritingFailed(String, Int32) +#endif } extension ImageAttachmentError: CustomStringConvertible { - var description: String { + package var description: String { +#if SWT_TARGET_OS_APPLE + switch self { + case .couldNotCreateCGImage: + "Could not create the corresponding Core Graphics image." + case .couldNotCreateImageDestination: + "Could not create the Core Graphics image destination to encode this image." + case .couldNotConvertImage: + "Could not convert the image to the specified format." + } +#elseif os(Windows) switch self { case let .queryInterfaceFailed(type, result): "Could not cast a COM object to type '\(type)' (HRESULT \(result))." @@ -45,6 +61,6 @@ extension ImageAttachmentError: CustomStringConvertible { case let .propertyBagWritingFailed(name, result): "Could not set the property '\(name)' (HRESULT \(result))." } +#endif } } -#endif diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift new file mode 100644 index 000000000..fe036efad --- /dev/null +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -0,0 +1,63 @@ +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for Swift project authors +// + +/// A wrapper type for images that can be indirectly attached to a test. +/// +/// You do not need to use this type directly. Instead, initialize an instance +/// of ``Attachment`` using an instance of an image type that conforms to +/// ``AttachableAsCGImage`` (on Apple platforms) or +/// ``AttachableAsIWICBitmapSource`` (on Windows). +/// +/// On Apple platforms, the following system-provided image types conform +/// to the ``AttachableAsCGImage`` protocol and can be attached to a test: +/// +/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) +/// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) +/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) +/// (macOS) +/// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) +/// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) +/// +/// On Windows, the following system-provided image types conform to the +/// ``AttachableAsIWICBitmapSource`` protocol and can be attached to a test: +/// +/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) +/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) +/// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) +/// (including its subclasses declared by Windows Imaging Component) +@_spi(Experimental) +@available(_uttypesAPI, *) +public final class _AttachableImageWrapper: Sendable { + /// The underlying image. + private nonisolated(unsafe) let _image: Image + + /// The image format to use when encoding the represented image. + package let imageFormat: AttachableImageFormat? + + /// A deinitializer function to call to clean up `image`. + private let _deinit: @Sendable (consuming Image) -> Void + + package init(image: Image, imageFormat: AttachableImageFormat?, deinitializingWith `deinit`: @escaping @Sendable (consuming Image) -> Void) { + self._image = image + self.imageFormat = imageFormat + self._deinit = `deinit` + } + + deinit { + _deinit(_image) + } +} + +@available(_uttypesAPI, *) +extension _AttachableImageWrapper { + public var wrappedValue: Image { + _image + } +} diff --git a/Sources/Testing/CMakeLists.txt b/Sources/Testing/CMakeLists.txt index 36437e167..531d27cfc 100644 --- a/Sources/Testing/CMakeLists.txt +++ b/Sources/Testing/CMakeLists.txt @@ -21,6 +21,9 @@ add_library(Testing ABI/Encoded/ABI.EncodedIssue.swift ABI/Encoded/ABI.EncodedMessage.swift ABI/Encoded/ABI.EncodedTest.swift + Attachments/Images/_AttachableImageWrapper.swift + Attachments/Images/AttachableImageFormat.swift + Attachments/Images/ImageAttachmentError.swift Attachments/Attachable.swift Attachments/AttachableWrapper.swift Attachments/Attachment.swift From 08dd994716f945b459cde10b5e066d77eeb3a768 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 15 Aug 2025 14:02:28 -0400 Subject: [PATCH 02/10] Teach Swift about an unreachable code path --- Sources/Testing/Attachments/Images/ImageAttachmentError.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift index 273221fea..7cd6f8180 100644 --- a/Sources/Testing/Attachments/Images/ImageAttachmentError.swift +++ b/Sources/Testing/Attachments/Images/ImageAttachmentError.swift @@ -8,6 +8,8 @@ // See https://swift.org/CONTRIBUTORS.txt for Swift project authors // +private import _TestingInternals + /// A type representing an error that can occur when attaching an image. package enum ImageAttachmentError: Error { #if SWT_TARGET_OS_APPLE @@ -61,6 +63,8 @@ extension ImageAttachmentError: CustomStringConvertible { case let .propertyBagWritingFailed(name, result): "Could not set the property '\(name)' (HRESULT \(result))." } +#else + swt_unreachable() #endif } } From 3aa81daf0e2edabf2e1288fee69395d9f2bdf4a1 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 15 Aug 2025 14:22:28 -0400 Subject: [PATCH 03/10] Adjust import visibility --- .../_AttachableImageWrapper+AttachableWrapper.swift | 2 +- .../Attachments/AttachableAsIWICBitmapSource.swift | 3 +-- .../Attachments/AttachableImageFormat+CLSID.swift | 3 +-- .../Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift | 3 +-- .../Attachments/HICON+AttachableAsIWICBitmapSource.swift | 3 +-- .../IWICBitmapSource+AttachableAsIWICBitmapSource.swift | 3 +-- .../UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift | 3 +-- .../_AttachableImageWrapper+AttachableWrapper.swift | 3 +-- 8 files changed, 8 insertions(+), 15 deletions(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 2ef6e974c..bb0d42b23 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -13,7 +13,7 @@ private import CoreGraphics private import ImageIO -import UniformTypeIdentifiers +private import UniformTypeIdentifiers /// ## Why can't images directly conform to Attachable? /// diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index 78c563526..43b593022 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -9,8 +9,7 @@ // #if os(Windows) -@_spi(Experimental) import Testing - +private import Testing public import WinSDK /// A protocol describing images that can be converted to instances of diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index 009015e13..d0e72ffa9 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -9,8 +9,7 @@ // #if os(Windows) -@_spi(Experimental) import Testing - +@_spi(Experimental) public import Testing public import WinSDK extension AttachableImageFormat { diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift index 0d11fd0bc..4baef8d36 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/HBITMAP+AttachableAsIWICBitmapSource.swift @@ -9,8 +9,7 @@ // #if os(Windows) -import Testing - +private import Testing public import WinSDK @_spi(Experimental) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/HICON+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/HICON+AttachableAsIWICBitmapSource.swift index a25e8f371..36f4fcc9e 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/HICON+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/HICON+AttachableAsIWICBitmapSource.swift @@ -9,8 +9,7 @@ // #if os(Windows) -import Testing - +private import Testing public import WinSDK @_spi(Experimental) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift index 401e6f480..8ff6d5430 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/IWICBitmapSource+AttachableAsIWICBitmapSource.swift @@ -9,8 +9,7 @@ // #if os(Windows) -import Testing - +private import Testing public import WinSDK /// - Important: The casts in this file to `IUnknown` are safe insofar as we use diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift index 6d34a6e90..297e1f25a 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/UnsafeMutablePointer+AttachableAsIWICBitmapSource.swift @@ -9,8 +9,7 @@ // #if os(Windows) -import Testing - +private import Testing public import WinSDK @_spi(Experimental) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 733320ae1..7cfe181b8 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -10,8 +10,7 @@ #if os(Windows) @_spi(Experimental) public import Testing - -internal import WinSDK +private import WinSDK extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsIWICBitmapSource { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { From ebd6b9f219b9bd2856d0576d21f3c9b353232238 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Fri, 15 Aug 2025 16:28:12 -0400 Subject: [PATCH 04/10] D.R.Y. --- .../Attachment+AttachableAsIWICBitmapSource.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index 49d13e414..b3acd1520 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -91,12 +91,7 @@ extension Attachment { as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation ) where T: AttachableAsIWICBitmapSource, AttachableValue == _AttachableImageWrapper { - let imageWrapper = _AttachableImageWrapper( - image: image._copyAttachableValue(), - imageFormat: imageFormat, - deinitializingWith: { $0._deinitializeAttachableValue() } - ) - let attachment = Self(imageWrapper, named: preferredName, sourceLocation: sourceLocation) + let attachment = Self(image, named: preferredName, as: imageFormat, sourceLocation: sourceLocation) Self.record(attachment, sourceLocation: sourceLocation) } } From c1d7cd5a5b6b329ca06bc76234c177c9ea4bcf70 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 13:03:27 -0400 Subject: [PATCH 05/10] Unify platform-specific comments (as much as possible) so that documentation shows both even if the WinSDK module isn't being built --- .../Attachments/AttachableAsCGImage.swift | 12 +++------ .../Attachment+AttachableAsCGImage.swift | 26 ++++++------------- .../AttachableAsIWICBitmapSource.swift | 20 ++++++-------- ...achment+AttachableAsIWICBitmapSource.swift | 22 ++++++---------- ...chableImageWrapper+AttachableWrapper.swift | 2 +- .../Images/_AttachableImageWrapper.swift | 25 +++--------------- 6 files changed, 33 insertions(+), 74 deletions(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index d19d321fc..2c3a5aa7e 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -20,15 +20,11 @@ private import ImageIO /// initializers on ``Testing/Attachment`` that take instances of such types and /// handle converting them to image data when needed. /// -/// The following system-provided image types conform to this protocol and can -/// be attached to a test: +/// You can attach instances of the following system-provided image types to a +/// test: /// -/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) -/// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) -/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) -/// (macOS) -/// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) -/// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) +/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index 6a84b9382..21b3bb282 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -26,15 +26,11 @@ extension Attachment { /// This value is used when recording issues associated with the /// attachment. /// - /// The following system-provided image types conform to the - /// ``AttachableAsCGImage`` protocol and can be attached to a test: + /// You can attach instances of the following system-provided image types to a + /// test: /// - /// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) - /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) - /// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) - /// (macOS) - /// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) - /// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) + /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -68,17 +64,11 @@ extension Attachment { /// - sourceLocation: The source location of the call to this function. /// /// This function creates a new instance of ``Attachment`` wrapping `image` - /// and immediately attaches it to the current test. + /// and immediately attaches it to the current test. You can attach instances + /// of the following system-provided image types to a test: /// - /// The following system-provided image types conform to the - /// ``AttachableAsCGImage`` protocol and can be attached to a test: - /// - /// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) - /// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) - /// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) - /// (macOS) - /// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) - /// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) + /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index 43b593022..f461e506e 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -20,13 +20,11 @@ public import WinSDK /// initializers on ``Testing/Attachment`` that take instances of such types and /// handle converting them to image data when needed. /// -/// The following system-provided image types conform to this protocol and can -/// be attached to a test: +/// You can attach instances of the following system-provided image types to a +/// test: /// -/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) -/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) -/// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) -/// (including its subclasses declared by Windows Imaging Component) +/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, @@ -99,13 +97,11 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// initializers on ``Testing/Attachment`` that take instances of such types and /// handle converting them to image data when needed. /// -/// The following system-provided image types conform to this protocol and can -/// be attached to a test: +/// You can attach instances of the following system-provided image types to a +/// test: /// -/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) -/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) -/// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) -/// (including its subclasses declared by Windows Imaging Component) +/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If /// you have an image in another format that needs to be attached to a test, diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index b3acd1520..1591acca5 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -26,13 +26,11 @@ extension Attachment { /// This value is used when recording issues associated with the /// attachment. /// - /// The following system-provided image types conform to the - /// ``AttachableAsIWICBitmapSource`` protocol and can be attached to a test: + /// You can attach instances of the following system-provided image types to a + /// test: /// - /// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) - /// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) - /// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) - /// (including its subclasses declared by Windows Imaging Component) + /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you @@ -68,15 +66,11 @@ extension Attachment { /// attachment. /// /// This function creates a new instance of ``Attachment`` wrapping `image` - /// and immediately attaches it to the current test. + /// and immediately attaches it to the current test. You can attach instances + /// of the following system-provided image types to a test: /// - /// The following system-provided image types conform to the - /// ``AttachableAsIWICBitmapSource`` protocol and can be attached to a test: - /// - /// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) - /// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) - /// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) - /// (including its subclasses declared by Windows Imaging Component) + /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass /// `nil` to let the testing library decide which image format to use. If you diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 7cfe181b8..32ab51b86 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -12,7 +12,7 @@ @_spi(Experimental) public import Testing private import WinSDK -extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsIWICBitmapSource { +extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsCGImage { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { // Create an in-memory stream to write the image data to. Note that Windows // documentation recommends SHCreateMemStream() instead, but that function diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift index fe036efad..a922bdddc 100644 --- a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -10,28 +10,11 @@ /// A wrapper type for images that can be indirectly attached to a test. /// -/// You do not need to use this type directly. Instead, initialize an instance -/// of ``Attachment`` using an instance of an image type that conforms to -/// ``AttachableAsCGImage`` (on Apple platforms) or -/// ``AttachableAsIWICBitmapSource`` (on Windows). +/// You can attach instances of the following system-provided image types to a +/// test: /// -/// On Apple platforms, the following system-provided image types conform -/// to the ``AttachableAsCGImage`` protocol and can be attached to a test: -/// -/// - [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage) -/// - [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage) -/// - [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) -/// (macOS) -/// - [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) -/// (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) -/// -/// On Windows, the following system-provided image types conform to the -/// ``AttachableAsIWICBitmapSource`` protocol and can be attached to a test: -/// -/// - [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps) -/// - [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons) -/// - [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) -/// (including its subclasses declared by Windows Imaging Component) +/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | @_spi(Experimental) @available(_uttypesAPI, *) public final class _AttachableImageWrapper: Sendable { From a260a3780e0fe1230b45a3b35e8ac2ee131e7b47 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 13:17:49 -0400 Subject: [PATCH 06/10] Fix typo --- .../Attachments/_AttachableImageWrapper+AttachableWrapper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift index 32ab51b86..7cfe181b8 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/_AttachableImageWrapper+AttachableWrapper.swift @@ -12,7 +12,7 @@ @_spi(Experimental) public import Testing private import WinSDK -extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsCGImage { +extension _AttachableImageWrapper: Attachable, AttachableWrapper where Image: AttachableAsIWICBitmapSource { public func withUnsafeBytes(for attachment: borrowing Attachment<_AttachableImageWrapper>, _ body: (UnsafeRawBufferPointer) throws -> R) throws -> R { // Create an in-memory stream to write the image data to. Note that Windows // documentation recommends SHCreateMemStream() instead, but that function From 19f3f06edb66e200f627f5b4dc78216f0244556e Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 13:59:08 -0400 Subject: [PATCH 07/10] Fix table headers --- .../Attachments/AttachableAsCGImage.swift | 2 ++ .../Attachments/Attachment+AttachableAsCGImage.swift | 4 ++++ .../Attachments/AttachableAsIWICBitmapSource.swift | 4 ++++ .../Attachments/Attachment+AttachableAsIWICBitmapSource.swift | 4 ++++ .../Testing/Attachments/Images/_AttachableImageWrapper.swift | 2 ++ 5 files changed, 16 insertions(+) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index 2c3a5aa7e..61b184fe7 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -23,6 +23,8 @@ private import ImageIO /// You can attach instances of the following system-provided image types to a /// test: /// +/// | Platform | Conforming Types | +/// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index 21b3bb282..d6eba1e3f 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -29,6 +29,8 @@ extension Attachment { /// You can attach instances of the following system-provided image types to a /// test: /// + /// | Platform | Conforming Types | + /// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// @@ -67,6 +69,8 @@ extension Attachment { /// and immediately attaches it to the current test. You can attach instances /// of the following system-provided image types to a test: /// + /// | Platform | Conforming Types | + /// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index f461e506e..034963ff4 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -23,6 +23,8 @@ public import WinSDK /// You can attach instances of the following system-provided image types to a /// test: /// +/// | Platform | Conforming Types | +/// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// @@ -100,6 +102,8 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// You can attach instances of the following system-provided image types to a /// test: /// +/// | Platform | Conforming Types | +/// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index 1591acca5..2cd245c18 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -29,6 +29,8 @@ extension Attachment { /// You can attach instances of the following system-provided image types to a /// test: /// + /// | Platform | Conforming Types | + /// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// @@ -69,6 +71,8 @@ extension Attachment { /// and immediately attaches it to the current test. You can attach instances /// of the following system-provided image types to a test: /// + /// | Platform | Conforming Types | + /// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift index a922bdddc..d65537143 100644 --- a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -13,6 +13,8 @@ /// You can attach instances of the following system-provided image types to a /// test: /// +/// | Platform | Conforming Types | +/// |-|-| /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | @_spi(Experimental) From 97fc51dcae2dc833a2ace0ca4f8bfcfcda30f0c9 Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 14:04:37 -0400 Subject: [PATCH 08/10] Adjustments to the supported types table --- .../Attachments/AttachableAsCGImage.swift | 5 +++-- .../Attachments/Attachment+AttachableAsCGImage.swift | 10 ++++++---- .../Attachments/AttachableAsIWICBitmapSource.swift | 10 ++++++---- .../Attachment+AttachableAsIWICBitmapSource.swift | 10 ++++++---- .../Attachments/Images/_AttachableImageWrapper.swift | 5 +++-- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift index 61b184fe7..e51742dc3 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift @@ -23,9 +23,10 @@ private import ImageIO /// You can attach instances of the following system-provided image types to a /// test: /// -/// | Platform | Conforming Types | +/// | Platform | Supported Types | /// |-|-| -/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | +/// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If diff --git a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift index d6eba1e3f..b3349915b 100644 --- a/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift +++ b/Sources/Overlays/_Testing_CoreGraphics/Attachments/Attachment+AttachableAsCGImage.swift @@ -29,9 +29,10 @@ extension Attachment { /// You can attach instances of the following system-provided image types to a /// test: /// - /// | Platform | Conforming Types | + /// | Platform | Supported Types | /// |-|-| - /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | + /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass @@ -69,9 +70,10 @@ extension Attachment { /// and immediately attaches it to the current test. You can attach instances /// of the following system-provided image types to a test: /// - /// | Platform | Conforming Types | + /// | Platform | Supported Types | /// |-|-| - /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | + /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index 034963ff4..87181d1a1 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -23,9 +23,10 @@ public import WinSDK /// You can attach instances of the following system-provided image types to a /// test: /// -/// | Platform | Conforming Types | +/// | Platform | Supported Types | /// |-|-| -/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | +/// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If @@ -102,9 +103,10 @@ public protocol _AttachableByAddressAsIWICBitmapSource { /// You can attach instances of the following system-provided image types to a /// test: /// -/// | Platform | Conforming Types | +/// | Platform | Supported Types | /// |-|-| -/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | +/// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// You do not generally need to add your own conformances to this protocol. If diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift index 2cd245c18..8068e7a8e 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/Attachment+AttachableAsIWICBitmapSource.swift @@ -29,9 +29,10 @@ extension Attachment { /// You can attach instances of the following system-provided image types to a /// test: /// - /// | Platform | Conforming Types | + /// | Platform | Supported Types | /// |-|-| - /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | + /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass @@ -71,9 +72,10 @@ extension Attachment { /// and immediately attaches it to the current test. You can attach instances /// of the following system-provided image types to a test: /// - /// | Platform | Conforming Types | + /// | Platform | Supported Types | /// |-|-| - /// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | + /// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | + /// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | /// /// The testing library uses the image format specified by `imageFormat`. Pass diff --git a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift index d65537143..71623538a 100644 --- a/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift +++ b/Sources/Testing/Attachments/Images/_AttachableImageWrapper.swift @@ -13,9 +13,10 @@ /// You can attach instances of the following system-provided image types to a /// test: /// -/// | Platform | Conforming Types | +/// | Platform | Supported Types | /// |-|-| -/// | Apple platforms | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) (macOS), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) (iOS, watchOS, tvOS, visionOS, and Mac Catalyst) | +/// | macOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`NSImage`](https://developer.apple.com/documentation/appkit/nsimage) | +/// | iOS, watchOS, tvOS, and visionOS | [`CGImage`](https://developer.apple.com/documentation/coregraphics/cgimage), [`CIImage`](https://developer.apple.com/documentation/coreimage/ciimage), [`UIImage`](https://developer.apple.com/documentation/uikit/uiimage) | /// | Windows | [`HBITMAP`](https://learn.microsoft.com/en-us/windows/win32/gdi/bitmaps), [`HICON`](https://learn.microsoft.com/en-us/windows/win32/menurc/icons), [`IWICBitmapSource`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapsource) (including its subclasses declared by Windows Imaging Component) | @_spi(Experimental) @available(_uttypesAPI, *) From a406ce4ef5db13c619ee6b6507d5cd1b5ef4b4dd Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 14:23:18 -0400 Subject: [PATCH 09/10] Fix some broken links when building DocC from a package --- .../Attachments/AttachableAsIWICBitmapSource.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift index 87181d1a1..fdcad1809 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift @@ -93,12 +93,12 @@ public protocol _AttachableByAddressAsIWICBitmapSource { } /// A protocol describing images that can be converted to instances of -/// ``Testing/Attachment``. +/// [`Attachment`](https://developer.apple.com/documentation/testing/attachment). /// /// Instances of types conforming to this protocol do not themselves conform to -/// ``Testing/Attachable``. Instead, the testing library provides additional -/// initializers on ``Testing/Attachment`` that take instances of such types and -/// handle converting them to image data when needed. +/// [`Attachable`](https://developer.apple.com/documentation/testing/attachable). +/// Instead, the testing library provides additional initializers on [`Attachment`](https://developer.apple.com/documentation/testing/attachment) +/// that take instances of such types and handle converting them to image data when needed. /// /// You can attach instances of the following system-provided image types to a /// test: From 7c1f88d756e320eb5e67a4ae2162feb98744086d Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Mon, 18 Aug 2025 14:26:31 -0400 Subject: [PATCH 10/10] Fix backtick typo --- .../Attachments/AttachableImageFormat+CLSID.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift index d0e72ffa9..1881fa036 100644 --- a/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift +++ b/Sources/Overlays/_Testing_WinSDK/Attachments/AttachableImageFormat+CLSID.swift @@ -257,7 +257,7 @@ extension AttachableImageFormat { /// /// If `clsid` does not represent an image encoder type supported by WIC, the /// result is undefined. For a list of image encoders supported by WIC, see - /// the documentation for the [IWICBitmapEncoder](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapencoder) + /// the documentation for the [`IWICBitmapEncoder`](https://learn.microsoft.com/en-us/windows/win32/api/wincodec/nn-wincodec-iwicbitmapencoder) /// class. public init(_ clsid: CLSID, encodingQuality: Float = 1.0) { self.init(kind: .systemValue(clsid), encodingQuality: encodingQuality)