From b14b1d1164b08ea0a4274b3e3f75d3d4349db3f1 Mon Sep 17 00:00:00 2001 From: Kirill Osenkov Date: Sat, 30 Nov 2024 22:43:49 -0800 Subject: [PATCH] Fix static field order --- Editor/Completion/XmlImageIds.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Editor/Completion/XmlImageIds.cs b/Editor/Completion/XmlImageIds.cs index 12187088..58445ec4 100644 --- a/Editor/Completion/XmlImageIds.cs +++ b/Editor/Completion/XmlImageIds.cs @@ -10,6 +10,12 @@ namespace MonoDevelop.Xml.Editor.Completion { public static class XmlImages { + // Warning: the order of these static fields is important, + // declare in the order they depend on one another. + // If this Guid is at the end, the other fields will read the empty value before it gets initialized + static readonly Guid KnownImagesGuid = KnownImageIds.ImageCatalogGuid; + static ImageElement CreateElement(int id) => new ImageElement(new ImageId(KnownImagesGuid, id)); + public static readonly ImageElement Element = CreateElement (KnownImageIds.XMLElement); public static readonly ImageElement Attribute = CreateElement (KnownImageIds.XMLAttribute); public static readonly ImageElement AttributeValue = CreateElement (KnownImageIds.Constant); @@ -19,8 +25,5 @@ public static class XmlImages public static readonly ImageElement Prolog = CreateElement (KnownImageIds.XMLProcessInstructionTag); public static readonly ImageElement Entity = Prolog; public static ImageElement ClosingTag = Element; - - static readonly Guid KnownImagesGuid = KnownImageIds.ImageCatalogGuid; - static ImageElement CreateElement (int id) => new ImageElement (new ImageId (KnownImagesGuid, id)); } }