Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions gendarme-ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ M: Java.Interop.JniObjectReferenceType Java.Interop.JniEnvironment/References::G
M: Java.Interop.JniObjectReference Java.Interop.JniEnvironment/Reflection::ToReflectedMethod(Java.Interop.JniObjectReference,Java.Interop.JniMethodInfo,System.Boolean)
M: Java.Interop.JniObjectReference Java.Interop.JniEnvironment/Reflection::ToReflectedField(Java.Interop.JniObjectReference,Java.Interop.JniFieldInfo,System.Boolean)
M: Java.Interop.JniObjectReferenceFlags Java.Interop.JniObjectReference::get_Flags()
# This method is used in Java.Interop.GenericMarshaler.dll, the internals are visible to this assembly. Looks like gendarme doesn't know InternalsVisibleTo attribute.
M: Java.Interop.JniObjectReference Java.Interop.JniPeerMembers/JniInstanceMethods::AllocObject(System.Type)

# I think Gendarme is buggy here; `JavaArray<T>.CheckLength(IList<T>)` *is* used.
M: System.Int32 Java.Interop.JavaArray`1::CheckLength(System.Collections.Generic.IList`1<T>)
Expand All @@ -557,3 +559,12 @@ R: Gendarme.Rules.Performance.UseTypeEmptyTypesRule
# The PCL profile we're using doen't *have* Type.EmptyTypes!
M: System.Void Java.Interop.JniRuntime/JniTypeManager::.cctor()

R: Gendarme.Rules.BadPractice.CheckNewExceptionWithoutThrowingRule
# This method constructs JavaException and calls ToString () on it. We only care about Java stack trace here, so we don't need to throw the exception to get managed StackTrace.
M: System.Exception Java.Interop.ManagedPeer::CreateJniLocationException()
# This method uses a JavaException and passes its PeerReference property along. We don't want to throw that property.
M: System.Void Java.Interop.JniEnvironment/Exceptions::Throw(System.Exception)

R: Gendarme.Rules.Correctness.DisposableFieldsShouldBeDisposedRule
# We call Dispose on marshalMemberBuilder field in the JniRuntime::Dispose method. Looks like gendarme bug, it doesn't handle well the `?.` operator.
T: Java.Interop.JniRuntime
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniEnvironment.Errors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static void ThrowNew (JniObjectReference klass, string message)
public static void Throw (Exception e)
{
if (e == null)
throw new ArgumentNullException ("e");
throw new ArgumentNullException (nameof (e));
var je = e as JavaException;
if (je == null) {
je = new JavaProxyThrowable (e);
Expand Down
10 changes: 3 additions & 7 deletions src/Java.Interop/Java.Interop/JniRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,12 @@ partial class JniRuntime {

public virtual void RaisePendingException (Exception pendingException)
{
#if XA_INTEGRATION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why move this line? Don't we always want to throw ArgumentNullException if pendingException is null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (pendingException == null)
throw new ArgumentNullException (nameof (pendingException));
#if XA_INTEGRATION
throw new NotSupportedException ("Do not know how to marshal System.Exception instances.");
#else // XA_INTEGRATION
var je = pendingException as JavaException;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why any of this code is being removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (je == null) {
je = new JavaProxyThrowable (pendingException);
}
JniEnvironment.Exceptions.Throw (je.PeerReference);
#else // !XA_INTEGRATION
JniEnvironment.Exceptions.Throw (pendingException);
#endif // !XA_INTEGRATION
}
}
Expand Down