コード例 #1
0
        /// <summary>
        /// Creates a stack frame information payload to use in notifications
        /// </summary>
        /// <param name="frame">The stack frame to base the payload on</param>
        /// <param name="config">The configuration to use</param>
        /// <returns>The stack frame payload to use in notifications</returns>
        public static StackTraceFrameInfo GenerateStackTraceFrameInfo(StackFrame frame, Configuration config)
        {
            if (frame == null || config == null)
            {
                return(null);
            }

            // Get the filename the frame comes from without prefixes
            var file = config.RemoveFileNamePrefix(frame.GetFileName());

            // Mark the frame is In Project if we are autodetecting and there is a filename, or
            // the method comes from the configured project namespaces.
            var method    = frame.GetMethod();
            var inProject = (config.AutoDetectInProject && !string.IsNullOrEmpty(file)) ||
                            (method.DeclaringType != null && config.IsInProjectNamespace(method.DeclaringType.FullName));

            return(new StackTraceFrameInfo
            {
                File = file,
                LineNumber = frame.GetFileLineNumber(),
                Method = GenerateMethodSignature(method),
                InProject = inProject
            });
        }
コード例 #2
0
        /// <summary>
        /// Creates a stack frame information payload to use in notifications
        /// </summary>
        /// <param name="frame">The stack frame to base the payload on</param>
        /// <param name="config">The configuration to use</param>
        /// <returns>The stack frame payload to use in notifications</returns>
        public static StackTraceFrameInfo GenerateStackTraceFrameInfo(StackFrame frame, Configuration config)
        {
            if (frame == null || config == null)
                return null;

            // Get the filename the frame comes from without prefixes
            var file = config.RemoveFileNamePrefix(frame.GetFileName());

            // Mark the frame is In Project if we are autodetecting and there is a filename, or
            // the method comes from the configured project namespaces.
            var method = frame.GetMethod();
            var inProject = (config.AutoDetectInProject && !string.IsNullOrEmpty(file)) ||
                            (method.DeclaringType != null && config.IsInProjectNamespace(method.DeclaringType.FullName));

            return new StackTraceFrameInfo
            {
                File = file,
                LineNumber = frame.GetFileLineNumber(),
                Method = GenerateMethodSignature(method),
                InProject = inProject
            };
        }