Browse Source

Add DecompilerSettings.OptionalArguments

pull/1218/merge
Siegfried Pammer 7 years ago
parent
commit
4776331277
  1. 4
      ICSharpCode.Decompiler/CSharp/CallBuilder.cs
  2. 17
      ICSharpCode.Decompiler/DecompilerSettings.cs

4
ICSharpCode.Decompiler/CSharp/CallBuilder.cs

@ -125,12 +125,12 @@ namespace ICSharpCode.Decompiler.CSharp @@ -125,12 +125,12 @@ namespace ICSharpCode.Decompiler.CSharp
// We only allow removing optional arguments in the following cases:
// - call arguments are not in expanded form
// - there are no named arguments
// This value has the following following values:
// This value has the following values:
// -2 - there are no optional arguments
// -1 - optional arguments are forbidden
// >= 0 - the index of the first argument that can be removed, because it is optional
// and is the default value of the parameter.
int firstOptionalArgumentIndex = -2;
int firstOptionalArgumentIndex = expressionBuilder.settings.OptionalArguments ? -2 : -1;
for (int i = firstParamIndex; i < callArguments.Count; i++) {
IParameter parameter;
if (argumentToParameterMap != null) {

17
ICSharpCode.Decompiler/DecompilerSettings.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler @@ -63,7 +63,7 @@ namespace ICSharpCode.Decompiler
if (languageVersion < CSharp.LanguageVersion.CSharp4) {
dynamic = false;
namedArguments = false;
// * optional arguments (not supported yet)
optionalArguments = false;
}
if (languageVersion < CSharp.LanguageVersion.CSharp5) {
asyncAwait = false;
@ -688,6 +688,21 @@ namespace ICSharpCode.Decompiler @@ -688,6 +688,21 @@ namespace ICSharpCode.Decompiler
}
}
bool optionalArguments = true;
/// <summary>
/// Gets/Sets whether optional arguments should be removed, if possible.
/// </summary>
public bool OptionalArguments {
get { return optionalArguments; }
set {
if (optionalArguments != value) {
optionalArguments = value;
OnPropertyChanged();
}
}
}
#region Options to aid VB decompilation
bool assumeArrayLengthFitsIntoInt32 = true;

Loading…
Cancel
Save