Browse Source

Remove "do what I mean" logic from AssignVariableNames

pull/1176/head
Siegfried Pammer 8 years ago
parent
commit
eeeecb2259
  1. 16
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

16
ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

@ -261,7 +261,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -261,7 +261,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
if (string.IsNullOrEmpty(proposedName)) {
var proposedNameForAddress = variable.AddressInstructions.OfType<LdLoca>()
.Select(arg => arg.Parent is CallInstruction c ? GetNameFromParameter(c.GetParameter(arg.ChildIndex)) : null)
.Select(arg => arg.Parent is CallInstruction c ? c.GetParameter(arg.ChildIndex)?.Name : null)
.Where(arg => !string.IsNullOrWhiteSpace(arg))
.Except(currentFieldNames).ToList();
if (proposedNameForAddress.Count > 0) {
@ -310,20 +310,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -310,20 +310,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms
}
}
static readonly FullTypeName DllImportAttributeName = new TopLevelTypeName("System.Runtime.InteropServices", "DllImportAttribute");
static string GetNameFromParameter(IParameter param)
{
if (param == null || !(param.Owner is IMethod method))
return string.Empty;
string name = param.Name;
// Special case for DllImports:
if (name.Length > 1 && name.StartsWith("p", StringComparison.Ordinal) && method.GetAttribute(DllImportAttributeName) != null) {
return name.Substring(1);
}
return name;
}
static string GetNameFromInstruction(ILInstruction inst)
{
switch (inst) {

Loading…
Cancel
Save