-
Notifications
You must be signed in to change notification settings - Fork 121
Merge more of the image attachments codebase duplicated between Darwin and Windows. #1329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grynspan
merged 4 commits into
main
from
jgrynspan/merge-more-cgimage-iwicbitmapsource-code
Sep 22, 2025
Merged
Merge more of the image attachments codebase duplicated between Darwin and Windows. #1329
grynspan
merged 4 commits into
main
from
jgrynspan/merge-more-cgimage-iwicbitmapsource-code
Sep 22, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…n and Windows. This PR eliminates a bunch of duplicated code between Darwin and Windows that's used to support image attachments. We're able to do this because `_AttachableImageWrapper` is now a class and can be included in conforms-to generic constraints, so we can write `where AttachableValue: _AttachableImageWrapper<T> & AttachableWrapper`. It was previously a structure and structures can't be used in generic constraints this way. There's a new public, underscored protocol introduced here, `_AttachableAsImage`, that serves as a "base" protocol for `AttachableAsCGImage` and `AttachableAsIWICBitmapSource`. I intend to promote this protocol to API, but it will need a Swift Evolution proposal first. I'm going to include it in a future "image attachments refinement" proposal that will cover a few other things.
2 tasks
Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift
Show resolved
Hide resolved
Sources/Overlays/_Testing_WinSDK/Attachments/AttachableAsIWICBitmapSource.swift
Show resolved
Hide resolved
jerryjrchen
approved these changes
Sep 22, 2025
Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift
Show resolved
Hide resolved
Sources/Overlays/_Testing_CoreGraphics/Attachments/AttachableAsCGImage.swift
Show resolved
Hide resolved
grynspan
added a commit
that referenced
this pull request
Sep 23, 2025
This PR explicitly marks the image attachments API bits in the core Swift Testing library as unavailable on e.g. Linux. Developers who attempt to use this API on Linux will get diagnostics such as: > 🛑 'AttachableImageFormat' is unavailable: Image attachments are not available on this platform. Blocked on #1329. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
attachments/activities
🖇️ Work related to attachments and/or activities
cross-import-overlays
🍰 Cross-import overlays (Foundation, Core Graphics, etc.)
darwin
🍎 macOS, iOS, watchOS, tvOS, and visionOS support
image-attachments
📸 Work related to image attachments
tech-debt
💾 reduces technical debt
windows
🪟 Windows support
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR eliminates a bunch of duplicated code between Darwin and Windows that's used to support image attachments. We're able to do this because
_AttachableImageWrapper
is now a class and can be included in conforms-to generic constraints, so we can writewhere AttachableValue: _AttachableImageWrapper<T> & AttachableWrapper
. It was previously a structure and structures can't be used in generic constraints this way.There's a new public, underscored protocol introduced here,
_AttachableAsImage
, that serves as a "base" protocol forAttachableAsCGImage
andAttachableAsIWICBitmapSource
. I intend to promote this protocol to API, but it will need a Swift Evolution proposal first. I'm going to include it in a future "image attachments refinement" proposal that will cover a few other things.Checklist: