I am working on removing obsolete/unused pieces of configuration from a .NET product starting with appSettings. There are multiple solutions and I've noticed that appSettings can be in a .config file in one project but which are somehow read in another project, sometimes in a separate solutions.
What I'm trying to figure out:
- How to tell from which .config file a particular configuration setting is read?
- How to tell which configuration settings can be removed?
Some easy cases:
- there is an appSetting with a key like 'ResetHelloWorldWhenFooBarHappens'. I can full text search all solutions and it only appears in the app.config file I'm cleaning up. It can be removed.
- there is an appSetting which Visual Studio Ctrl + F (search document/project/solution) shows me is used everywhere and is holding the project together. It can be removed but the application will fail.
- there is an appsetting which is not used anywhere in the solution but the key name is included in an enum in a separate solution named Shared which handles logging for several solutions. I can remove it and see that logging stops working for that solution.
Some tricky cases:
- there is an appSetting in a config file which is not being used in that project but it is used in a different project which does not have it's own config files. I can look at the project references (or dependencies if its a newer SDK style project), see there is some kind of connection between the projects and guess that the appSettings is being used.
- there is an appSetting with a generic name like 'path' which appears in various other config files and is read/gotten in obscure code by various projects and solutions. I don't know what to do. I could leave all of those appSettings alone even if most of them do nothing. If I remove some/all of them it's difficult to figure what has changed or if anything has broken.
Thanks in advance.