Browse Source

Resolve LanguageService/Settings fresh so the tree filter honours current settings

ILSpyTreeNode cached the SettingsService (and LanguageService) in a static
field that was never invalidated. In the headless suite the MEF container is
rebuilt per test, so from the second test onward the filter cascade
(ApplyFilterToChild / OnIsVisibleChanged) read a previous test's disposed
SettingsService and its stale ShowApiLevel. A test that set ShowApiLevel=All
on its own fresh settings then expanded a large type still had ~a third of the
members marked IsHidden against the stale level, so the flattener dropped them
and the rows never realised -- surfacing as an order-dependent timeout
(NonPublic_Member_Rows_Render and the in-place refilter test).

GetSuffixString already resolves the service fresh for exactly this reason;
apply the same to CurrentLanguageSettings and LanguageService and drop the dead
caches. A warm GetExport is a dictionary lookup, and in production (one
container for the app lifetime) behaviour is unchanged.
pull/3755/head
Siegfried Pammer 1 month ago
parent
commit
0a7aa74542
  1. 15
      ILSpy/TreeNodes/ILSpyTreeNode.cs

15
ILSpy/TreeNodes/ILSpyTreeNode.cs

@ -37,15 +37,15 @@ namespace ILSpy.TreeNodes @@ -37,15 +37,15 @@ namespace ILSpy.TreeNodes
{
IEnumerable<ITreeNode> ITreeNode.Children => Children.OfType<ILSpyTreeNode>();
static LanguageService? cachedLanguageService;
static SettingsService? cachedSettingsService;
/// <summary>
/// Resolves the LanguageService from the MEF composition. Tree nodes use this to access
/// the active <see cref="Language"/> for formatting their <see cref="SharpTreeNode.Text"/>.
/// 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 <see cref="GetSuffixString(EntityHandle)"/> for the same rationale.
/// </summary>
protected static LanguageService LanguageService
=> cachedLanguageService ??= AppComposition.Current.GetExport<LanguageService>();
=> AppComposition.Current.GetExport<LanguageService>();
/// <summary>
/// The active <see cref="LanguageSettings"/>, or <see langword="null"/> when composition
@ -58,8 +58,11 @@ namespace ILSpy.TreeNodes @@ -58,8 +58,11 @@ namespace ILSpy.TreeNodes
get {
try
{
var service = cachedSettingsService ??= AppComposition.Current.GetExport<SettingsService>();
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<SettingsService>().SessionSettings.LanguageSettings;
}
catch
{

Loading…
Cancel
Save