Skip to content

Commit 27c7bf4

Browse files
authored
[invocation-overhead] Fix CS0436 warnings (#805)
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4466540&view=logs&j=f31c9f97-4411-58e7-49ac-fc73f645e6b6&t=cbeb8522-7b64-5cc0-7bee-eff0e164a409 Commit 2a299eb accidentally introduced ~650 warnings to the build: tests\invocation-overhead\jni.cs(5756,24): Warning CS0436: The type 'JniFieldInfo' in 'D:\a\1\s\tests\invocation-overhead\invocation-overhead.cs' conflicts with the imported type 'JniFieldInfo' in 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. Using the type defined in 'D:\a\1\s\tests\invocation-overhead\invocation-overhead.cs'. This was because commit 2a299eb added a declaration for `JniFieldInfo` and `JniMethodInfo` in the `Java.Interop` namespace within `invocation-overhead.cs`. Fix the warnings by moving the `JniFieldInfo` and `JniMethodInfo` declarations into the "per-handle-type" sub-namespaces.
1 parent 89a5a22 commit 27c7bf4

File tree

1 file changed

+81
-45
lines changed

1 file changed

+81
-45
lines changed

tests/invocation-overhead/invocation-overhead.cs

Lines changed: 81 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,52 @@
1010
using PinvokeEnv = Java.Interop.JIPinvokes.JniEnvironment;
1111
using XAIntPtrEnv = Java.Interop.XAIntPtrs.JniEnvironment;
1212

13+
public class XFieldInfo
14+
{
15+
public IntPtr ID;
16+
public bool IsStatic;
17+
public bool IsValid {get {return ID != IntPtr.Zero;}}
18+
public XFieldInfo (string name, string signature, IntPtr id, bool isStatic)
19+
{
20+
ID = id;
21+
IsStatic = isStatic;
22+
}
23+
public override string ToString ()
24+
{
25+
return string.Format ("{0}(0x{1})", GetType ().FullName, ID.ToString ("x"));
26+
}
27+
}
28+
29+
public class XMethodInfo
30+
{
31+
public IntPtr ID;
32+
public bool IsStatic;
33+
public bool IsValid {get {return ID != IntPtr.Zero;}}
34+
public XMethodInfo (string name, string signature, IntPtr id, bool isStatic)
35+
{
36+
ID = id;
37+
IsStatic = isStatic;
38+
}
39+
public override string ToString ()
40+
{
41+
return string.Format ("{0}(0x{1})", GetType ().FullName, ID.ToString ("x"));
42+
}
43+
}
44+
45+
1346
namespace Java.Interop.SafeHandles {
47+
public class JniFieldInfo : XFieldInfo {
48+
public JniFieldInfo (string name, string signature, IntPtr id, bool isStatic)
49+
: base (name, signature, id, isStatic)
50+
{
51+
}
52+
}
53+
public class JniMethodInfo : XMethodInfo {
54+
public JniMethodInfo (string name, string signature, IntPtr id, bool isStatic)
55+
: base (name, signature, id, isStatic)
56+
{
57+
}
58+
}
1459
public struct JniObjectReference
1560
{
1661
public JniReferenceSafeHandle SafeHandle {get; private set;}
@@ -195,6 +240,18 @@ public static Exception GetExceptionForLastThrowable ()
195240
}
196241

197242
namespace Java.Interop.JIIntPtrs {
243+
public class JniFieldInfo : XFieldInfo {
244+
public JniFieldInfo (string name, string signature, IntPtr id, bool isStatic)
245+
: base (name, signature, id, isStatic)
246+
{
247+
}
248+
}
249+
public class JniMethodInfo : XMethodInfo {
250+
public JniMethodInfo (string name, string signature, IntPtr id, bool isStatic)
251+
: base (name, signature, id, isStatic)
252+
{
253+
}
254+
}
198255
public struct JniObjectReference
199256
{
200257
public IntPtr Handle {get; private set;}
@@ -236,6 +293,18 @@ public static Exception GetExceptionForLastThrowable ()
236293
}
237294

238295
namespace Java.Interop.JIPinvokes {
296+
public class JniFieldInfo : XFieldInfo {
297+
public JniFieldInfo (string name, string signature, IntPtr id, bool isStatic)
298+
: base (name, signature, id, isStatic)
299+
{
300+
}
301+
}
302+
public class JniMethodInfo : XMethodInfo {
303+
public JniMethodInfo (string name, string signature, IntPtr id, bool isStatic)
304+
: base (name, signature, id, isStatic)
305+
{
306+
}
307+
}
239308
public struct JniObjectReference
240309
{
241310
public IntPtr Handle {get; private set;}
@@ -282,6 +351,18 @@ public static Exception GetExceptionForLastThrowable ()
282351
}
283352
}
284353
namespace Java.Interop.XAIntPtrs {
354+
public class JniFieldInfo : XFieldInfo {
355+
public JniFieldInfo (string name, string signature, IntPtr id, bool isStatic)
356+
: base (name, signature, id, isStatic)
357+
{
358+
}
359+
}
360+
public class JniMethodInfo : XMethodInfo {
361+
public JniMethodInfo (string name, string signature, IntPtr id, bool isStatic)
362+
: base (name, signature, id, isStatic)
363+
{
364+
}
365+
}
285366
public struct JniObjectReference
286367
{
287368
public IntPtr Handle {get; private set;}
@@ -321,51 +402,6 @@ public static Exception GetExceptionForLastThrowable ()
321402
}
322403
}
323404

324-
namespace Java.Interop {
325-
public sealed class JniFieldInfo
326-
{
327-
public IntPtr ID;
328-
public bool IsStatic;
329-
public bool IsValid {get {return ID != IntPtr.Zero;}}
330-
331-
public JniFieldInfo (IntPtr id, bool isStatic)
332-
{
333-
ID = id;
334-
IsStatic = isStatic;
335-
}
336-
public JniFieldInfo (string name, string signature, IntPtr id, bool isStatic)
337-
{
338-
ID = id;
339-
IsStatic = isStatic;
340-
}
341-
342-
public override string ToString ()
343-
{
344-
return string.Format ("{0}(0x{1})", GetType ().FullName, ID.ToString ("x"));
345-
}
346-
}
347-
public class JniMethodInfo
348-
{
349-
public IntPtr ID;
350-
public bool IsStatic;
351-
public bool IsValid {get {return ID != IntPtr.Zero;}}
352-
public JniMethodInfo (IntPtr id, bool isStatic)
353-
{
354-
ID = id;
355-
IsStatic = isStatic;
356-
}
357-
public JniMethodInfo (string name, string signature, IntPtr id, bool isStatic)
358-
{
359-
ID = id;
360-
IsStatic = isStatic;
361-
}
362-
public override string ToString ()
363-
{
364-
return string.Format ("{0}(0x{1})", GetType ().FullName, ID.ToString ("x"));
365-
}
366-
}
367-
}
368-
369405
class App {
370406

371407
public static void Main ()

0 commit comments

Comments
 (0)