diff --git a/ILSpy.Tests/Analyzers/MethodUsesAnalyzerTests.cs b/ILSpy.Tests/Analyzers/MethodUsesAnalyzerTests.cs index a3cd215c4..0b234541d 100644 --- a/ILSpy.Tests/Analyzers/MethodUsesAnalyzerTests.cs +++ b/ILSpy.Tests/Analyzers/MethodUsesAnalyzerTests.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.ILSpy.Tests.Analyzers [OneTimeSetUp] public void Setup() { - new Application(); + Stub.SetupApplication(); Options.DecompilerSettingsPanel.TestSetup(new Decompiler.DecompilerSettings()); assemblyList = new AssemblyList("Test"); testAssembly = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location); diff --git a/ILSpy.Tests/Analyzers/TypeUsedByAnalyzerTests.cs b/ILSpy.Tests/Analyzers/TypeUsedByAnalyzerTests.cs index c94e7bae6..fba4bc5cb 100644 --- a/ILSpy.Tests/Analyzers/TypeUsedByAnalyzerTests.cs +++ b/ILSpy.Tests/Analyzers/TypeUsedByAnalyzerTests.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.ILSpy.Tests.Analyzers [OneTimeSetUp] public void Setup() { - new Application(); + Stub.SetupApplication(); Options.DecompilerSettingsPanel.TestSetup(new Decompiler.DecompilerSettings()); assemblyList = new AssemblyList("Test"); testAssembly = assemblyList.OpenAssembly(typeof(MethodUsesAnalyzerTests).Assembly.Location); diff --git a/ILSpy.Tests/Stub.cs b/ILSpy.Tests/Stub.cs index 4bfce75b2..53afccfe1 100644 --- a/ILSpy.Tests/Stub.cs +++ b/ILSpy.Tests/Stub.cs @@ -16,12 +16,24 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using System.Windows; + namespace ICSharpCode.ILSpy.Tests { - class Stub + public static class Stub { static void Main(string[] args) { } + + static readonly object sync = new object(); + + internal static void SetupApplication() + { + lock (sync) { + if (Application.Current == null) + new Application(); + } + } } }