Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Testing/ABI/Encoded/ABI.EncodedAttachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extension ABI {
path = attachment.fileSystemPath

if V.includesExperimentalFields {
_preferredName = attachment.preferredName
_preferredName = attachment.uncheckedPreferredName

if path == nil {
_bytes = try? attachment.withUnsafeBytes { bytes in
Expand Down
20 changes: 14 additions & 6 deletions Sources/Testing/Attachments/Attachment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ public struct Attachment<AttachableValue> where AttachableValue: Attachable & ~C
/// Storage for ``preferredName``.
fileprivate var _preferredName: String?

/// A filename to use when saving this attachment.
///
/// The value of this property is equal to ``preferredName`` if the test
/// author specified a preferred name when creating the attachment. Otherwise,
/// the value of this property is `nil`.
@_spi(ForToolsIntegrationOnly)
public var uncheckedPreferredName: String? {
if let _preferredName, !_preferredName.isEmpty {
return attachableValue.preferredName(for: self, basedOn: _preferredName)
}
return nil
}

/// A filename to use when saving this attachment.
///
/// The value of this property is used as a hint to the testing library. The
Expand All @@ -88,12 +101,7 @@ public struct Attachment<AttachableValue> where AttachableValue: Attachable & ~C
/// @Available(Xcode, introduced: 26.0)
/// }
public var preferredName: String {
let suggestedName = if let _preferredName, !_preferredName.isEmpty {
_preferredName
} else {
Self.defaultPreferredName
}
return attachableValue.preferredName(for: self, basedOn: suggestedName)
uncheckedPreferredName ?? attachableValue.preferredName(for: self, basedOn: Self.defaultPreferredName)
}

/// The source location of this instance.
Expand Down