Ejemplo n.º 1
0
        // Tell ReSharper the cache folder being used for shadow copy, so that if
        // someone kills this process (e.g. user aborts), ReSharper can delete it.
        // xunit doesn't expose this information, so we'll grab it via (sorry) reflection
        private void SetTempFolderPath(ExecutorWrapper executorWrapper)
        {
            if (!configuration.ShadowCopy)
                return;

            var fieldInfo = executorWrapper.GetType().GetField("appDomain", BindingFlags.NonPublic | BindingFlags.Instance);
            if (fieldInfo == null)
                throw new InvalidOperationException("Expected ExecutorWrapped to contain private field \"appDomain\"");

            var appDomain = fieldInfo.GetValue(executorWrapper) as AppDomain;
            if (appDomain != null)
            {
                var cachePath = appDomain.SetupInformation.CachePath;
                if (!string.IsNullOrEmpty(cachePath))
                    server.SetTempFolderPath(cachePath);
            }
        }