Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ final class DependencyProviderClassSerializer: Serializer {
}

return """
@MainActor
private class \(classNameSerializer.serialize()): \(provider.unprocessed.dependency.name) {
\(propertiesSerializer.serialize())
\(sourceComponentsSerializer.serialize())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class OutputSerializer: Serializer {

\(registrationHelpers)

@MainActor
public func registerProviderFactories() {
\(registrationBody)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PluginExtensionContentSerializer: Serializer {
let nonCoreComponentPropertyName = component.nonCoreComponent.name.lowercasedFirstChar()

return """
@MainActor
/// \(component.data.name) plugin extension
private class \(extensionClassName): \(component.pluginExtension.name) {
\(properties)
Expand Down
3 changes: 3 additions & 0 deletions Sources/NeedleFoundation/Component.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import Foundation

/// The base protocol of a dependency, enabling Needle's parsing process.
@MainActor
public protocol Dependency: AnyObject {}

/// The base protocol of a DI scope. Application code should inherit
/// from the `Component` base class, instead of using this protocol
/// directly.
@MainActor
public protocol Scope: AnyObject {
/// The path to reach this component on the dependnecy graph.
var path: [String] { get }
Expand All @@ -35,6 +37,7 @@ public protocol Scope: AnyObject {
/// contains a set of properties it provides to units of its scope as well
/// as child scopes. A component instantiates child components that define
/// child scopes.
@MainActor
@dynamicMemberLookup
open class Component<DependencyType>: Scope {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import Foundation
// method in the base component class. Generate extensions to all the
// component subclasses that override the method to instantiate the
// dependnecy providers.
@MainActor
public class __DependencyProviderRegistry {

/// The singleton instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Foundation
// method in the base pluginized component class. Generate extensions to
// all the pluginized component subclasses that override the method to
// instantiate the dependnecy providers.
@MainActor
public class __PluginExtensionProviderRegistry {

/// The singleton instance.
Expand Down