Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Azure Search] Remove JsonConvert.DefaultSettings check from unit tes…
…ts (#4053) Some time ago, we added a check to every Azure Search unit test that uses the Run() method. This check is intended to ensure that none of our SDK code uses the global JsonConvert.DefaultSettings, since these can be altered by other code in the same AppDomain. This was causing issues for customers, and is the reason we added SafeJsonConvert to ClientRuntime and AutoRest. The check in the Run() method installs a custom JsonConverter and ContractResolver that throw exceptions whenever they're called. It does this using a try/finally block so that the change should only be visible while running the unit test. Unfortunately, since JsonConvert.DefaultSettings is global state, this approach is fragile. For example, running tests in parallel can break this because some infrastructure such as the VS test runner framework itself uses JSON.NET in ways that rely on DefaultSettings. Given the fragility of this approach, we've decided to remove these checks altogether since they were causing spurious test failures.
- Loading branch information