Mark things as nonisolated and Sendable.

This commit is contained in:
Brent Simmons committed 2025-11-16 21:05:05 -08:00
1 parent 0205acda9f
commit be73e8a469
25 files changed
+75 -103

No files matched your search

+6 -1
View File
@@ -37,7 +37,12 @@ let package = Package(
"Secrets",
"SyncDatabase",
],
swiftSettings: [.swiftLanguageMode(.v5)]),
swiftSettings: [
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
.enableUpcomingFeature("InferIsolatedConformances"),
.defaultIsolation(MainActor.self)
]
),
.testTarget(
name: "AccountTests",
dependencies: ["Account"],
@@ -26,7 +26,7 @@ final class CloudKitArticlesZone: CloudKitZone {
let compressionQueue = DispatchQueue(label: "Articles Zone Compression Queue")
struct CloudKitArticle {
nonisolated struct CloudKitArticle: Sendable {
static let recordType = "Article"
struct Fields {
static let articleStatus = "articleStatus"
@@ -47,7 +47,7 @@ final class CloudKitArticlesZone: CloudKitZone {
}
}
struct CloudKitArticleStatus {
nonisolated struct CloudKitArticleStatus: Sendable {
static let recordType = "ArticleStatus"
struct Fields {
static let feedExternalID = "webFeedExternalID"
@@ -223,7 +223,7 @@ private extension CloudKitArticlesZone {
return record
}
func compressArticleRecords(_ records: [CKRecord]) -> [CKRecord] {
nonisolated func compressArticleRecords(_ records: [CKRecord]) -> [CKRecord] {
var result = [CKRecord]()
for record in records {
@@ -10,8 +10,7 @@ import Foundation
import RSParser
import RSCore
final class FeedbinEntry: Decodable {
nonisolated final class FeedbinEntry: Decodable, Sendable {
let articleID: Int
let feedID: Int
let title: String?
@@ -27,14 +26,12 @@ final class FeedbinEntry: Decodable {
// requires a very specific date formatter to work and even then it fails occasionally.
// Rather than loose all the entries we only lose the one date by decoding as a string
// and letting the one date fail when parsed.
lazy var parsedDatePublished: Date? = {
if let datePublished = datePublished {
var parsedDatePublished: Date? {
if let datePublished {
return RSDateWithString(datePublished)
}
else {
return nil
}
}()
return nil
}
enum CodingKeys: String, CodingKey {
case articleID = "id"
@@ -50,7 +47,7 @@ final class FeedbinEntry: Decodable {
}
}
struct FeedbinEntryJSONFeed: Decodable {
nonisolated struct FeedbinEntryJSONFeed: Decodable, Sendable {
let jsonFeedAuthor: FeedbinEntryJSONFeedAuthor?
let jsonFeedExternalURL: String?
@@ -72,12 +69,12 @@ struct FeedbinEntryJSONFeed: Decodable {
jsonFeedExternalURL = nil
}
}
}
struct FeedbinEntryJSONFeedAuthor: Decodable {
nonisolated struct FeedbinEntryJSONFeedAuthor: Decodable, Sendable {
let url: String?
let avatarURL: String?
enum CodingKeys: String, CodingKey {
case url = "url"
case avatarURL = "avatar"
@@ -8,8 +8,7 @@
import Foundation
struct FeedbinImportResult: Codable {
nonisolated struct FeedbinImportResult: Codable, Sendable {
let importResultID: Int
let complete: Bool
@@ -8,12 +8,10 @@
import Foundation
struct FeedbinStarredEntry: Codable {
nonisolated struct FeedbinStarredEntry: Codable, Sendable {
let starredEntries: [Int]
enum CodingKeys: String, CodingKey {
case starredEntries = "starred_entries"
}
}
@@ -10,8 +10,7 @@ import Foundation
import RSCore
import RSParser
struct FeedbinSubscription: Hashable, Codable {
nonisolated struct FeedbinSubscription: Hashable, Codable, Sendable {
let subscriptionID: Int
let feedID: Int
let name: String?
@@ -35,10 +34,9 @@ struct FeedbinSubscription: Hashable, Codable {
static func == (lhs: FeedbinSubscription, rhs: FeedbinSubscription) -> Bool {
return lhs.subscriptionID == rhs.subscriptionID
}
}
struct FeedbinSubscriptionJSONFeed: Codable {
nonisolated struct FeedbinSubscriptionJSONFeed: Codable, Sendable {
let favicon: String?
let icon: String?
enum CodingKeys: String, CodingKey {
@@ -47,22 +45,21 @@ struct FeedbinSubscriptionJSONFeed: Codable {
}
}
struct FeedbinCreateSubscription: Codable {
nonisolated struct FeedbinCreateSubscription: Codable, Sendable {
let feedURL: String
enum CodingKeys: String, CodingKey {
case feedURL = "feed_url"
}
}
struct FeedbinUpdateSubscription: Codable {
nonisolated struct FeedbinUpdateSubscription: Codable, Sendable {
let title: String
enum CodingKeys: String, CodingKey {
case title
}
}
struct FeedbinSubscriptionChoice: Codable {
nonisolated struct FeedbinSubscriptionChoice: Codable, Sendable {
let name: String?
let url: String
@@ -70,5 +67,4 @@ struct FeedbinSubscriptionChoice: Codable {
case name = "title"
case url = "feed_url"
}
}
@@ -8,8 +8,7 @@
import Foundation
struct FeedbinTag: Codable {
nonisolated struct FeedbinTag: Codable, Sendable {
let tagID: Int
let name: String
@@ -17,11 +16,9 @@ struct FeedbinTag: Codable {
case tagID = "id"
case name = "name"
}
}
struct FeedbinRenameTag: Codable {
nonisolated struct FeedbinRenameTag: Codable, Sendable {
let oldName: String
let newName: String
@@ -29,15 +26,12 @@ struct FeedbinRenameTag: Codable {
case oldName = "old_name"
case newName = "new_name"
}
}
struct FeedbinDeleteTag: Codable {
nonisolated struct FeedbinDeleteTag: Codable, Sendable {
let name: String
enum CodingKeys: String, CodingKey {
case name
}
}
@@ -8,8 +8,7 @@
import Foundation
struct FeedbinTagging: Codable {
nonisolated struct FeedbinTagging: Codable, Sendable {
let taggingID: Int
let feedID: Int
let name: String
@@ -19,11 +18,9 @@ struct FeedbinTagging: Codable {
case feedID = "feed_id"
case name = "name"
}
}
struct FeedbinCreateTagging: Codable {
nonisolated struct FeedbinCreateTagging: Codable, Sendable {
let feedID: Int
let name: String
@@ -31,5 +28,4 @@ struct FeedbinCreateTagging: Codable {
case feedID = "feed_id"
case name = "name"
}
}
@@ -8,12 +8,10 @@
import Foundation
struct FeedbinUnreadEntry: Codable {
nonisolated struct FeedbinUnreadEntry: Codable, Sendable {
let unreadEntries: [Int]
enum CodingKeys: String, CodingKey {
case unreadEntries = "unread_entries"
}
}
@@ -8,8 +8,7 @@
import Foundation
import os.log
struct Feedly {
nonisolated struct Feedly: Sendable {
// Convention with this logger is to put "Feedly: " at the beginning of each message.
static let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Feedly")
}
@@ -24,7 +24,7 @@ public enum OAuthAccountAuthorizationOperationError: LocalizedError {
}
@objc final class PresentationAnchorProvider: NSObject, ASWebAuthenticationPresentationContextProviding {
var presentationAnchor: ASPresentationAnchor?
nonisolated(unsafe) var presentationAnchor: ASPresentationAnchor?
// MARK: - ASWebAuthenticationPresentationContextProviding
@@ -36,7 +36,7 @@ public enum OAuthAccountAuthorizationOperationError: LocalizedError {
}
}
public final class OAuthAccountAuthorizationOperation: MainThreadOperation, @unchecked Sendable {
@MainActor public final class OAuthAccountAuthorizationOperation: MainThreadOperation, @unchecked Sendable {
public var presentationAnchor: ASPresentationAnchor? {
get {
anchorProvider.presentationAnchor
@@ -57,7 +57,7 @@ public final class OAuthAccountAuthorizationOperation: MainThreadOperation, @unc
@MainActor public init(accountType: AccountType) {
self.accountType = accountType
self.oauthClient = Account.oauthAuthorizationClient(for: accountType)
super.init()
super.init(name: "OAuthAccountAuthorizationOperation")
}
@MainActor public override func run() {
@@ -25,7 +25,7 @@ final class FeedlyGetCollectionsOperation: FeedlyOperation, FeedlyCollectionProv
super.init()
}
override func run() {
@MainActor override func run() {
Feedly.logger.info("Feedly: Requesting collections")
service.getCollections { result in
@@ -54,7 +54,7 @@ final class FeedlyGetEntriesOperation: FeedlyOperation, FeedlyEntryProviding, Fe
return name ?? String(describing: Self.self)
}
override func run() {
@MainActor override func run() {
service.getEntries(for: provider.entryIDs) { result in
Task { @MainActor in
switch result {
@@ -96,7 +96,7 @@ final class FeedlyGetStreamContentsOperation: FeedlyOperation, FeedlyEntryProvid
self.init(account: account, resource: resourceProvider.resource, service: service, newerThan: newerThan, unreadOnly: unreadOnly)
}
override func run() {
@MainActor override func run() {
service.getStreamContents(for: resourceProvider.resource, continuation: continuation, newerThan: newerThan, unreadOnly: unreadOnly) { result in
Task { @MainActor in
switch result {
@@ -12,7 +12,7 @@ import RSParser
typealias NewsBlurFolder = NewsBlurFeedsResponse.Folder
struct NewsBlurFeed: Hashable, Codable {
nonisolated struct NewsBlurFeed: Hashable, Codable, Sendable {
let name: String
let feedID: Int
let feedURL: String
@@ -20,21 +20,21 @@ struct NewsBlurFeed: Hashable, Codable {
let faviconURL: String?
}
struct NewsBlurFeedsResponse: Decodable {
nonisolated struct NewsBlurFeedsResponse: Decodable, Sendable {
let feeds: [NewsBlurFeed]
let folders: [Folder]
struct Folder: Hashable, Codable {
nonisolated struct Folder: Hashable, Codable, Sendable {
let name: String
let feedIDs: [Int]
}
}
struct NewsBlurAddURLResponse: Decodable {
nonisolated struct NewsBlurAddURLResponse: Decodable, Sendable {
let feed: NewsBlurFeed?
}
struct NewsBlurFolderRelationship {
nonisolated struct NewsBlurFolderRelationship: Sendable {
let folderName: String
let feedID: Int
}
@@ -49,7 +49,7 @@ extension NewsBlurFeed {
}
}
extension NewsBlurFeedsResponse {
nonisolated extension NewsBlurFeedsResponse {
private enum CodingKeys: String, CodingKey {
case feeds = "feeds"
case folders = "flat_folders"
@@ -8,13 +8,13 @@
import Foundation
struct NewsBlurLoginResponse: Decodable {
var code: Int
var errors: LoginError?
nonisolated struct NewsBlurLoginResponse: Decodable, Sendable {
let code: Int
let errors: LoginError?
struct LoginError: Decodable {
var username: [String]?
var others: [String]?
nonisolated struct LoginError: Decodable, Sendable {
let username: [String]?
let others: [String]?
}
}
@@ -12,7 +12,7 @@ import RSParser
typealias NewsBlurStory = NewsBlurStoriesResponse.Story
struct NewsBlurStoriesResponse: Decodable {
nonisolated struct NewsBlurStoriesResponse: Decodable, Sendable {
let stories: [Story]
struct Story: Decodable {
@@ -12,19 +12,19 @@ import RSParser
typealias NewsBlurStoryHash = NewsBlurStoryHashesResponse.StoryHash
struct NewsBlurStoryHashesResponse: Decodable {
nonisolated struct NewsBlurStoryHashesResponse: Decodable, Sendable {
typealias StoryHashDictionary = [String: [StoryHash]]
var unread: [StoryHash]?
var starred: [StoryHash]?
struct StoryHash: Hashable, Codable {
var hash: String
var timestamp: Date
nonisolated struct StoryHash: Hashable, Codable, Sendable {
let hash: String
let timestamp: Date
}
}
extension NewsBlurStoryHashesResponse {
nonisolated extension NewsBlurStoryHashesResponse {
private enum CodingKeys: String, CodingKey {
case unread = "unread_feed_story_hashes"
case starred = "starred_story_hashes"
@@ -10,12 +10,11 @@ import Foundation
import RSParser
import RSCore
struct ReaderAPIEntryWrapper: Codable {
nonisolated struct ReaderAPIEntryWrapper: Codable, Sendable {
let id: String
let updated: Int
let entries: [ReaderAPIEntry]
enum CodingKeys: String, CodingKey {
case id = "id"
case updated = "updated"
@@ -47,8 +46,7 @@ struct ReaderAPIEntryWrapper: Codable {
}
}
*/
struct ReaderAPIEntry: Codable {
nonisolated struct ReaderAPIEntry: Codable, Sendable {
let articleID: String
let title: String?
let author: String?
@@ -104,7 +102,7 @@ struct ReaderAPIEntry: Codable {
}
struct ReaderAPIArticleSummary: Codable {
nonisolated struct ReaderAPIArticleSummary: Codable, Sendable {
let content: String?
enum CodingKeys: String, CodingKey {
@@ -112,7 +110,7 @@ struct ReaderAPIArticleSummary: Codable {
}
}
struct ReaderAPIAlternateLocation: Codable {
nonisolated struct ReaderAPIAlternateLocation: Codable, Sendable {
let url: String?
enum CodingKeys: String, CodingKey {
@@ -120,7 +118,7 @@ struct ReaderAPIAlternateLocation: Codable {
}
}
struct ReaderAPIEntryOrigin: Codable {
nonisolated struct ReaderAPIEntryOrigin: Codable, Sendable {
let streamId: String?
let title: String?
@@ -19,7 +19,7 @@ import RSParser
*/
struct ReaderAPIQuickAddResult: Codable {
nonisolated struct ReaderAPIQuickAddResult: Codable, Sendable {
let numResults: Int
let error: String?
let streamId: String?
@@ -31,7 +31,7 @@ struct ReaderAPIQuickAddResult: Codable {
}
}
struct ReaderAPISubscriptionContainer: Codable {
nonisolated struct ReaderAPISubscriptionContainer: Codable, Sendable {
let subscriptions: [ReaderAPISubscription]
enum CodingKeys: String, CodingKey {
@@ -55,7 +55,7 @@ struct ReaderAPISubscriptionContainer: Codable {
}
*/
struct ReaderAPISubscription: Codable {
nonisolated struct ReaderAPISubscription: Codable, Sendable {
let feedID: String
let name: String?
let categories: [ReaderAPICategory]
@@ -81,7 +81,7 @@ struct ReaderAPISubscription: Codable {
}
}
struct ReaderAPICategory: Codable {
nonisolated struct ReaderAPICategory: Codable, Sendable {
let categoryId: String
let categoryLabel: String
@@ -91,15 +91,14 @@ struct ReaderAPICategory: Codable {
}
}
struct ReaderAPICreateSubscription: Codable {
nonisolated struct ReaderAPICreateSubscription: Codable, Sendable {
let feedURL: String
enum CodingKeys: String, CodingKey {
case feedURL = "feed_url"
}
}
struct ReaderAPISubscriptionChoice: Codable {
nonisolated struct ReaderAPISubscriptionChoice: Codable, Sendable {
let name: String?
let url: String
@@ -107,5 +106,4 @@ struct ReaderAPISubscriptionChoice: Codable {
case name = "title"
case url = "feed_url"
}
}
@@ -8,7 +8,7 @@
import Foundation
struct ReaderAPITagContainer: Codable {
nonisolated struct ReaderAPITagContainer: Codable, Sendable {
let tags: [ReaderAPITag]
enum CodingKeys: String, CodingKey {
@@ -16,8 +16,7 @@ struct ReaderAPITagContainer: Codable {
}
}
struct ReaderAPITag: Codable {
nonisolated struct ReaderAPITag: Codable, Sendable {
let tagID: String
let type: String?
@@ -32,5 +31,4 @@ struct ReaderAPITag: Codable {
}
return String(tagID.suffix(from: range.upperBound))
}
}
@@ -8,7 +8,7 @@
import Foundation
struct ReaderAPIReferenceWrapper: Codable {
nonisolated struct ReaderAPIReferenceWrapper: Codable, Sendable {
let itemRefs: [ReaderAPIReference]?
let continuation: String?
@@ -18,7 +18,7 @@ struct ReaderAPIReferenceWrapper: Codable {
}
}
struct ReaderAPIReference: Codable {
nonisolated struct ReaderAPIReference: Codable, Sendable {
let itemId: String?
enum CodingKeys: String, CodingKey {
@@ -7,7 +7,7 @@
import Foundation
public enum ReaderAPIVariant {
nonisolated public enum ReaderAPIVariant: Sendable {
case generic
case freshRSS
case inoreader
@@ -26,5 +26,4 @@ public enum ReaderAPIVariant {
return ""
}
}
}
@@ -9,17 +9,15 @@
import Foundation
import RSCore
public enum ReadFilterType {
nonisolated public enum ReadFilterType: Sendable {
case read
case none
case alwaysRead
}
public protocol SidebarItem: SidebarItemIdentifiable, ArticleFetcher, DisplayNameProvider, UnreadCountProvider {
var account: Account? { get }
var defaultReadFilterType: ReadFilterType { get }
@MainActor var account: Account? { get }
@MainActor var defaultReadFilterType: ReadFilterType { get }
}
@MainActor public extension SidebarItem {
@@ -35,5 +33,4 @@ public protocol SidebarItem: SidebarItemIdentifiable, ArticleFetcher, DisplayNam
}
}
}
@@ -114,7 +114,7 @@ nonisolated public enum TransportError: LocalizedError, Sendable {
}
nonisolated public protocol Transport {
nonisolated public protocol Transport: Sendable {
/// Cancels all pending requests
func cancelAll()