Browse Source

Use 'out' instead of 'ref' when calling a method with an out-parameter. Closes #57.

pull/70/head
Daniel Grunwald 14 years ago
parent
commit
b84ba59c68
  1. 11
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 1
      ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj

11
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -703,9 +703,20 @@ namespace Decompiler
} }
} }
// Default invocation // Default invocation
AdjustArgumentsForMethodCall(cecilMethod, methodArgs);
return target.Invoke(cecilMethod.Name, ConvertTypeArguments(cecilMethod), methodArgs).WithAnnotation(cecilMethod); return target.Invoke(cecilMethod.Name, ConvertTypeArguments(cecilMethod), methodArgs).WithAnnotation(cecilMethod);
} }
static void AdjustArgumentsForMethodCall(MethodReference cecilMethod, List<Expression> methodArgs)
{
// Convert 'ref' into 'out' where necessary
for (int i = 0; i < methodArgs.Count && i < cecilMethod.Parameters.Count; i++) {
DirectionExpression dir = methodArgs[i] as DirectionExpression;
if (dir != null && cecilMethod.Parameters[i].IsOut)
dir.FieldDirection = FieldDirection.Out;
}
}
static PropertyDefinition GetIndexer(MethodDefinition cecilMethodDef) static PropertyDefinition GetIndexer(MethodDefinition cecilMethodDef)
{ {
TypeDefinition typeDef = cecilMethodDef.DeclaringType; TypeDefinition typeDef = cecilMethodDef.DeclaringType;

1
ICSharpCode.Decompiler/Tests/ICSharpCode.Decompiler.Tests.csproj

@ -13,6 +13,7 @@
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<NoWarn>67,169</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> <PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>

Loading…
Cancel
Save