Skip to content
Permalink
Browse files

Fix #1180: Fix generation of Windows Forms InitializeComponent.

  • Loading branch information...
siegfriedpammer committed Mar 8, 2019
1 parent 4987f78 commit b0309ca9e3be2e35949f6b6bc0ae6ff234636fd5
@@ -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);
}
@@ -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) {
@@ -649,7 +649,7 @@ int Next()
list.IsExpandedForm = isExpandedForm;
list.IsPrimitiveValue = isPrimitiveValue;
list.FirstOptionalArgumentIndex = firstOptionalArgumentIndex;
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NonTrailingNamedArguments;
list.AddNamesToPrimitiveValues = expressionBuilder.settings.NamedArguments && expressionBuilder.settings.NonTrailingNamedArguments;
return list;
}

@@ -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)

0 comments on commit b0309ca

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.