Brightify / Cuckoo

Boilerplate-free mocking framework for Swift!
MIT License
1.67k stars 174 forks source link

Compiler custom flags are not supported by Cuckoo generator #471

Open DanyilNefodov opened 1 year ago

DanyilNefodov commented 1 year ago

Hi!

I have protocols which use Compiler custom flags. I have code similar to next one:

protocol Boo {
    func doesBoo(arg: Int64)
    #if FEATURE_FLAG
    func doesBooForFeature(arg: Int64)
    #endif
}

extension Boo {
    func doesBoo(arg: Int64) {
        doesBoo(arg: arg)
    }
    #if FEATURE_FLAG
    func doesBooForFeature(arg: Int64) {
        doesBooForFeature(arg: arg)
    }
    #endif
}

When I mock this code with FEATURE_FLAG disabled I get next error:

image
/path/to/mock/GeneratedMocks.swift:1757:45 Value of type 'any Boo' has no member 'doesBooForFeature'

I didn't found any reference to custom flags in Generator code/doc.

Could you help me please to understand is there any functionality for it? If not can it be supported in future?

MatyasKriz commented 1 year ago

Hey, this functionality probably isn't supported in Cuckoo. It might be easier to add it to the SwiftSyntax version I've been cooking up, but I haven't gotten around to finishing that up and releasing as Cuckoo 2.0 yet. 🙂

MatyasKriz commented 1 year ago

I've looked into implementing this and as it stands it will be a bit harder to add than I initially thought. Mainly because of #elseif that can be added into the mix. I'll keep it in mind though.

MatyasKriz commented 5 months ago

2 likes on that previous issue, so this might be useful to users, but I'm not sure if I'm able to add support for it before converting the generator to use SwiftFormat instead of Sourcery.