diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs index 8ee6aaebc6d2d..3da313f0ff752 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.UpdateResourceDataModel.cs @@ -3,6 +3,7 @@ using System; using System.Collections; +using System.Diagnostics; #if HOST_MODEL namespace Microsoft.NET.HostModel.Win32Resources @@ -26,6 +27,7 @@ private void AddResourceInternal(object name, object type, ushort language, byte } else { + Debug.Assert(type is string); if (!_resTypeHeadName.TryGetValue((string)type, out resType)) { resType = new ResType(); @@ -45,6 +47,7 @@ private void AddResourceInternal(object name, object type, ushort language, byte } else { + Debug.Assert(name is string); if (!resType.NameHeadName.TryGetValue((string)name, out resName)) { resName = new ResName(); @@ -57,28 +60,30 @@ private void AddResourceInternal(object name, object type, ushort language, byte private byte[] FindResourceInternal(object name, object type, ushort language) { - ResType resType = null; + ResType resType; if (type is ushort) { _resTypeHeadID.TryGetValue((ushort)type, out resType); } - if (type is string) + else { + Debug.Assert(type is string); _resTypeHeadName.TryGetValue((string)type, out resType); } if (resType == null) return null; - ResName resName = null; + ResName resName; if (name is ushort) { resType.NameHeadID.TryGetValue((ushort)name, out resName); } - if (name is string) + else { + Debug.Assert(name is string); resType.NameHeadName.TryGetValue((string)name, out resName); } diff --git a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs index ff6b7fb9ee6f4..007374e35a860 100644 --- a/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs +++ b/src/coreclr/tools/Common/Compiler/Win32Resources/ResourceData.cs @@ -60,6 +60,10 @@ public ResourceData(Internal.TypeSystem.Ecma.EcmaModule ecmaModule, Func /// Find a resource in the resource data /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public byte[] FindResource(string name, string type, ushort language) { return FindResourceInternal(name, type, language); @@ -68,6 +72,10 @@ public byte[] FindResource(string name, string type, ushort language) /// /// Find a resource in the resource data /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public byte[] FindResource(ushort name, string type, ushort language) { return FindResourceInternal(name, type, language); @@ -76,6 +84,10 @@ public byte[] FindResource(ushort name, string type, ushort language) /// /// Find a resource in the resource data /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public byte[] FindResource(string name, ushort type, ushort language) { return FindResourceInternal(name, type, language); @@ -92,16 +104,28 @@ public byte[] FindResource(ushort name, ushort type, ushort language) /// /// Add or update resource /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public void AddResource(string name, string type, ushort language, byte[] data) => AddResourceInternal(name, type, language, data); /// /// Add or update resource /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public void AddResource(string name, ushort type, ushort language, byte[] data) => AddResourceInternal(name, type, language, data); /// /// Add or update resource /// + /// + /// The Win32 APIs typcially perform an uppercase transform on string arguments - during add and find. + /// If the resource will be read by Win32 APIs, it is recommended to make the resource name upper case. + /// public void AddResource(ushort name, string type, ushort language, byte[] data) => AddResourceInternal(name, type, language, data); /// diff --git a/src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHost.cs b/src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHost.cs index f344da03bd76b..4b6d31fdc76e3 100644 --- a/src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHost.cs +++ b/src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHost.cs @@ -57,7 +57,7 @@ public static void Create( if (tlbFileBytes.Length == 0) throw new InvalidTypeLibraryException(typeLibrary.Value); - updater.AddResource(tlbFileBytes, "typelib", (IntPtr)typeLibrary.Key); + updater.AddResource(tlbFileBytes, "TYPELIB", (IntPtr)typeLibrary.Key); } catch (FileNotFoundException ex) {