private static bool isCustomDirectQuery(CallingMethodInfo info) { return info.CallingMethod.Contains("ExecuteSqlCommand") || info.CallingMethod.Contains("ExecuteSqlQuery") || info.StackTrace.Contains("SessionImpl.ListCustomQuery"); }
private CallingMethodInfo getStackFrameInfo(StackFrame stackFrame, bool onlyIncludeInfoWithFileLine) { var methodInfo = new CallingMethodInfo { StackTrace = string.Empty }; if (stackFrame == null) return null; var method = stackFrame.GetMethod(); if (method == null) return null; method = getRealMethodFromAsyncMethod(method); var type = method.ReflectedType; if (type == null) return null; var assemblyName = method.Module.Assembly.GetName().Name; if (_assembliesToExclude.Contains(assemblyName) || _methodsToExclude.Contains(method.Name) || shouldExcludeType(method) || isMicrosoftType(method)) { if (!WontExcludeTypes) return null; } var methodString = method.ToString(); var returnName = string.Empty; var methodSignature = methodString; var splitIndex = methodString.IndexOf(' '); if (splitIndex > 0) { returnName = methodString.Substring(0, splitIndex); methodSignature = methodString.Substring(splitIndex + 1, methodString.Length - splitIndex - 1); } var typeNameFull = type.FullName; var lineNumber = stackFrame.GetFileLineNumber(); var fileLine = string.Empty; var filePath = stackFrame.GetFileName(); if (isTempFile(filePath)) return null; if (!string.IsNullOrEmpty(filePath)) { var fileName = Path.GetFileName(filePath); fileLine = string.Format("File={0}, Line={1}", fileName, lineNumber); methodInfo.CallingFile = fileName; methodInfo.CallingLine = lineNumber; methodInfo.CallingCol = stackFrame.GetFileColumnNumber(); methodInfo.CallingFileFullName = filePath; } //there is no valid .pdb file if (onlyIncludeInfoWithFileLine && !File.Exists(filePath)) return null; //couldn't extract the source file name if (onlyIncludeInfoWithFileLine && string.IsNullOrWhiteSpace(fileLine)) return null; var methodSignatureFull = string.Format("{0} {1}.{2}", returnName, typeNameFull, methodSignature); methodInfo.CallingMethod = method.Name; methodInfo.StackTrace = string.Format("{0}", methodSignatureFull); methodInfo.AssemblyName = type.Assembly.FullName; return methodInfo; }
protected virtual void OpenFile(CallingMethodInfo data) { if (data == null) return; new OpenStackTraceFile { Column = data.CallingCol, Line = data.CallingLine, FullFilename = data.CallingFileFullName }.ShowToUser(); }