Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
matrix:
xcode: ['26.5']
config: ['debug', 'release']
traits: ['', 'CasePaths', 'IdentifiedCollections']
traits: ['', 'CasePaths', 'CustomDump', 'IdentifiedCollections']
runs-on: macos-26
steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +35,7 @@ jobs:
matrix:
swift:
- '6.3'
traits: ['', 'CasePaths']
traits: ['', 'CasePaths', 'CustomDump', 'IdentifiedCollections']
runs-on: ubuntu-latest
container: swift:${{ matrix.swift }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 22 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ let package = Package(
name: "CasePaths",
description: "Derive Shared cases from Shared enums using CasePaths"
),
.trait(
name: "CustomDump",
description: "Pretty-print and diff Sharing's data types using CustomDump"
),
.trait(
name: "IdentifiedCollections",
description: "Derive Shared elements from Shared collections using IdentifiedCollections"
Expand All @@ -44,8 +48,21 @@ let package = Package(
dependencies: [
"Sharing1",
"Sharing2",
.product(
name: "CasePaths",
package: "swift-case-paths",
condition: .when(
traits: ["CasePaths"]
)
),
.product(name: "ConcurrencyExtras", package: "swift-concurrency-extras"),
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(
name: "CustomDump",
package: "swift-custom-dump",
condition: .when(
traits: ["CustomDump"]
)
),
.product(name: "Dependencies", package: "swift-dependencies"),
.product(
name: "IdentifiedCollections",
Expand All @@ -56,13 +73,6 @@ let package = Package(
),
.product(name: "IssueReporting", package: "xctest-dynamic-overlay"),
.product(name: "PerceptionCore", package: "swift-perception"),
.product(
name: "CasePaths",
package: "swift-case-paths",
condition: .when(
traits: ["CasePaths"]
)
),
],
resources: [
.process("PrivacyInfo.xcprivacy")
Expand All @@ -72,15 +82,16 @@ let package = Package(
name: "SharingTests",
dependencies: [
"Sharing",
.product(name: "CombineSchedulers", package: "combine-schedulers"),
.product(name: "DependenciesTestSupport", package: "swift-dependencies"),
.product(
name: "CasePaths",
package: "swift-case-paths",
condition: .when(
traits: ["CasePaths"]
)
),
.product(name: "CombineSchedulers", package: "combine-schedulers"),
.product(name: "CustomDump", package: "swift-custom-dump"),
.product(name: "DependenciesTestSupport", package: "swift-dependencies"),
],
exclude: ["Sharing.xctestplan"]
),
Expand All @@ -103,6 +114,7 @@ package.traits.insert(
enableAllTraits
? package.traits.map(\.name)
: [
"CustomDump",
"IdentifiedCollections",
]
)
Expand Down
1 change: 1 addition & 0 deletions Package@swift-5.9.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ let package = Package(
for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.define("CustomDump"),
.define("IdentifiedCollections"),
])
}
1 change: 1 addition & 0 deletions Package@swift-6.0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let package = Package(
for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.define("CustomDump"),
.define("IdentifiedCollections"),
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ImmutableWeakCaptures"),
Expand Down
20 changes: 0 additions & 20 deletions Sources/Sharing/Shared.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
public import CustomDump
import Dependencies
import Foundation
public import Observation
Expand Down Expand Up @@ -474,25 +473,6 @@ extension Shared: Observable {}

extension Shared: Perceptible {}

extension Shared: CustomDumpRepresentable {
public var customDumpValue: Any {
wrappedValue
}
}

extension Shared: _CustomDiffObject {
public var _customDiffValues: (Any, Any) {
(reference.snapshot ?? reference.wrappedValue, reference.wrappedValue)
}

public var _objectIdentifier: ObjectIdentifier {
func open(_ reference: some MutableReference<Value>) -> ObjectIdentifier {
reference.id
}
return open(reference)
}
}

#if canImport(SwiftUI)
extension Shared: DynamicProperty {
public func update() {
Expand Down
7 changes: 0 additions & 7 deletions Sources/Sharing/SharedReader.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
public import CustomDump
import Foundation
import IssueReporting
public import Observation
Expand Down Expand Up @@ -345,12 +344,6 @@ extension SharedReader: Observable {}

extension SharedReader: Perceptible {}

extension SharedReader: CustomDumpRepresentable {
public var customDumpValue: Any {
wrappedValue
}
}

#if canImport(SwiftUI)
extension SharedReader: DynamicProperty {
public func update() {
Expand Down
28 changes: 28 additions & 0 deletions Sources/Sharing/Traits/CustomDump.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#if CustomDump
public import CustomDump

extension Shared: CustomDumpRepresentable {
public var customDumpValue: Any {
wrappedValue
}
}

extension Shared: _CustomDiffObject {
public var _customDiffValues: (Any, Any) {
(reference.snapshot ?? reference.wrappedValue, reference.wrappedValue)
}

public var _objectIdentifier: ObjectIdentifier {
func open(_ reference: some MutableReference<Value>) -> ObjectIdentifier {
reference.id
}
return open(reference)
}
}

extension SharedReader: CustomDumpRepresentable {
public var customDumpValue: Any {
wrappedValue
}
}
#endif
6 changes: 4 additions & 2 deletions Tests/SharingTests/FileStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
@Shared(.fileStorage(.fileURL)) var users = [User]()
#expect($users.loadError == nil)
expectNoDifference(
fileSystem.value, [.fileURL: Data()]
fileSystem.value,
[.fileURL: Data()]
)
$users.withLock { $0.append(.blob) }
try expectNoDifference(fileSystem.value.users(for: .fileURL), [.blob])
Expand All @@ -34,7 +35,8 @@
@Shared(.utf8String) var string = ""
#expect($string.loadError == nil)
expectNoDifference(
fileSystem.value, [.utf8StringURL: Data()]
fileSystem.value,
[.utf8StringURL: Data()]
)
$string.withLock { $0 = "hello" }
expectNoDifference(
Expand Down
Loading
Loading