I am writing a c# application that currently uses
#if IOS
using Plugin.Firebase.iOS;
#else
using Plugin.Firebase.Android;
#endif
and then it uses it later on:
void SomeMethod(Events events) {
#if IOS
events.AddiOS( _ => { // AddiOS is only present on the IOS version of plugin library
// some IOS specific code
};
#else
events.AddAndroid( _ => { // AddAndroid is only present on the Android version of plugin library
// some Android specific code
};
#endif
}
I just learned about conditional attributes. They seems super powerful and easier to use.
However, when I refactor the call to AddiOS() into its own conditional method using
[Conditional("IOS")]
it gives a compiler error since it can't find Plugin.Firebase.iOS anymore. If I remove the #if for the using directives, I get compilation errors.
Is there a way to attach using directives to conditional methods somehow? A google search didn't turn anything up, but I wasn't too sure what to search for.
Just to add: I can get conditional methods working when they don't depend on packages that need to be imported using #if as well.