Skip to content

Commit

Permalink
Fix #1180: Fix generation of Windows Forms InitializeComponent.
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Mar 8, 2019
1 parent 4987f78 commit b0309ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected internal override void Test(string test)
base.Test(a);
};
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);
}
Expand Down
1 change: 1 addition & 0 deletions ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,7 @@ void DecompileBody(IMethod method, EntityDeclaration entityDecl, DecompileRun de
localSettings.UseImplicitMethodGroupConversion = false;
localSettings.UsingDeclarations = false;
localSettings.AlwaysCastTargetsOfExplicitInterfaceImplementationCalls = true;
localSettings.NamedArguments = false;
}

var context = new ILTransformContext(function, typeSystem, DebugInfoProvider, localSettings) {
Expand Down
2 changes: 1 addition & 1 deletion ICSharpCode.Decompiler/CSharp/CallBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ private ArgumentList BuildArgumentList(ExpectedTargetDetails expectedTargetDetai
list.IsExpandedForm = isExpandedForm;
list.IsPrimitiveValue = isPrimitiveValue;
list.FirstOptionalArgumentIndex = firstOptionalArgumentIndex;
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NonTrailingNamedArguments;
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NamedArguments && expressionBuilder.settings.NonTrailingNamedArguments;
return list;
}

Expand Down
5 changes: 5 additions & 0 deletions ICSharpCode.Decompiler/IL/Transforms/AssignVariableNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ string GenerateNameForVariable(ILVariable variable)
}
}
}
// 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)) {
var proposedNameForAddress = variable.AddressInstructions.OfType<LdLoca>()
.Select(arg => arg.Parent is CallInstruction c ? c.GetParameter(arg.ChildIndex)?.Name : null)
Expand Down

0 comments on commit b0309ca

Please sign in to comment.