コード例 #1
0
ファイル: ErrorFormatter.cs プロジェクト: wushian/dotvvm
        protected static IFrameMoreInfo CreateGithubLink(StackFrameModel frame)
        {
            const string GithubUrl = @"https://github.com/riganti/dotvvm/blob/master/src/";
            const string Octocat   = @"https://assets-cdn.github.com/favicon.ico";

            if (frame.Method?.DeclaringType?.GetTypeInfo()?.Assembly == typeof(ErrorFormatter).GetTypeInfo().Assembly)
            {
                // dotvvm github
                if (!string.IsNullOrEmpty(frame.At?.FileName))
                {
                    var fileName =
                        frame.At.FileName.Substring(
                            frame.At.FileName.LastIndexOf("DotVVM.Framework", StringComparison.Ordinal));
                    var url = GithubUrl + fileName.Replace('\\', '/').TrimStart('/') + "#L" + frame.At.LineNumber;
                    return(FrameMoreInfo.CreateThumbLink(url, Octocat));
                }
                else
                {
                    // guess by method name
                    var fileName = frame.Method.DeclaringType.FullName.Replace("DotVVM.Framework", "")
                                   .Replace('.', '/');
                    if (fileName.Contains("+"))
                    {
                        fileName = fileName.Remove(fileName.IndexOf('+')); // remove nested class
                    }
                    var url = GithubUrl + "DotVVM.Framework" + fileName + ".cs";
                    return(FrameMoreInfo.CreateThumbLink(url, Octocat));
                }
            }
            return(null);
        }
コード例 #2
0
ファイル: ErrorFormatter.cs プロジェクト: wushian/dotvvm
        protected static IFrameMoreInfo CreateReferenceSourceLink(StackFrameModel frame)
        {
            const string DotNetIcon = "http://referencesource.microsoft.com/favicon.ico";
            const string SourceUrl  = "http://referencesource.microsoft.com/";

            if (frame.Method?.DeclaringType?.GetTypeInfo()?.Assembly != null &&
                ReferenceSourceAssemblies.Contains(frame.Method.DeclaringType.GetTypeInfo().Assembly.GetName().Name))
            {
                if (!String.IsNullOrEmpty(frame.At?.FileName))
                {
                    throw new NotImplementedException();
                }
                else
                {
                    if (frame.Method.DeclaringType.GetTypeInfo().IsGenericType)
                    {
                        var url = SourceUrl + "#q=" +
                                  WebUtility.HtmlEncode(
                            GetGenericFullName(frame.Method.DeclaringType).Replace('+', '.'));
                        return(FrameMoreInfo.CreateThumbLink(url, DotNetIcon));
                    }
                    else
                    {
                        var url = SourceUrl + "#q=" +
                                  WebUtility.HtmlEncode(frame.Method.DeclaringType.FullName.Replace('+', '.') + "." +
                                                        frame.Method.Name);
                        return(FrameMoreInfo.CreateThumbLink(url, DotNetIcon));
                    }
                }
            }
            return(null);
        }
コード例 #3
0
        private StackFrameModel AddMoreInfo(StackFrameModel frame)
        {
            try
            {
                frame.MoreInfo = FrameInfoLoaders.Select(f => f(frame)).Where(f => f != null).ToArray();
            }
            catch { }

            return(frame);
        }
コード例 #4
0
ファイル: ErrorFormatter.cs プロジェクト: wushian/dotvvm
        protected static IFrameMoreInfo CreateDotvvmDocsLink(StackFrameModel frame)
        {
            const string DotvvmThumb = "https://dotvvm.com/Content/assets/ico/favicon.png";
            var          type        = frame.Method?.DeclaringType;

            if (type == null)
            {
                return(null);
            }
            while (type.DeclaringType != null)
            {
                type = type.DeclaringType;
            }
            if (type.Namespace == "DotVVM.Framework.Controls")
            {
                const string BuildinControlsDocs = "https://dotvvm.com/docs/controls/builtin/";
                var          url = BuildinControlsDocs + type.Name;
                return(FrameMoreInfo.CreateThumbLink(url, DotvvmThumb));
            }
            return(null);
        }