From eeeecb22590ec9fd4883d23b30640244767fc38c Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 9 Jun 2018 09:08:45 +0200 Subject: [PATCH] Remove "do what I mean" logic from AssignVariableNames --- .../IL/Transforms/AssignVariableNames.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs index 1a9605524..2e7435d38 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs @@ -261,7 +261,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms } if (string.IsNullOrEmpty(proposedName)) { var proposedNameForAddress = variable.AddressInstructions.OfType() - .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 } } - 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) {