Browse Source

Fix #1180: Fix generation of Windows Forms InitializeComponent.

pull/1464/head
Siegfried Pammer 7 years ago
parent
commit
b0309ca9e3
  1. 2
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.cs
  2. 1
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  3. 2
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  4. 5
      ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

2
ICSharpCode.Decompiler.Tests/TestCases/Pretty/FixProxyCalls.cs

@ -100,7 +100,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.ILPretty
base.Test(a); base.Test(a);
}; };
if (test.Equals(1)) { if (test.Equals(1)) {
throw new Exception("roslyn optimize is inlining the assignment which lets the test fail"); throw new Exception("roslyn optimizes is inlining the assignment which lets the test fail");
} }
action(test); action(test);
} }

1
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -1203,6 +1203,7 @@ namespace ICSharpCode.Decompiler.CSharp
localSettings.UseImplicitMethodGroupConversion = false; localSettings.UseImplicitMethodGroupConversion = false;
localSettings.UsingDeclarations = false; localSettings.UsingDeclarations = false;
localSettings.AlwaysCastTargetsOfExplicitInterfaceImplementationCalls = true; localSettings.AlwaysCastTargetsOfExplicitInterfaceImplementationCalls = true;
localSettings.NamedArguments = false;
} }
var context = new ILTransformContext(function, typeSystem, DebugInfoProvider, localSettings) { var context = new ILTransformContext(function, typeSystem, DebugInfoProvider, localSettings) {

2
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -649,7 +649,7 @@ namespace ICSharpCode.Decompiler.CSharp
list.IsExpandedForm = isExpandedForm; list.IsExpandedForm = isExpandedForm;
list.IsPrimitiveValue = isPrimitiveValue; list.IsPrimitiveValue = isPrimitiveValue;
list.FirstOptionalArgumentIndex = firstOptionalArgumentIndex; list.FirstOptionalArgumentIndex = firstOptionalArgumentIndex;
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NonTrailingNamedArguments; list.AddNamesToPrimitiveValues = expressionBuilder.settings.NamedArguments && expressionBuilder.settings.NonTrailingNamedArguments;
return list; return list;
} }

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

@ -264,6 +264,11 @@ namespace ICSharpCode.Decompiler.IL.Transforms
} }
} }
} }
// The ComponentResourceManager inside InitializeComponent must be named "resources",
// otherwise the WinForms designer won't load the Form.
if (CSharp.CSharpDecompiler.IsWindowsFormsInitializeComponentMethod(context.Function.Method) && variable.Type.FullName == "System.ComponentModel.ComponentResourceManager") {
proposedName = "resources";
}
if (string.IsNullOrEmpty(proposedName)) { if (string.IsNullOrEmpty(proposedName)) {
var proposedNameForAddress = variable.AddressInstructions.OfType<LdLoca>() var proposedNameForAddress = variable.AddressInstructions.OfType<LdLoca>()
.Select(arg => arg.Parent is CallInstruction c ? c.GetParameter(arg.ChildIndex)?.Name : null) .Select(arg => arg.Parent is CallInstruction c ? c.GetParameter(arg.ChildIndex)?.Name : null)

Loading…
Cancel
Save