From fa409a8186996e56938b276aad0fd4eee9d05793 Mon Sep 17 00:00:00 2001 From: Snorri Gislason Date: Fri, 7 Feb 2025 03:29:25 +0000 Subject: [PATCH] Load resource stream outside of delegate --- ILSpy/TextView/DecompilerTextView.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index 4e748fd2a..3b9ea493c 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -1447,17 +1447,20 @@ namespace ICSharpCode.ILSpy.TextView if (resourceStream != null) { + IHighlightingDefinition highlightingDefinition; + + using (resourceStream) + using (XmlTextReader reader = new XmlTextReader(resourceStream)) + { + highlightingDefinition = HighlightingLoader.Load(reader, manager); + } + manager.RegisterHighlighting( - name, extensions, - delegate { - using (resourceStream) - using (XmlTextReader reader = new XmlTextReader(resourceStream)) - { - var highlightingDefinition = HighlightingLoader.Load(reader, manager); - ThemeManager.Current.ApplyHighlightingColors(highlightingDefinition); - return highlightingDefinition; - } - }); + name, extensions, + delegate { + ThemeManager.Current.ApplyHighlightingColors(highlightingDefinition); + return highlightingDefinition; + }); } } }