0

I have two classes. There is #if statement, that decides which class should be used.

Example:

public class DebugTool { }
public class ReleaseTool { }
...
#if RELEASE
var tool = new ReleaseTool();
#elseif
var tool = new DebugTool();
#endif
...

The problem is that, while I'm working with debug configuration(or any configuration, that doesn't define RELEASE), rider shows me that there is no any usages of ReleaseTool class. And, if I remove ReleaseTool, I would not get any error until I cook a release build.

So is there a way to index all usages from all #if statements, including those ones, which will not be compiled with current configuration?

P.S It's just an example. I need exactly what I've asked. Solutions like "Place ReleaseTool under #if RELEASE" don't suit.

Nikolai
  • 656
  • 6
  • 19
  • 1
    Consider something like `#if RELEASE const bool isRelease = true;` and then `var tool = isRelease ? new ReleaseTool() : new DebugTool()`, making both implement `ITool` or suchlike. A `static readonly` also suffices. The JIT compiler can eliminate such checks efficiently, so there is no performance penalty. – Jeroen Mostert Sep 05 '22 at 11:07
  • does "release" class declaration is under the ifdef RELEASE statement ? – Zenek Sep 05 '22 at 11:07
  • You could add `var unusedTool = new ReleaseTool();` to the `#else` branch. – Klaus Gütter Sep 05 '22 at 11:08

0 Answers0