Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 22, 2023. It is now read-only.
/pythonnetPublic archive
forked frompythonnet/pythonnet

Commit4692e68

Browse files
omnicognatetom
authored and
tom
committed
Fix forpythonnet#200 - check for params array args correctly
1 parentbc414e1 commit4692e68

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

‎src/runtime/methodbinder.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,8 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
269269
defaultArgList.Add((object)pi[v].DefaultValue);
270270
}
271271
}elseif((pynargs>clrnargs)&&(clrnargs>0)&&
272-
(pi[clrnargs-1].ParameterType.IsArray)){
273-
// The last argument of the mananged functions seems to
274-
// accept multiple arguments as a array. Hopefully it's a
275-
// spam(params object[] egg) style method
272+
Attribute.IsDefined(pi[clrnargs-1],typeof(ParamArrayAttribute))){
273+
// This is a spam(params object[] egg) style method
276274
match=true;
277275
arrayStart=clrnargs-1;
278276
}

‎src/testing/methodtest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ public static bool TestStringRefParams (string s, ref string s1) {
117117
returntrue;
118118
}
119119

120+
publicstaticboolTestNonParamsArrayInLastPlace(inti1,int[]i2){
121+
returnfalse;
122+
}
123+
124+
publicstaticboolTestNonParamsArrayInLastPlace(inti1,inti2,inti3){
125+
returntrue;
126+
}
127+
120128
publicstaticboolTestValueOutParams(strings,outinti1){
121129
i1=42;
122130
returntrue;

‎src/tests/test_method.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ def testValueParamsArgs(self):
304304
self.assertTrue(result[1]==2)
305305
self.assertTrue(result[2]==3)
306306

307+
deftestNonParamsArrayInLastPlace(self):
308+
"""Test overload resolution with of non-"params" array as last parameter."""
309+
result=MethodTest.TestNonParamsArrayInLastPlace(1,2,3)
310+
self.assertTrue(result)
307311

308312
deftestStringOutParams(self):
309313
"""Test use of string out-parameters."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp