Jelajahi Sumber

Fixing callstack logging

Source commit: de9db7c0ed0a16ff1644f895771ce5dfba3172a3
Martin Prikryl 5 tahun lalu
induk
melakukan
3db1c28414
1 mengubah file dengan 7 tambahan dan 2 penghapusan
  1. 7 2
      dotnet/internal/Callstack.cs

+ 7 - 2
dotnet/internal/Callstack.cs

@@ -21,8 +21,8 @@ namespace WinSCP
                 {
                     StackFrame frame = stackTrace.GetFrame(i);
                     method = frame.GetMethod();
-                    if ((method.IsConstructor && ((method.DeclaringType == type) || method.DeclaringType.IsSubclassOf(type))) ||
-                        ((method.MemberType == MemberTypes.Method) && ((MethodInfo)method).ReturnType == type))
+                    if ((method.IsConstructor && IsTypeOrSubType(method.DeclaringType, type)) ||
+                        ((method.MemberType == MemberTypes.Method) && IsTypeOrSubType(((MethodInfo)method).ReturnType, type)))
                     {
                         method = null;
                     }
@@ -47,6 +47,11 @@ namespace WinSCP
             }
         }
 
+        private static bool IsTypeOrSubType(Type tested, Type type)
+        {
+            return (tested == type) || tested.IsSubclassOf(type);
+        }
+
         public virtual void Dispose()
         {
             if (_name != null)