We have some mocking code that I'd like to run ONLY when running in VS2022. Does anyone know if there is a preprocessor variable (or some other way) I can use to check for this condition, that the code is running in VS2022 ? I'm using C# with .NET Core 6.
I understand there are reasons this isn't a good idea. I'm just looking for an answer as to whether this is possible, and how. We're in a situation where we need a short term solution while we work on the longer term solution.
The #if DEBUG solution doesn't work, because we run debug builds in one of our integration environments. In the integration environment, we want to use the real services and not the mocks.
As Progman said above, using System.Diagnostics.Debugger.IsAttached works for us.