summaryrefslogtreecommitdiff
path: root/Lib/csharp
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-04-09 19:15:12 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-04-09 19:35:00 +0100
commit00528a1ef68dc2adbe3c34c23e9841a0715c428b (patch)
tree0274b44769f7a3de0c43feebd792ab24a53f0ea4 /Lib/csharp
parentd6746379a1d63b9c588d9642cd1d0d6608629e20 (diff)
downloadswig-00528a1ef68dc2adbe3c34c23e9841a0715c428b.tar.gz
Fix C# wrappers FxCop warning CA2002 in SWIGPendingException
Fixes two warnings in each wrapper: warning : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Retrieve()' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity. warning : CA2002 : Microsoft.Reliability : 'examplePINVOKE.SWIGPendingException.Set(Exception)' locks on a reference of type 'Type'. Replace this with a lock against an object with strong-identity. Use lock statement advice not to use typeof for locks, see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/lock-statement
Diffstat (limited to 'Lib/csharp')
-rw-r--r--Lib/csharp/csharphead.swg9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg
index 0b55635b3..7db4c0e3c 100644
--- a/Lib/csharp/csharphead.swg
+++ b/Lib/csharp/csharphead.swg
@@ -244,6 +244,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
[global::System.ThreadStatic]
private static global::System.Exception pendingException = null;
private static int numExceptionsPending = 0;
+ private static global::System.Object exceptionsLock = null;
public static bool Pending {
get {
@@ -259,7 +260,7 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
if (pendingException != null)
throw new global::System.ApplicationException("FATAL: An earlier pending exception from unmanaged code was missed and thus not thrown (" + pendingException.ToString() + ")", e);
pendingException = e;
- lock(typeof($imclassname)) {
+ lock(exceptionsLock) {
numExceptionsPending++;
}
}
@@ -270,13 +271,17 @@ SWIGEXPORT void SWIGSTDCALL SWIGRegisterExceptionArgumentCallbacks_$module(
if (pendingException != null) {
e = pendingException;
pendingException = null;
- lock(typeof($imclassname)) {
+ lock(exceptionsLock) {
numExceptionsPending--;
}
}
}
return e;
}
+
+ static SWIGPendingException() {
+ exceptionsLock = new global::System.Object();
+ }
}
%}
#endif // SWIG_CSHARP_NO_EXCEPTION_HELPER