Skip to content
Merged
Changes from all 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 @@ -30,6 +30,7 @@ public class FixLegacyResourceDesignerStep : LinkDesignerBase
AssemblyDefinition designerAssembly = null;
TypeDefinition designerType = null;
Dictionary<string, MethodDefinition> lookup;
Dictionary<string, MethodDefinition> lookupCaseInsensitive;

protected override void EndProcess ()
{
Expand Down Expand Up @@ -61,7 +62,7 @@ protected override void LoadDesigner ()
LogMessage ($" Did not find {DesignerAssemblyNamespace}.Resource type. It was probably linked out.");
return;
}
lookup = BuildResourceDesignerPropertyLookup (designerType);
lookup = BuildResourceDesignerPropertyLookup (designerType, out lookupCaseInsensitive);
} finally {
designerLoaded = true;
}
Expand Down Expand Up @@ -105,10 +106,11 @@ internal override bool ProcessAssemblyDesigner (AssemblyDefinition assembly)
return true;
}

Dictionary<string, MethodDefinition> BuildResourceDesignerPropertyLookup (TypeDefinition type)
Dictionary<string, MethodDefinition> BuildResourceDesignerPropertyLookup (TypeDefinition type, out Dictionary<string, MethodDefinition> caseInsensitiveLookup)
{
LogMessage ($" Building Designer Lookups for {type.FullName}");
var output = new Dictionary<string, MethodDefinition> (StringComparer.Ordinal);
caseInsensitiveLookup = new Dictionary<string, MethodDefinition> (StringComparer.OrdinalIgnoreCase);
foreach (TypeDefinition definition in type.NestedTypes)
{
foreach (PropertyDefinition property in definition.Properties)
Expand All @@ -117,7 +119,9 @@ Dictionary<string, MethodDefinition> BuildResourceDesignerPropertyLookup (TypeDe
if (output.ContainsKey (key)) {
LogMessage ($" Found duplicate {key}");
} else {
LogMessage ($" Adding {key}");
output.Add (key, property.GetMethod);
caseInsensitiveLookup [key] = property.GetMethod;
}
}
}
Expand Down Expand Up @@ -153,7 +157,12 @@ protected override void FixBody (MethodBody body, TypeDefinition designer)
if (idx >= 0) {
string key = line.Substring (idx + designerFullName.Length);
LogMessage ($"Looking for {key}.");
if (lookup.TryGetValue (key, out MethodDefinition method)) {
var found = lookup.TryGetValue (key, out MethodDefinition method);
if (!found) {
LogMessage ($"DEBUG! Failed to find {key}! Trying case insensitive lookup.");
found = lookupCaseInsensitive.TryGetValue (key, out method);
}
if (found) {
var importedMethod = designer.Module.ImportReference (method);
var newIn = Instruction.Create (OpCodes.Call, importedMethod);
instructions.Add (i, newIn);
Expand Down