diff --git a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs index 87b9e4651..796b1bffa 100644 --- a/ICSharpCode.Decompiler/CSharp/CallBuilder.cs +++ b/ICSharpCode.Decompiler/CSharp/CallBuilder.cs @@ -593,7 +593,7 @@ namespace ICSharpCode.Decompiler.CSharp parameter = method.Parameters[i - firstParamIndex]; } var arg = expressionBuilder.Translate(callArguments[i], parameter.Type); - if (IsPrimitiveValueThatShouldHaveNamedArgument(arg, method)) { + if (IsPrimitiveValueThatShouldBeNamedArgument(arg, method)) { isPrimitiveValue.Set(arguments.Count); } if (IsOptionalArgument(parameter, arg)) { @@ -644,7 +644,7 @@ namespace ICSharpCode.Decompiler.CSharp return list; } - private bool IsPrimitiveValueThatShouldHaveNamedArgument(TranslatedExpression arg, IMethod method) + private bool IsPrimitiveValueThatShouldBeNamedArgument(TranslatedExpression arg, IMethod method) { if (!arg.ResolveResult.IsCompileTimeConstant || method.DeclaringType.IsKnownType(KnownTypeCode.NullableOfT)) return false; @@ -714,8 +714,10 @@ namespace ICSharpCode.Decompiler.CSharp || a.AttributeType.IsKnownType(KnownAttribute.CallerFilePath) || a.AttributeType.IsKnownType(KnownAttribute.CallerLineNumber))) return false; - return (parameter.ConstantValue == null && arg.ResolveResult.ConstantValue == null) - || (parameter.ConstantValue != null && parameter.ConstantValue.Equals(arg.ResolveResult.ConstantValue)); + if (parameter.ConstantValue == null) + return arg.ResolveResult.ConstantValue == null; + arg = arg.ConvertTo(parameter.Type, expressionBuilder, allowImplicitConversion: true); + return parameter.ConstantValue.Equals(arg.ResolveResult.ConstantValue); } [Flags] diff --git a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs index 070081d8f..bbba0455b 100644 --- a/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs +++ b/ICSharpCode.Decompiler/TypeSystem/TypeSystemExtensions.cs @@ -216,7 +216,7 @@ namespace ICSharpCode.Decompiler.TypeSystem /// /// Gets whether the type is the specified known type. - /// For generic known types, this returns true any parameterization of the type (and also for the definition itself). + /// For generic known types, this returns true for any parameterization of the type (and also for the definition itself). /// public static bool IsKnownType(this IType type, KnownTypeCode knownType) { @@ -226,7 +226,7 @@ namespace ICSharpCode.Decompiler.TypeSystem /// /// Gets whether the type is the specified known type. - /// For generic known types, this returns true any parameterization of the type (and also for the definition itself). + /// For generic known types, this returns true for any parameterization of the type (and also for the definition itself). /// internal static bool IsKnownType(this IType type, KnownAttribute knownType) {