I also recommend putting macros in project parameters (csproj file), as @Hans Passant suggests.
If you need documented definitions, you can add a documentation file to the solution explaining what the settings mean.
If there are not many options, you can define a new project configuration for each of them. This will allow you to pre-configure the required #defines list for each option, and then simply switch between them from the configuration list box on the toolbar. If you want to temporarily disable one parameter, you can duplicate the current configuration and delete #define, and then delete the configuration later when you tested it.
The next option, which I can offer to make it βeasierβ (by combining settings and documents into a single file, as you suggested), will use a simple text file (settings + comments) to set up the project, and spend 15 minutes on a fast C # application for reading this file and write the parameters that it contains in the .csproj file - this is just XML, so it should be a trivial writing application. You can easily configure this file and run the updater application to configure project settings. If you will do something often, spend 30 minutes on it and add a user interface with checkboxes to make it easier to choose settings.
The concept you are describing sounds rather strange. The point of the library is usually that you have one standardized piece of code that can be used by many clients, so changing these definitions to reorganize the entire library is not something I would expect to do very often. Perhaps you have good reasons , but it might be worth considering why you need to solve this #define problem.
(for example, if you have many clients who need different versions of the "library", the best option would be to use the configurations (described above) that allow you to create all the necessary options in a batch assembly. If you just try many different algorithms / methods, you can redo library pieces to limit the impact of most #defines on a single .cs file so that they no longer need a global? Maybe the library should not be in the same dll, or a plug-in architecture is needed so you can choose " Modules ", which are included in the library).
source share