Cuckoo icon indicating copy to clipboard operation
Cuckoo copied to clipboard

Compiler custom flags are not supported by Cuckoo generator

Open DanyilNefodov opened this issue 1 year ago • 3 comments

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?

DanyilNefodov avatar Jul 31 '23 10:07 DanyilNefodov

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 avatar Aug 15 '23 16:08 MatyasKriz

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 avatar Oct 04 '23 21:10 MatyasKriz

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.

MatyasKriz avatar Jun 24 '24 09:06 MatyasKriz