In my team's deployment environment, there are three endpoints for a certain REST data api: alpha, beta and production.
I have setup conditional compilation so that in RELEASE configuration, the project will definitely connect to the production api. In DEBUG configuration, however, the project may connect to any of the three endpoints according to the developer's preference.
Currently, the developer sets this preference by commenting out the endpoints not needed.
However, different developers will wish to connect to different endpoints during development, so this system doesn't work well with git and a team. How can I change the setup so that the api endpoint is selected according to a developer preference (and not committed to git) in DEBUG configuration only?
const string api_prod = "https://api.mydomain.com/api/";
const string api_beta = "https://betaapi.mydomain.com/api/";
const string api_alpha = "https://alphaapi.mydomain.com/api/";
#if DEBUG
//static readonly string BaseUrl = api_prod;
//static readonly string BaseUrl = api_beta;
static readonly string BaseUrl = api_alpha;
#else
static readonly string BaseUrl = api_prod;
#endif
You should use external configuration files and make their inclusion dependent on compilation configuration. Take a look at slow cheetah https://visualstudiogallery.msdn.microsoft.com/69023d00-a4f9-4a34-a6cd-7e854ba318b5
Keeping hardcoded uris is never a good idea.