Browse Source

Fix bug in AssignVariableNames: The first parameter of indexer getters was not properly handled.

pull/1600/head
Siegfried Pammer 7 years ago
parent
commit
b3db473211
  1. 11
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

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

@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
loopCounters = CollectLoopCounters(function); loopCounters = CollectLoopCounters(function);
foreach (var f in function.Descendants.OfType<ILFunction>()) { foreach (var f in function.Descendants.OfType<ILFunction>()) {
if (f.Method != null) { if (f.Method != null) {
if (f.Method.IsAccessor && f.Method.Parameters.Count > 0) { if (IsSetOrEventAccessor(f.Method) && f.Method.Parameters.Count > 0) {
for (int i = 0; i < f.Method.Parameters.Count - 1; i++) { for (int i = 0; i < f.Method.Parameters.Count - 1; i++) {
AddExistingName(reservedVariableNames, f.Method.Parameters[i].Name); AddExistingName(reservedVariableNames, f.Method.Parameters[i].Name);
} }
@ -121,6 +121,15 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
bool IsSetOrEventAccessor(IMethod method)
{
if (method.AccessorOwner is IProperty p)
return p.Setter == method;
if (method.AccessorOwner is IEvent e)
return e.InvokeAccessor != method;
return false;
}
void PerformAssignment(ILFunction function) void PerformAssignment(ILFunction function)
{ {
// remove unused variables before assigning names // remove unused variables before assigning names

Loading…
Cancel
Save