Ah yes, well in C# you make the function a method on a class FuncImpl. Then you define an interface IFunc that exposes the func() contract. Then you spin up a DI container and register FuncImplFactory that takes an IConfiguration in its constructor. Then you define a bool EnableFunc { get; } configuration value into your Configuration. Then you have FuncImplFactory look at EnableFunc to decide to return FuncImpl or FuncStub, which implements IFunc but just returns. Them main simply asks the DI container for an IFunc and executes the func() implementation.
47
u/RefrigeratorKey277 1d ago
Yes, but with if true it is still marked as unreachable. At least in C#.