From 0f7a07c6fa3b087537f49a505a8310479aa004d9 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 2 Jan 2018 16:27:29 +0100 Subject: [PATCH] [Java.Interop] Rename methods with '_' in their names This was catched by gendarme's https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Naming.UseCorrectCasingRule%282.10%29 --- src/Java.Interop/Java.Interop/JavaArray.cs | 4 +-- .../Java.Interop/JavaException.cs | 16 +++++----- .../Java.Interop/JavaObjectArray.cs | 6 ++-- .../Java.Interop/JavaPrimitiveArrays.cs | 32 +++++++++---------- .../Java.Interop/JavaProxyObject.cs | 13 ++++---- .../Java.Interop/JavaProxyThrowable.cs | 4 +-- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/Java.Interop/Java.Interop/JavaArray.cs b/src/Java.Interop/Java.Interop/JavaArray.cs index 2be6a6c13..8efd6b04f 100644 --- a/src/Java.Interop/Java.Interop/JavaArray.cs +++ b/src/Java.Interop/Java.Interop/JavaArray.cs @@ -89,7 +89,7 @@ internal static int CheckLength (IList value) return value.Count; } - internal static IList _ToList (IEnumerable value) + internal static IList ToList (IEnumerable value) { if (value == null) throw new ArgumentNullException ("value"); @@ -376,7 +376,7 @@ public override void CopyTo (T[] array, int arrayIndex) CopyTo (0, array, arrayIndex, Length); } - internal static T[] _ToArray (IEnumerable value) + internal static T[] ToArray (IEnumerable value) { var array = value as T[]; if (array != null) diff --git a/src/Java.Interop/Java.Interop/JavaException.cs b/src/Java.Interop/Java.Interop/JavaException.cs index 624502a4e..d4d5c93fe 100644 --- a/src/Java.Interop/Java.Interop/JavaException.cs +++ b/src/Java.Interop/Java.Interop/JavaException.cs @@ -37,7 +37,7 @@ public unsafe JavaException () var peer = JniPeerMembers.InstanceMethods.StartCreateInstance ("()V", GetType (), null); Construct (ref peer, JniObjectReferenceOptions.CopyAndDispose); JniPeerMembers.InstanceMethods.FinishCreateInstance ("()V", this, null); - javaStackTrace = _GetJavaStack (PeerReference); + javaStackTrace = GetJavaStack (PeerReference); } public unsafe JavaException (string message) @@ -54,7 +54,7 @@ public unsafe JavaException (string message) } finally { JniObjectReference.Dispose (ref native_message, JniObjectReferenceOptions.CopyAndDispose); } - javaStackTrace = _GetJavaStack (PeerReference); + javaStackTrace = GetJavaStack (PeerReference); } public unsafe JavaException (string message, Exception innerException) @@ -71,15 +71,15 @@ public unsafe JavaException (string message, Exception innerException) } finally { JniObjectReference.Dispose (ref native_message, JniObjectReferenceOptions.CopyAndDispose); } - javaStackTrace = _GetJavaStack (PeerReference); + javaStackTrace = GetJavaStack (PeerReference); } public JavaException (ref JniObjectReference reference, JniObjectReferenceOptions transfer) - : base (_GetMessage (ref reference, transfer), _GetCause (ref reference, transfer)) + : base (GetMessage (ref reference, transfer), GetCause (ref reference, transfer)) { Construct (ref reference, transfer); if (PeerReference.IsValid) - javaStackTrace = _GetJavaStack (PeerReference); + javaStackTrace = GetJavaStack (PeerReference); } protected void Construct (ref JniObjectReference reference, JniObjectReferenceOptions options) @@ -186,7 +186,7 @@ public override unsafe int GetHashCode () return _members.InstanceMethods.InvokeVirtualInt32Method ("hashCode.()I", this, null); } - static string _GetMessage (ref JniObjectReference reference, JniObjectReferenceOptions transfer) + static string GetMessage (ref JniObjectReference reference, JniObjectReferenceOptions transfer) { if (transfer == JniObjectReferenceOptions.None) return null; @@ -196,7 +196,7 @@ static string _GetMessage (ref JniObjectReference reference, JniObjectReferenceO return JniEnvironment.Strings.ToString (ref s, JniObjectReferenceOptions.CopyAndDispose); } - static Exception _GetCause (ref JniObjectReference reference, JniObjectReferenceOptions transfer) + static Exception GetCause (ref JniObjectReference reference, JniObjectReferenceOptions transfer) { if (transfer == JniObjectReferenceOptions.None) return null; @@ -206,7 +206,7 @@ static Exception _GetCause (ref JniObjectReference reference, JniObjectReference return JniEnvironment.Runtime.GetExceptionForThrowable (ref e, JniObjectReferenceOptions.CopyAndDispose); } - unsafe string _GetJavaStack (JniObjectReference handle) + unsafe string GetJavaStack (JniObjectReference handle) { using (var StringWriter_class = new JniType ("java/io/StringWriter")) using (var PrintWriter_class = new JniType ("java/io/PrintWriter")) { diff --git a/src/Java.Interop/Java.Interop/JavaObjectArray.cs b/src/Java.Interop/Java.Interop/JavaObjectArray.cs index 7bb337543..65ff8646d 100644 --- a/src/Java.Interop/Java.Interop/JavaObjectArray.cs +++ b/src/Java.Interop/Java.Interop/JavaObjectArray.cs @@ -11,7 +11,7 @@ public JavaObjectArray (ref JniObjectReference handle, JniObjectReferenceOptions { } - static JniObjectReference _NewArray (int length) + static JniObjectReference NewArray (int length) { var info = JniEnvironment.Runtime.TypeManager.GetTypeSignature (typeof (T)); if (info.SimpleReference == null) @@ -27,7 +27,7 @@ static JniObjectReference _NewArray (int length) public unsafe JavaObjectArray (int length) : this (ref *InvalidJniObjectReference, JniObjectReferenceOptions.None) { - var peer = _NewArray (CheckLength (length)); + var peer = NewArray (CheckLength (length)); Construct (ref peer, JniObjectReferenceOptions.CopyAndDispose); } @@ -39,7 +39,7 @@ public JavaObjectArray (IList value) } public JavaObjectArray (IEnumerable value) - : this (_ToList (value)) + : this (ToList (value)) { } diff --git a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs index e510f0688..a31ba0cb5 100644 --- a/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs +++ b/src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs @@ -102,11 +102,11 @@ public unsafe JavaBooleanArray (int length) public JavaBooleanArray (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaBooleanArray (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -249,11 +249,11 @@ public unsafe JavaSByteArray (int length) public JavaSByteArray (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaSByteArray (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -396,11 +396,11 @@ public unsafe JavaCharArray (int length) public JavaCharArray (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaCharArray (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -543,11 +543,11 @@ public unsafe JavaInt16Array (int length) public JavaInt16Array (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaInt16Array (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -690,11 +690,11 @@ public unsafe JavaInt32Array (int length) public JavaInt32Array (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaInt32Array (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -837,11 +837,11 @@ public unsafe JavaInt64Array (int length) public JavaInt64Array (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaInt64Array (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -984,11 +984,11 @@ public unsafe JavaSingleArray (int length) public JavaSingleArray (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaSingleArray (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } @@ -1131,11 +1131,11 @@ public unsafe JavaDoubleArray (int length) public JavaDoubleArray (System.Collections.Generic.IList value) : this (CheckLength (value)) { - CopyFrom (_ToArray (value), 0, 0, value.Count); + CopyFrom (ToArray (value), 0, 0, value.Count); } public JavaDoubleArray (System.Collections.Generic.IEnumerable value) - : this (_ToArray (value)) + : this (ToArray (value)) { } diff --git a/src/Java.Interop/Java.Interop/JavaProxyObject.cs b/src/Java.Interop/Java.Interop/JavaProxyObject.cs index 69236df30..84072fb0f 100644 --- a/src/Java.Interop/Java.Interop/JavaProxyObject.cs +++ b/src/Java.Interop/Java.Interop/JavaProxyObject.cs @@ -14,9 +14,9 @@ sealed class JavaProxyObject : JavaObject [JniAddNativeMethodRegistrationAttribute] static void RegisterNativeMembers (JniNativeMethodRegistrationArguments args) { - args.Registrations.Add (new JniNativeMethodRegistration ("equals", "(Ljava/lang/Object;)Z", (Func)_Equals)); - args.Registrations.Add (new JniNativeMethodRegistration ("hashCode", "()I", (Func)_GetHashCode)); - args.Registrations.Add (new JniNativeMethodRegistration ("toString", "()Ljava/lang/String;", (Func)_ToString)); + args.Registrations.Add (new JniNativeMethodRegistration ("equals", "(Ljava/lang/Object;)Z", (Func)Equals)); + args.Registrations.Add (new JniNativeMethodRegistration ("hashCode", "()I", (Func)GetHashCode)); + args.Registrations.Add (new JniNativeMethodRegistration ("toString", "()Ljava/lang/String;", (Func)ToString)); } public override JniPeerMembers JniPeerMembers { @@ -68,7 +68,7 @@ public static JavaProxyObject GetProxy (object value) } // TODO: Keep in sync with the code generated by ExportedMemberBuilder - static bool _Equals (IntPtr jnienv, IntPtr n_self, IntPtr n_value) + static bool Equals (IntPtr jnienv, IntPtr n_self, IntPtr n_value) { var envp = new JniTransition (jnienv); try { @@ -87,7 +87,7 @@ static bool _Equals (IntPtr jnienv, IntPtr n_self, IntPtr n_value) } // TODO: Keep in sync with the code generated by ExportedMemberBuilder - static int _GetHashCode (IntPtr jnienv, IntPtr n_self) + static int GetHashCode (IntPtr jnienv, IntPtr n_self) { var envp = new JniTransition (jnienv); try { @@ -103,7 +103,7 @@ static int _GetHashCode (IntPtr jnienv, IntPtr n_self) } } - static IntPtr _ToString (IntPtr jnienv, IntPtr n_self) + static IntPtr ToString (IntPtr jnienv, IntPtr n_self) { var envp = new JniTransition (jnienv); try { @@ -126,4 +126,3 @@ static IntPtr _ToString (IntPtr jnienv, IntPtr n_self) } } } - diff --git a/src/Java.Interop/Java.Interop/JavaProxyThrowable.cs b/src/Java.Interop/Java.Interop/JavaProxyThrowable.cs index 7c8f640e4..b66113526 100644 --- a/src/Java.Interop/Java.Interop/JavaProxyThrowable.cs +++ b/src/Java.Interop/Java.Interop/JavaProxyThrowable.cs @@ -10,12 +10,12 @@ sealed class JavaProxyThrowable : JavaException public Exception Exception {get; private set;} public JavaProxyThrowable (Exception exception) - : base (_GetMessage (exception)) + : base (GetMessage (exception)) { Exception = exception; } - static string _GetMessage (Exception exception) + static string GetMessage (Exception exception) { if (exception == null) throw new ArgumentNullException ("exception");