'Resolve preprocessor directives and save output
I have single code base written in C# covering slightly varying requirements from two customers.
namespace Demo
{
public class DemoClass
{
#if CUSTOMER_A
public void CustomerA()
{
// customer A logic
}
#endif
#if CUSTOMER_B
public void CustomerB()
{
// customer B logic
}
#endif
}
}
I need to provide customer A with the source code that only contains his use case.
namespace Demo
{
public class DemoClass
{
public void CustomerA()
{
// customer A logic
}
}
}
Is there an out of the box solution for such task?
Solution 1:[1]
One solution would be to use CPP, however this solution fails if there are #region #endregion directives.
cpp -C -P -DCUSTOMER_A DemoClass.cs DemoClass_CustomerA.cs
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | just-my-name |
