Browse Source

Use 'ref', not 'out', for passing arguments to a method parameter declared as "[In, Out] ref".

pull/254/merge
Daniel Grunwald 14 years ago
parent
commit
f39f7c3d63
  1. 3
      ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs
  2. 9
      ICSharpCode.Decompiler/Tests/PInvoke.cs

3
ICSharpCode.Decompiler/Ast/AstMethodBodyBuilder.cs

@ -1012,7 +1012,8 @@ namespace ICSharpCode.Decompiler.Ast @@ -1012,7 +1012,8 @@ namespace ICSharpCode.Decompiler.Ast
// 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)
ParameterDefinition p = cecilMethod.Parameters[i];
if (dir != null && p.IsOut && !p.IsIn)
dir.FieldDirection = FieldDirection.Out;
}
}

9
ICSharpCode.Decompiler/Tests/PInvoke.cs

@ -84,4 +84,13 @@ public class PInvoke @@ -84,4 +84,13 @@ public class PInvoke
public void CustomMarshal2([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "MyCompany.MyMarshaler", MarshalCookie = "Cookie")] object o)
{
}
[DllImport("ws2_32.dll", SetLastError = true)]
internal static extern IntPtr ioctlsocket([In] IntPtr socketHandle, [In] int cmd, [In] [Out] ref int argp);
public void CallMethodWithInOutParameter()
{
int num = 0;
PInvoke.ioctlsocket(IntPtr.Zero, 0, ref num);
}
}

Loading…
Cancel
Save