Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            // In production, the React files will be served from this directory
            services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; });

            services.AddSingleton(sp =>
            {
                var env        = sp.GetRequiredService <IWebHostEnvironment>();
                var collection = new SourceMapCollection();

                foreach (var file in env.ContentRootFileProvider.GetDirectoryContents("/ClientApp/build/static/js/"))
                {
                    if (file.IsDirectory || !file.Name.EndsWith(".map", StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }

                    var contents = new StreamReader(file.CreateReadStream()).ReadToEnd();
                    collection.ParseAndRegister(contents);
                }

                return(collection);
            });
        }
Esempio n. 2
0
        public static string ReTrace(SourceMap sourceMap, string stacktrace, string?sourceRoot = null)
        {
            var collection = new SourceMapCollection();

            collection.Register(sourceMap);
            return(ReTrace(collection, stacktrace, sourceRoot));
        }
Esempio n. 3
0
        public static string ReTrace(SourceMapCollection sourceMaps, string stacktrace, string?sourceRoot = null)
        {
            var trace = Parse(stacktrace);

            foreach (var frame in trace.Frames)
            {
                if (!string.IsNullOrEmpty(sourceRoot))
                {
                    frame.File = frame.File?.Replace(sourceRoot, "");
                }

                var sourceMap = sourceMaps.GetSourceMapFor(frame.File);
                if (sourceMap == null && frame.File?.IndexOf('?') >= 0) // Allow querystring versioning missing from the registered filename
                {
                    sourceMap = sourceMaps.GetSourceMapFor(frame.File.Substring(0, frame.File.IndexOf('?')));
                }

                if (frame.LineNumber == null || frame.ColumnNumber == null)
                {
                    continue;
                }

                var originalPosition = sourceMap?.OriginalPositionFor(frame.LineNumber.Value, frame.ColumnNumber.Value - 1);
                if (originalPosition == null)
                {
                    continue;
                }

                frame.File         = originalPosition?.OriginalFileName;
                frame.Method       = originalPosition?.OriginalName;
                frame.LineNumber   = originalPosition?.OriginalLineNumber + 1;
                frame.ColumnNumber = originalPosition?.OriginalColumnNumber + 1;
            }

            return(trace.ToString());
        }
Esempio n. 4
0
 private void ServeDataSourceInfoCollection(DataSourceInfo selectedMappedData)
 {
     SourceMapCollection = (ObservableCollection <DataSourceInfo>)SourceMapCollection.Except(AlreadyMappedItems);
 }
Esempio n. 5
0
 public ApiController(SourceMapCollection sourceMaps)
 {
     _sourceMaps = sourceMaps;
 }