Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ private void AddResourceInternal(object name, object type, ushort language, byte
}
else
{
Debug.Assert(type is string);
type = ToUpperForResource((string)type);
if (!_resTypeHeadName.TryGetValue((string)type, out resType))
{
resType = new ResType();
Expand All @@ -45,6 +47,8 @@ private void AddResourceInternal(object name, object type, ushort language, byte
}
else
{
Debug.Assert(name is string);
name = ToUpperForResource((string)name);
if (!resType.NameHeadName.TryGetValue((string)name, out resName))
{
resName = new ResName();
Expand All @@ -63,8 +67,10 @@ private byte[] FindResourceInternal(object name, object type, ushort language)
{
_resTypeHeadID.TryGetValue((ushort)type, out resType);
}
if (type is string)
else
{
Debug.Assert(type is string);
type = ToUpperForResource((string)type);
_resTypeHeadName.TryGetValue((string)type, out resType);
}

Expand All @@ -77,8 +83,10 @@ private byte[] FindResourceInternal(object name, object type, ushort language)
{
resType.NameHeadID.TryGetValue((ushort)name, out resName);
}
if (name is string)
else
{
Debug.Assert(name is string);
name = ToUpperForResource((string)name);
resType.NameHeadName.TryGetValue((string)name, out resName);
}

Expand All @@ -90,5 +98,16 @@ private byte[] FindResourceInternal(object name, object type, ushort language)

return (byte[])resLanguage.DataEntry.Clone();
}

private static string ToUpperForResource(string str)
{
// Undocumented semantic for Win32 Resource APIs
StringBuilder builder = new(str.Length);
foreach (char c in str)
{
builder.Append('a' <= c && c <= 'z' ? char.ToUpper(c) : c);
}
return builder.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down