// sourcery: Autofixturable
class Person {
// sourcery fixture = .init(fromString: "dasdsadsa-dasddede2-3rd2e")
let id: UUID
// sourcery fixture = "James Bond"
let name: String
// sourcery fixture = 18
let age: Int
// sourcery fixture = .male
let sex: Sex // enum
}
The only way to pass information about a single property was to add a comment like // sourcery fixture = 18. But this is not compile time checked as it is a comment.
So I was wondering.. can Sourcery somehow read actual code and not declarations only? Or is there any workaround to pass information for a property but at the same time have compile time check!
We only analyze AST but I can imagine you could potentially leverage PropertyWrappers? we have basic support for them already and could potentially extend it
I'm trying to build an automatic way to create fixtures that are used in unit tests to easily create models. https://medium.com/@bruno.hcr/swift-tests-tips-tricks-fixture-object-pattern-5decefe6f10c
The only way to pass information about a single property was to add a comment like
// sourcery fixture = 18
. But this is not compile time checked as it is a comment.So I was wondering.. can Sourcery somehow read actual code and not declarations only? Or is there any workaround to pass information for a property but at the same time have compile time check!