Skip to content

Commit b0309ca

Browse files
Fix #1180: Fix generation of Windows Forms InitializeComponent.
1 parent 4987f78 commit b0309ca

4 files changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected internal override void Test(string test)
100100
base.Test(a);
101101
};
102102
if (test.Equals(1)) {
103-
throw new Exception("roslyn optimize is inlining the assignment which lets the test fail");
103+
throw new Exception("roslyn optimizes is inlining the assignment which lets the test fail");
104104
}
105105
action(test);
106106
}

ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,7 @@ void DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun de
12031203
localSettings.UseImplicitMethodGroupConversion = false;
12041204
localSettings.UsingDeclarations = false;
12051205
localSettings.AlwaysCastTargetsOfExplicitInterfaceImplementationCalls = true;
1206+
localSettings.NamedArguments = false;
12061207
}
12071208

12081209
var context = new ILTransformContext(function, typeSystem, DebugInfoProvider, localSettings) {

ICSharpCode.Decompiler/CSharp/CallBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ private ArgumentList BuildArgumentList(ExpectedTargetDetails expectedTargetDetai
649649
list.IsExpandedForm = isExpandedForm;
650650
list.IsPrimitiveValue = isPrimitiveValue;
651651
list.FirstOptionalArgumentIndex = firstOptionalArgumentIndex;
652-
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NonTrailingNamedArguments;
652+
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NamedArguments && expressionBuilder.settings.NonTrailingNamedArguments;
653653
return list;
654654
}
655655

ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ string GenerateNameForVariable(ILVariable variable)
264264
}
265265
}
266266
}
267+
// The ComponentResourceManager inside InitializeComponent must be named "resources",
268+
// otherwise the WinForms designer won't load the Form.
269+
if (CSharp.CSharpDecompiler.IsWindowsFormsInitializeComponentMethod(context.Function.Method) && variable.Type.FullName == "System.ComponentModel.ComponentResourceManager") {
270+
proposedName = "resources";
271+
}
267272
if (string.IsNullOrEmpty(proposedName)) {
268273
var proposedNameForAddress = variable.AddressInstructions.OfType<LdLoca>()
269274
.Select(arg => arg.Parent is CallInstruction c ? c.GetParameter(arg.ChildIndex)?.Name : null)

0 commit comments

Comments
 (0)