فهرست منبع

Fixing callstack logging

(cherry picked from commit 3db1c2841486af0dc9d44ad76f5ff38b33ddbf2a)

Source commit: 2a6ee99fa576a0a86eb08c876c2456f6dc1bbde0
Martin Prikryl 5 سال پیش
والد
کامیت
e0c8c2f8ec
1فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  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)