c# - Preprocessor directive "being consumed" building dll -


i have class several utility functions. class compiled dll used in user editor, of there 3 operative versions.

these 3 versions (let's call them a, b , c) use core library different across 3 versions, named identically file, , overlapping functions , classes.

to compile dll , able interface editor chose 1 version of core library, , referenced in solution. convenience in terms of cross compatibility other versions, choose b version of core library.

now problem i'm facing: of functions / class properties in core libraries missing in 1 version in respect others, need able address these functions , classes , 'decide' (at runtime?) property use, address version-specific property of class / function user running. each version of editor exposes global define version.

simple example: version class_a property_1 property_2  version b class_a identical version  version c class_a property_1 property_3 <= property 2 has disappeared, must use per new api specifications 

i've tried use defines, realize these 'consumed' when build, , since reference b version of editor, dll 'baptized' if user editor b, regardless of editor later use dll.

simple example: ... //some code in library public void useclassa() {     class_a newclassa = new class_a();     newclassa.property_1 = "x";     #if version_a || version_b     newclassa.property_2 = "y";     #endif      #if version_c     newclassa.property_3 = "y";     #endif } ^^^ version c users error when calling function, since dll built reference version_b's core dll. 

as alternative, i've used reflection, feels dirty since i'm forced 'property check' @ runtime, instead of 'version check'.

so question is, possible maintain directives in place in code, they're considered @ runtime rather during build? kind of understand not how directives work, hope there's alternative or way achieve desired result.


Popular posts from this blog