コード例 #1
0
        private SourceRow MapRow(ISourceMapProvider sourceMapProvider, SourceRow src)
        {
            var sourceMap = sourceMapProvider.Get(src.File);

            if (sourceMap == null)
            {
                return(src);
            }

            if (src.Line == null)
            {
                return(src);
            }

            if (src.Column == null)
            {
                return(src);
            }

            var position = sourceMap.OriginalPositionFor((int)src.Line, (int)src.Column);

            return(new SourceRow
            {
                Line = position.Line,
                Column = position.Column,
                File = position.Source,
                Symbol = position.Name
            });
        }
コード例 #2
0
        /// <summary>
        /// Creates a StackTraceDeminifier that only deminifies the method names. StackTrace deminifiers created with this method will use significantly less memory during runtime than the
        /// </summary>
        /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
        /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
        /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param>
        public static StackTraceDeminifier GetMethodNameOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser)
        {
            ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser);

            SourceMapParser       sourceMapParser      = new SourceMapParser();
            IStackFrameDeminifier stackFrameDeminifier = new MethodNameStackFrameDeminifier(new FunctionMapStore(generatedCodeProvider, (url) => sourceMapParser.ParseSourceMap(sourceMapProvider.GetSourceMapContentsForCallstackUrl(url))), new FunctionMapConsumer());

            return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser));
        }
コード例 #3
0
        public static StackTraceDeminifier GetStackTraceDeminfier(ISourceMapProvider sourceMapProvider)
        {
            var sourceMapStore       = new SourceMapStore(sourceMapProvider);
            var stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore);

            var stackTraceParser = new StackTraceParser();

            return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser));
        }
コード例 #4
0
        public Crash Process(Crash crash)
        {
            var appVersion = crash.Version;

            ISourceMapProvider providerOnVersion = _sourceMapProvider.GetByApplicationVersion(crash.Application.Key, appVersion);

            crash.StackTrace = _stackTraceBeautifier.Beautify(providerOnVersion, crash.StackTrace);

            return(crash);
        }
コード例 #5
0
        /// <summary>
        /// Creates a StackTraceDeminifier with full capabilities. StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier.
        /// </summary>
        /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
        /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
        /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param>
        public static StackTraceDeminifier GetStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser)
        {
            ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser);

            ISourceMapStore       sourceMapStore       = new SourceMapStore(sourceMapProvider);
            IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore,
                                                                                  new FunctionMapStore(generatedCodeProvider, sourceMapStore.GetSourceMapForUrl), new FunctionMapConsumer());

            return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser));
        }
        private StackTraceDeminifier GetStackTraceDeminifierWithDependencies()
        {
            ISourceMapProvider sourceMapProvider = MockRepository.GenerateStrictMock <ISourceMapProvider>();

            sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/crashcauser.min.js")).Return(UnitTestUtils.StreamReaderFromString(SourceMapString));

            ISourceCodeProvider sourceCodeProvider = MockRepository.GenerateStrictMock <ISourceCodeProvider>();

            sourceCodeProvider.Stub(x => x.GetSourceCode("http://localhost:11323/crashcauser.min.js")).Return(UnitTestUtils.StreamReaderFromString(GeneratedCodeString));

            return(StackTraceDeminfierFactory.GetMapOnlyStackTraceDeminfier(sourceMapProvider));
        }
コード例 #7
0
        private static void ValidateArguments(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider)
        {
            if (sourceMapProvider == null)
            {
                throw new ArgumentNullException(nameof(sourceMapProvider));
            }

            if (generatedCodeProvider == null)
            {
                throw new ArgumentNullException(nameof(generatedCodeProvider));
            }
        }
コード例 #8
0
        public string Beautify(ISourceMapProvider sourceMapProvider, string src)
        {
            var sb = new StringBuilder();

            var rows = ParseStackTrace(src);

            rows = rows
                   .Select(x => MapRow(sourceMapProvider, x));

            foreach (var row in rows)
            {
                sb.Append($"{row.File} [{row.Line}, {row.Column}]\r\n");
            }

            return(sb.ToString());
        }
コード例 #9
0
        /// <summary>
        /// Creates a StackTraceDeminifier which does not depend on JS files, and is ES2015+ compatible.
        /// StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier.
        /// </summary>
        /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
        /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param>
        public static StackTraceDeminifier GetMapOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, IStackTraceParser stackTraceParser)
        {
            if (sourceMapProvider == null)
            {
                throw new ArgumentNullException(nameof(sourceMapProvider));
            }

            if (stackTraceParser == null)
            {
                throw new ArgumentNullException(nameof(stackTraceParser));
            }

            ISourceMapStore       sourceMapStore       = new SourceMapStore(sourceMapProvider);
            IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore);

            return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser));
        }
コード例 #10
0
 /// <summary>
 /// Creates a StackTraceDeminifier that only deminifies the method names. StackTrace deminifiers created with this method will use significantly less memory during runtime than the
 /// </summary>
 /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
 /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
 public static StackTraceDeminifier GetMethodNameOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider)
 {
     return(GetMethodNameOnlyStackTraceDeminfier(sourceMapProvider, generatedCodeProvider, new StackTraceParser()));
 }
コード例 #11
0
 /// <summary>
 /// Creates a StackTraceDeminifier which does not depend on JS files, and is ES2015+ compatible.
 /// StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier.
 /// </summary>
 /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param>
 public static StackTraceDeminifier GetMapOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider)
 {
     return(GetMapOnlyStackTraceDeminfier(sourceMapProvider, new StackTraceParser()));
 }
コード例 #12
0
 public SourceMapStore(ISourceMapProvider sourceMapProvider)
 {
     _sourceMapProvider = sourceMapProvider;
     _sourceMapParser   = new SourceMapParser();
     _sourceMapCache    = new KeyValueCache <string, SourceMap>(sourceCodeUrl => _sourceMapParser.ParseSourceMap(_sourceMapProvider.GetSourceMapContentsForCallstackUrl(sourceCodeUrl)));
 }