diff --git a/ILSpy/TreeNodes/ILSpyTreeNode.cs b/ILSpy/TreeNodes/ILSpyTreeNode.cs index 97956ba37..e4b569bfc 100644 --- a/ILSpy/TreeNodes/ILSpyTreeNode.cs +++ b/ILSpy/TreeNodes/ILSpyTreeNode.cs @@ -37,15 +37,15 @@ namespace ILSpy.TreeNodes { IEnumerable ITreeNode.Children => Children.OfType(); - static LanguageService? cachedLanguageService; - static SettingsService? cachedSettingsService; - /// /// Resolves the LanguageService from the MEF composition. Tree nodes use this to access /// the active for formatting their . + /// Resolved fresh each call: a static cache can hold a previous test's composition root in + /// headless sweeps (the container is rebuilt per test), and a warm GetExport is a dictionary + /// lookup. See for the same rationale. /// protected static LanguageService LanguageService - => cachedLanguageService ??= AppComposition.Current.GetExport(); + => AppComposition.Current.GetExport(); /// /// The active , or when composition @@ -58,8 +58,11 @@ namespace ILSpy.TreeNodes get { try { - var service = cachedSettingsService ??= AppComposition.Current.GetExport(); - return service.SessionSettings.LanguageSettings; + // Resolve fresh each call -- a static cache can hold a previous test's composition + // root in headless sweeps (the container is rebuilt per test, so a cached + // SettingsService reports a stale ShowApiLevel and the filter cascade hides nodes + // that the current settings would show). A warm GetExport is a dictionary lookup. + return AppComposition.Current.GetExport().SessionSettings.LanguageSettings; } catch {