Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Sep 19, 2025

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.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

…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.
@grynspan grynspan added this to the Swift 6.x (main) milestone Sep 19, 2025
@grynspan grynspan self-assigned this Sep 19, 2025
@grynspan grynspan added the windows 🪟 Windows support label Sep 19, 2025
@grynspan grynspan added darwin 🍎 macOS, iOS, watchOS, tvOS, and visionOS support attachments/activities 🖇️ Work related to attachments and/or activities cross-import-overlays 🍰 Cross-import overlays (Foundation, Core Graphics, etc.) tech-debt 💾 reduces technical debt image-attachments 📸 Work related to image attachments labels Sep 19, 2025
@grynspan grynspan merged commit a6d370e into main Sep 22, 2025
47 of 48 checks passed
@grynspan grynspan deleted the jgrynspan/merge-more-cgimage-iwicbitmapsource-code branch September 22, 2025 22:07
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants