Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support actor object via annotation metadata #221

Conversation

treastrain
Copy link

Issue

Part of #216
(#216 (comment) 's "1.")

Description

Add an annotation "object: class/actor" for specifying the object nominal types of the mock.
This allows the user to choose, at his/her own risk, whether to generate the mock for the protocol as a class or as an actor.

For details: #216 (comment)

@CLAassistant
Copy link

CLAassistant commented Mar 9, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@uhooi uhooi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx PR!!

}
"""

let argumentsObjectTypesWithActorAnnotation =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like you to write the following test.

/// \(String.mockAnnotation)(object: actor)
protocol Foo: Bar {
    func foo(arg: String) async -> Result<String, Error>
    var bar: Int { get }
}

protocol Bar: Actor {
    func baz(arg: String) async -> Result<String, Error>
    var qux: Int { get }
}

Sources/MockoloFramework/Models/ActorModel.swift Outdated Show resolved Hide resolved
import Foundation

extension ActorModel {
func applyActorTemplate(name: String,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like to reduce a lot of duplication codes with ClassModel?
I have not good idea yet, but this size of duplications will cause future bug.

struct AnnotationMetadata {
var objectType: ObjectType?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please describe the usecase of this option.
Is it not enough when the protocol inherit Actor ?
(It seems that this option is added only to split the implementation 1 and 2 in #216 (comment))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, this is my misunderstanding. I understand 1 and 2 are not dependent of each other.

@treastrain
Copy link
Author

Same: #222 (comment)

@treastrain treastrain closed this Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants