Ejemplo n.º 1
0
        public void AddSymbolFiles(SymbolFile symbolFile, HttpPostedFileBase[] uploadFiles)
        {
            var symbol = GetSymbol(symbolFile.Symbol.SystemId);

            if (symbolFile.SymbolFileVariant == null)
            {
                SymbolFileVariant variant = new SymbolFileVariant();
                variant.SystemId             = Guid.NewGuid();
                variant.Name                 = GetVariantName(symbol, symbolFile);
                symbolFile.SymbolFileVariant = variant;
            }

            symbol.DateChanged  = DateTime.Now;
            symbol.LastEditedBy = ClaimsPrincipal.Current.GetUsername();

            ImageService imageService = new ImageService();

            foreach (var uploadFile in uploadFiles)
            {
                int width = imageService.GetWidth(uploadFile);
                uploadFile.InputStream.Position = 0;
                var format = Path.GetExtension(uploadFile.FileName).Replace(".", "");
                if (width > 0 && format != "ai" && format != "pdf")
                {
                    symbolFile.Size = GetSize(width);
                }
                var filename = new ImageService().SaveImage(uploadFile, symbol, symbolFile, width, true);
                AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, format);
            }
        }
Ejemplo n.º 2
0
        public void TestSuite3()
        {
            var symbols = new Dictionary <string, int>
            {
                { "Val1", 0x11 },
                { "Val2", 0x22 },
                { "Val3", 0xff },
                { "Loc1", 0xd020 },
                { "Loc2", 0xd021 },
                { "Loc3", 0xd022 }
            };


            var symbolFile = new SymbolFile(symbols);

            var tree = GetContext("GrammarTests/test-3.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener {
                Symbols = symbolFile
            };

            walker.Walk(sbl, tree);

            Assert.AreEqual(0x11, sbl.Proc.ReadMemoryValueWithoutCycle(0xd020));
            Assert.AreEqual(0x22, sbl.Proc.ReadMemoryValueWithoutCycle(0xd021));
            Assert.AreEqual(0xff, sbl.Proc.ReadMemoryValueWithoutCycle(0xd022));
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string        path = @"C:\Tool Demo Files\2. Crash Data\File43\CoreImage"; // C:\Tool Demo Files\2. Crash Data\File28\";
            DirectoryInfo dir  = new DirectoryInfo(path);

            FileInfo[] files = dir.GetFiles("*.symbol");
            //
            //
            foreach (FileInfo file in files)
            {
                //
                DateTime timeStamp = DateTime.Now;
                System.Console.WriteLine(string.Format("[{0}] - Reading starting...", file.Name));

                SymbolFile symbolFile = new SymbolFile(file);
                symbolFile.Read();

                DateTime endTime = DateTime.Now;
                TimeSpan span    = (endTime - timeStamp);

                System.Console.WriteLine(string.Format("[{0}] - Reading complete - {1} time, {2} binaries", file.Name, span, symbolFile.Count));
                System.Console.WriteLine(" ");
                System.Console.WriteLine(" ");
                System.Console.WriteLine(" ");
                System.Console.ReadKey();
            }
        }
Ejemplo n.º 4
0
        public void TestAddSymbols()
        {
            var symfile = ".label MyLabel=$0801\n.label YourLabel=$c000\n  .label OurLabel=49152";
            var sf      = new SymbolFile(symfile);

            Assert.AreEqual(2049, sf.SymbolToAddress("MyLabel"));
            Assert.AreEqual(49152, sf.SymbolToAddress("YourLabel"));
            Assert.AreEqual(49152, sf.SymbolToAddress("OurLabel"));
        }
Ejemplo n.º 5
0
        public void AddSymbolFilesFromSvg(SymbolFile symbolFile, HttpPostedFileBase uploadFile)
        {
            var symbol = GetSymbol(symbolFile.Symbol.SystemId);

            if (symbolFile.SymbolFileVariant == null)
            {
                SymbolFileVariant variant = new SymbolFileVariant();
                variant.SystemId             = Guid.NewGuid();
                variant.Name                 = GetVariantName(symbol, symbolFile);
                symbolFile.SymbolFileVariant = variant;
            }

            ImageService imageService = new ImageService();

            symbol.DateChanged  = DateTime.Now;
            symbol.LastEditedBy = ClaimsPrincipal.Current.GetUsername();
            symbolFile.Symbol   = symbol;
            symbolFile.SystemId = Guid.NewGuid();
            var filename = imageService.SaveImage(uploadFile, symbol, symbolFile, 0, false);

            symbolFile.FileName = filename;
            symbolFile.Format   = "svg";
            symbolFile.Size     = "stor";
            _dbContext.SymbolFiles.Add(symbolFile);
            _dbContext.SaveChanges();

            uploadFile.InputStream.Position = 0;
            filename        = imageService.ConvertImage(uploadFile, symbol, "tiff", symbolFile, 1500, false);
            symbolFile.Size = "stor";
            AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "tiff");

            uploadFile.InputStream.Position = 0;
            filename        = imageService.ConvertImage(uploadFile, symbol, "png", symbolFile, 50, false);
            symbolFile.Size = "liten";
            AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "png");

            uploadFile.InputStream.Position = 0;
            filename        = imageService.ConvertImage(uploadFile, symbol, "png", symbolFile, 150);
            symbolFile.Size = "liten";
            AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "png");

            //var gifInputFileName = filename;

            //filename = imageService.ConvertToGif(gifInputFileName, symbol, "gif", symbolFile, 50, false);
            //symbolFile.Size = "liten";
            //AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "gif");

            //filename = imageService.ConvertToGif(gifInputFileName, symbol, "gif", symbolFile, 150);
            //symbolFile.Size = "liten";
            //AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "gif");

            //uploadFile.InputStream.Position = 0;
            //filename = imageService.ConvertImage(uploadFile, symbol, "ai", symbolFile, 0, false);
            //symbolFile.Size = "stor";
            //AddFile(symbolFile, symbol, symbolFile.SymbolFileVariant, filename, "ai");
        }
Ejemplo n.º 6
0
        public void TestNamespaces()
        {
            var symfile =
                ".label NonNamespacedLabel=$400\n.namespace kernal {\n  .label NamespacedLabel=$ffff\n}\n.label AnotherNonNamespacedLabel=$0800";
            var sf = new SymbolFile(symfile);

            Assert.AreEqual(1024, sf.SymbolToAddress("NonNamespacedLabel"));
            Assert.AreEqual(65535, sf.SymbolToAddress("kernal.NamespacedLabel"));
            Assert.AreEqual(2048, sf.SymbolToAddress("AnotherNonNamespacedLabel"));
        }
Ejemplo n.º 7
0
        public override void ExitSymbolsFunction(sim6502Parser.SymbolsFunctionContext context)
        {
            var filename = context.symbolsFilename().StringLiteral().GetText();

            Logger.Trace($"Loading symbol file {filename}");
            var symbols = File.ReadAllText(filename);

            Symbols = new SymbolFile(symbols);
            Logger.Trace($"{Symbols.SymbolCount.ToString()} symbols loaded.");
        }
Ejemplo n.º 8
0
        // GET: SymbolFiles/Create
        public ActionResult Create(Guid systemid)
        {
            ViewBag.Size           = new SelectList(CodeList.Size, "Key", "Value");
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value");
            SymbolFile symbolFile = new SymbolFile();

            symbolFile.Symbol = _symbolService.GetSymbol(systemid);

            return(View(symbolFile));
        }
Ejemplo n.º 9
0
        public void TestLookupByAddress()
        {
            var symfile =
                ".label NonNamespacedLabel=$400\n.namespace kernal {\n  .label NamespacedLabel=$ffff\n}\n.label AnotherNonNamespacedLabel=$0800";
            var sf = new SymbolFile(symfile);

            Assert.AreEqual("NonNamespacedLabel", sf.AddressToSymbol(1024));
            Assert.AreEqual("kernal.NamespacedLabel", sf.AddressToSymbol(65535));
            Assert.AreEqual("AnotherNonNamespacedLabel", sf.AddressToSymbol(2048));

            Assert.AreEqual("$401", sf.AddressToSymbol(1025));
            Assert.AreEqual("1025", sf.AddressToSymbol(1025, false));
        }
Ejemplo n.º 10
0
        private void AddFile(SymbolFile symbolFile, Models.Symbol symbol, SymbolFileVariant variant, string filename, string format)
        {
            SymbolFile file = new SymbolFile();

            file.SystemId          = Guid.NewGuid();
            file.Color             = symbolFile.Color;
            file.Size              = symbolFile.Size;
            file.Symbol            = symbol;
            file.SymbolFileVariant = variant;
            file.Type              = symbolFile.Type;
            file.FileName          = filename;
            file.Format            = format;
            _dbContext.SymbolFiles.Add(file);
            _dbContext.SaveChanges();
        }
Ejemplo n.º 11
0
        private static bool WriteAnnotations(SymbolFile file, StreamWriter sw)
        {
            var providers = new SortedList <string, SourceProvider>();
            var itemCount = 1;

            var available = file.SourceFiles
                            .Where(x => x.IsResolved)
                            .Select(x => x.SourceReference.SourceProvider)
                            .Where(x => !providers.ContainsKey(x.Id));

            foreach (var provider in available)
            {
                providers.Add(provider.Id, provider);
                if (provider.SourceEntryVariableCount > itemCount)
                {
                    itemCount = provider.SourceEntryVariableCount;
                }
            }

            if (providers.Count == 0)
            {
                return(false);
            }

            Console.WriteLine("Indexing " + file.File.FullName);
            sw.WriteLine("SRCSRV: ini ------------------------------------------------");
            sw.WriteLine("VERSION=1");
            sw.WriteLine("SRCSRV: variables ------------------------------------------");
            sw.WriteLine("DATETIME=" + DateTime.UtcNow.ToString("u"));
            foreach (var sp in providers.Values)
            {
                sp.WriteEnvironment(sw);
            }
            sw.WriteLine("SRCSRV: source files ---------------------------------------");

            var files = file.SourceFiles
                        .Where(x => x.IsResolved)
                        .Select(x => x.SourceReference.GetSourceEntries());

            foreach (var values in files)
            {
                sw.WriteLine(string.Join("*", values.Take(itemCount)));
            }

            sw.WriteLine("SRCSRV: end ------------------------------------------------");

            return(true);
        }
Ejemplo n.º 12
0
        private string GetVariantName(Models.Symbol symbol, SymbolFile symbolFile)
        {
            string variantName = symbol.Name;

            if (!string.IsNullOrEmpty(symbolFile.Type))
            {
                variantName = variantName + " " + symbolFile.Type;
            }

            if (!string.IsNullOrEmpty(symbolFile.Color))
            {
                variantName = variantName + " " + symbolFile.Color;
            }

            return(variantName);
        }
Ejemplo n.º 13
0
        public void TestSuite10()
        {
            var symbols = new Dictionary <string, int>
            {
                { "Loc1", 0xd020 }
            };

            var symbolFile = new SymbolFile(symbols);

            var tree = GetContext("GrammarTests/test-10.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener {
                Symbols = symbolFile
            };

            walker.Walk(sbl, tree);
        }
Ejemplo n.º 14
0
        // GET: SymbolFiles/EditFile/5
        public ActionResult EditFile(Guid?systemid)
        {
            if (systemid == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            SymbolFile symbolFile = _symbolService.GetSymbolFile(systemid.Value);

            if (symbolFile == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Sizes          = new SelectList(CodeList.Size, "Key", "Value", symbolFile.Size);
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value", symbolFile.Type);

            return(View(symbolFile));
        }
Ejemplo n.º 15
0
        public ActionResult EditFile(SymbolFile symbolFile)
        {
            var originalSymbolFile = _symbolService.GetSymbolFile(symbolFile.SystemId);

            ViewBag.Sizes          = new SelectList(CodeList.Size, "Key", "Value", originalSymbolFile.Size);
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value", originalSymbolFile.Type);

            if (!_authorizationService.HasAccess(originalSymbolFile.Symbol.Owner,
                                                 ClaimsPrincipal.Current.GetOrganizationName()))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }
            if (ModelState.IsValid)
            {
                try
                {
                    if (symbolFile.FileName != originalSymbolFile.FileName)
                    {
                        _symbolService.RenameFile(originalSymbolFile, symbolFile.FileName);
                        originalSymbolFile.FileName = symbolFile.FileName;
                    }

                    originalSymbolFile.Color = symbolFile.Color;
                    originalSymbolFile.Size  = symbolFile.Size;
                    originalSymbolFile.Type  = symbolFile.Type;

                    _symbolService.UpdateSymbolFile(originalSymbolFile);
                    return(RedirectToAction("edit", "symbolfiles", new { systemid = originalSymbolFile.SymbolFileVariant.SystemId }));
                }
                catch (FileException exf)
                {
                    Log.Error(exf);
                    ModelState.AddModelError("errorFile", exf.Message);
                }
                catch (Exception ex) {
                    Log.Error(ex);
                    ModelState.AddModelError("error", "Det oppstod en feil");
                }
            }

            return(View(originalSymbolFile));
        }
Ejemplo n.º 16
0
        public void TestSuite2()
        {
            var symbols = new Dictionary <string, int> {
                { "Val1", 0x11 }, { "Val2", 0x22 }, { "Val3", 0xff }
            };
            var symbolFile = new SymbolFile(symbols);

            var tree = GetContext("GrammarTests/test-2.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener {
                Symbols = symbolFile
            };

            walker.Walk(sbl, tree);

            Assert.AreEqual(0x11, sbl.Proc.XRegister);
            Assert.AreEqual(0x22, sbl.Proc.Accumulator);
            Assert.AreEqual(0xff, sbl.Proc.YRegister);
        }
Ejemplo n.º 17
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public IndexerResult Exec()
        {
            Uri    codeBase = new Uri(typeof(SourceServerIndexer).Assembly.CodeBase);
            string myDir    = Path.GetDirectoryName(codeBase.LocalPath);

            _srcToolPath = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "srctool.exe"));
            _pdbStrPath  = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "pdbstr.exe"));

            if (!File.Exists(_srcToolPath))
            {
                throw new FileNotFoundException("SRCTOOL.EXE not found", _srcToolPath);
            }
            if (!File.Exists(_srcToolPath))
            {
                throw new FileNotFoundException("PDBSTR.EXE not found", _pdbStrPath);
            }

            IndexerState state = new IndexerState();

            foreach (string pdbFile in SymbolFiles)
            {
                SymbolFile symbolFile = new SymbolFile(pdbFile);

                if (!symbolFile.Exists)
                {
                    throw new FileNotFoundException(string.Format("Symbol {0} file not found", symbolFile.FullName), symbolFile.FullName);
                }

                state.SymbolFiles.Add(symbolFile.FullName, symbolFile);
            }

            ReadSourceFilesFromPdbs(state); // Check if there are files to index for this pdb file

            PerformExclusions(state);

            ResolveFiles(state);

            WritePdbAnnotations(state);

            return(CreateResultData(state));
        }
Ejemplo n.º 18
0
        public ActionResult Create(SymbolFile symbolFile, HttpPostedFileBase[] uploadFiles, bool autogenererFraSvg = false)
        {
            ViewBag.Size           = new SelectList(CodeList.Size, "Key", "Value", symbolFile.Size);
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value", symbolFile.Type);
            if (ModelState.IsValid)
            {
                if (autogenererFraSvg)
                {
                    _symbolService.AddSymbolFilesFromSvg(symbolFile, uploadFiles[0]);
                }
                else
                {
                    _symbolService.AddSymbolFiles(symbolFile, uploadFiles);
                }


                return(RedirectToAction("Details", "Files", new { systemid = symbolFile.Symbol.SystemId }));
            }

            return(View(symbolFile));
        }
Ejemplo n.º 19
0
        public void RenameFile(SymbolFile symbolFile, string newFileName)
        {
            var fileExists = _dbContext.SymbolFiles.Where(f => f.FileName == newFileName && f.SystemId != symbolFile.SystemId);

            if (fileExists.Any())
            {
                throw new FileException("Filnavn finnes fra før");
            }

            string targetFolder = System.Web.HttpContext.Current.Server.MapPath("~/files");

            if (!string.IsNullOrEmpty(symbolFile.Symbol.SymbolPackages[0].Folder))
            {
                targetFolder = targetFolder + "\\" + symbolFile.Symbol.SymbolPackages[0].Folder;
            }
            string targetPath = Path.Combine(targetFolder, symbolFile.FileName);

            string destinationPath = Path.Combine(targetFolder, newFileName);

            File.Move(targetPath, destinationPath);
        }
Ejemplo n.º 20
0
        public void TestSuite8()
        {
            var symbols = new Dictionary <string, int>
            {
                { "Loc1", 0xd020 }
            };

            var symbolFile = new SymbolFile(symbols);

            var tree = GetContext("GrammarTests/test-8.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener {
                Symbols = symbolFile
            };

            walker.Walk(sbl, tree);

            Assert.AreEqual(0xabcd, sbl.Proc.ReadMemoryWordWithoutCycle(0xd020));
            Assert.AreEqual(0xd0, sbl.Proc.ReadMemoryValueWithoutCycle(0xd022));
        }
Ejemplo n.º 21
0
        private static bool WriteAnnotations(SymbolFile file, StreamWriter sw)
        {
            var providers = new SortedList<string, SourceProvider>();
            var itemCount = 1;

            var available = file.SourceFiles
                .Where(x => x.IsResolved)
                .Select(x => x.SourceReference.SourceProvider)
                .Where(x => !providers.ContainsKey(x.Id));

            foreach (var provider in available)
            {
                providers.Add(provider.Id, provider);
                if (provider.SourceEntryVariableCount > itemCount)
                    itemCount = provider.SourceEntryVariableCount;
            }

            if (providers.Count == 0)
                return false;

            Console.WriteLine("Indexing " + file.File.FullName);
            sw.WriteLine("SRCSRV: ini ------------------------------------------------");
            sw.WriteLine("VERSION=1");
            sw.WriteLine("SRCSRV: variables ------------------------------------------");
            sw.WriteLine("DATETIME=" + DateTime.UtcNow.ToString("u"));
            foreach (var sp in providers.Values)
                sp.WriteEnvironment(sw);
            sw.WriteLine("SRCSRV: source files ---------------------------------------");

            var files = file.SourceFiles
                .Where(x => x.IsResolved)
                .Select(x => x.SourceReference.GetSourceEntries());

            foreach (var values in files)
                sw.WriteLine(string.Join("*", values.Take(itemCount)));

            sw.WriteLine("SRCSRV: end ------------------------------------------------");

            return true;
        }
Ejemplo n.º 22
0
        public ActionResult Edit(SymbolFile symbolFile, HttpPostedFileBase[] uploadFile, string FileToRemove)
        {
            ViewBag.Size           = new SelectList(CodeList.Size, "Key", "Value");
            ViewBag.SymbolGraphics = new SelectList(CodeList.SymbolGraphics, "Key", "Value");

            var variants = _symbolService.GetSymbolVariant(symbolFile.SymbolFileVariant.SystemId);

            if (!_authorizationService.HasAccess(variants[0].Symbol.Owner,
                                                 ClaimsPrincipal.Current.GetOrganizationName()))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            foreach (var variant in variants)
            {
                variant.SymbolFileVariant.Name = symbolFile.SymbolFileVariant.Name;
                _symbolService.UpdateSymbolFile(variant);
            }

            if (uploadFile != null && uploadFile[0] != null)
            {
                var file = variants.FirstOrDefault();
                symbolFile.SymbolFileVariant = file.SymbolFileVariant;
                symbolFile.Type   = symbolFile.Type;
                symbolFile.Color  = symbolFile.Color;
                symbolFile.Size   = symbolFile.Size;
                symbolFile.Symbol = file.Symbol;
                _symbolService.AddSymbolFiles(symbolFile, uploadFile);
            }

            if (!string.IsNullOrEmpty(FileToRemove))
            {
                var fileToRemove = _symbolService.GetSymbolFile(Guid.Parse(FileToRemove));
                _symbolService.RemoveSymbolFile(fileToRemove);
            }

            variants = _symbolService.GetSymbolVariant(symbolFile.SymbolFileVariant.SystemId);

            return(View(variants));
        }
Ejemplo n.º 23
0
        public void TestSuite4()
        {
            var symbols = new Dictionary <string, int> {
                { "FALSE", 0x00 }
            };

            var symbolFile = new SymbolFile(symbols);
            var tree       = GetContext("GrammarTests/test-4.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener {
                Symbols = symbolFile
            };

            walker.Walk(sbl, tree);

            Assert.IsTrue(sbl.Proc.CarryFlag);
            Assert.IsFalse(sbl.Proc.NegativeFlag);
            Assert.IsTrue(sbl.Proc.ZeroFlag);
            Assert.IsFalse(sbl.Proc.OverflowFlag);
            Assert.IsFalse(sbl.Proc.DecimalFlag);
        }
Ejemplo n.º 24
0
        public void TestSuite1()
        {
            var symbols = new Dictionary <string, int>();

            symbols.Add("MySymbol", 0xa000);
            symbols.Add("Loc1", 0xc000);
            symbols.Add("Loc2", 0x80);

            var symbolFile = new SymbolFile(symbols);

            var tree = GetContext("GrammarTests/test-1.txt");

            var walker = new ParseTreeWalker();
            var sbl    = new SimBaseListener();

            sbl.Symbols = symbolFile;

            walker.Walk(sbl, tree);

            Assert.AreEqual(0xd0, sbl.Proc.ReadMemoryValueWithoutCycle(0x80));
            Assert.AreEqual(0xabcd, sbl.Proc.ReadMemoryWordWithoutCycle(0xc000));
            Assert.AreEqual(0xdcba, sbl.Proc.ReadMemoryWordWithoutCycle(0xc002));
            Assert.AreEqual(0x0d, sbl.Proc.ReadMemoryValueWithoutCycle(0x81));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IndexerResult Exec()
        {
            Uri codeBase = new Uri(typeof(SourceServerIndexer).Assembly.CodeBase);
            string myDir = Path.GetDirectoryName(codeBase.LocalPath);

            _srcToolPath = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "srctool.exe"));
            _pdbStrPath = SvnTools.GetNormalizedFullPath(Path.Combine(myDir, "pdbstr.exe"));

            if (!File.Exists(_srcToolPath))
                throw new FileNotFoundException("SRCTOOL.EXE not found", _srcToolPath);
            if (!File.Exists(_srcToolPath))
                throw new FileNotFoundException("PDBSTR.EXE not found", _pdbStrPath);

            IndexerState state = new IndexerState();

            foreach (string pdbFile in SymbolFiles)
            {
                SymbolFile symbolFile = new SymbolFile(pdbFile);

                if (!symbolFile.Exists)
                    throw new FileNotFoundException(string.Format("Symbol {0} file not found", symbolFile.FullName), symbolFile.FullName);

                state.SymbolFiles.Add(symbolFile.FullName, symbolFile);
            }

            ReadSourceFilesFromPdbs(state); // Check if there are files to index for this pdb file

            PerformExclusions(state);

            ResolveFiles(state);

            WritePdbAnnotations(state);

            return CreateResultData(state);
        }
Ejemplo n.º 26
0
        static bool WriteAnnotations(IndexerState state, SymbolFile file, StreamWriter sw)
        {
            SortedList<string, SourceProvider> providers = new SortedList<string, SourceProvider>();
            int itemCount = 1;

            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                if (providers.ContainsKey(provider.Id))
                    continue;

                providers.Add(provider.Id, provider);

                if (provider.SourceEntryVariableCount > itemCount)
                    itemCount = provider.SourceEntryVariableCount;
            }

            if (providers.Count == 0)
                return false;

            sw.WriteLine("SRCSRV: ini ------------------------------------------------");
            sw.WriteLine("VERSION=1");
            sw.Write("VERCTRL=SharpSvn.PdbAnnotate");
            foreach (SourceProvider sp in providers.Values)
            {
                if (!string.IsNullOrEmpty(sp.Name))
                {
                    sw.Write('+');
                    sw.Write(sp.Name);
                }
            }
            sw.WriteLine();
            sw.WriteLine("SRCSRV: variables ------------------------------------------");
            sw.WriteLine("DATETIME=" + DateTime.Now.ToUniversalTime().ToString("u"));
            sw.WriteLine("SRCSRVTRG=%fnvar%(%VAR2%__TRG)");
            sw.WriteLine("SRCSRVCMD=%fnvar%(%VAR2%__CMD)");
            //sw.WriteLine("SRCSRVENV=PATH=%PATH%\\bSystemDrive=%SystemDrive%\\bSystemRoot=%SystemRoot%\\bProgramFiles=%ProgramFiles%\\bProgramData=%ProgramData%\\b%fnvar%(%VAR2%__ENV)");
            foreach (SourceProvider sp in providers.Values)
            {
                sp.WriteEnvironment(sw);
            }
            sw.WriteLine("SRCSRV: source files ---------------------------------------");

            // Note: the sourcefile block must be written in the order they are found by the PdbReader
            //	otherwise SrcTool skips all sourcefiles which don't exist locally and are out of order
            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                sw.Write(sf.FullName);
                sw.Write('*');

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                sw.Write(provider.Id);
                sw.Write('*');

                string[] strings = sr.GetSourceEntries();

                if (strings != null)
                    for (int i = 0; i < itemCount; i++)
                    {
                        if (i < strings.Length)
                            sw.Write(strings[i]);

                        sw.Write('*');
                    }
                else
                {
                    for (int i = 0; i < itemCount; i++)
                        sw.Write('*');
                }

                // Note: We defined the variables upto itemCount+2 (filename, type, itemcount),
                // All variables above this index are reserved for future extensions

                sw.WriteLine();
            }

            sw.WriteLine("SRCSRV: end ------------------------------------------------");

            return true;
        }
Ejemplo n.º 27
0
 internal void AddSymbolFile(SymbolFile symfile)
 {
     symbol_files.Add(symfile);
 }
Ejemplo n.º 28
0
 internal void AddSymbolFile(SymbolFile symfile)
 {
     symbol_files.Add (symfile);
 }
Ejemplo n.º 29
0
 public void RemoveSymbolFile(SymbolFile symbolFile)
 {
     DeleteFile(symbolFile.FileName, symbolFile.Symbol.SymbolPackages.FirstOrDefault()?.Folder);
     _dbContext.SymbolFiles.Remove(symbolFile);
     _dbContext.SaveChanges();
 }
Ejemplo n.º 30
0
        static bool WriteAnnotations(IndexerState state, SymbolFile file, StreamWriter sw)
        {
            SortedList<string, SourceProvider> providers = new SortedList<string, SourceProvider>();
            int itemCount = 1;

            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                if (providers.ContainsKey(provider.Id))
                    continue;

                providers.Add(provider.Id, provider);

                if (provider.SourceEntryVariableCount > itemCount)
                    itemCount = provider.SourceEntryVariableCount;
            }

            if (providers.Count == 0)
                return false;

            sw.WriteLine("SRCSRV: ini ------------------------------------------------");
            sw.WriteLine("VERSION=1");
            sw.Write("VERCTRL=SharpSvn.PdbAnnotate");
            foreach (SourceProvider sp in providers.Values)
            {
                if (!string.IsNullOrEmpty(sp.Name))
                {
                    sw.Write('+');
                    sw.Write(sp.Name);
                }
            }
            sw.WriteLine();
            sw.WriteLine("SRCSRV: variables ------------------------------------------");
            sw.WriteLine("DATETIME=" + DateTime.Now.ToUniversalTime().ToString("u"));
            sw.WriteLine("SRCSRVTRG=%fnvar%(%VAR2%__TRG)");
            sw.WriteLine("SRCSRVCMD=%fnvar%(%VAR2%__CMD)");
            //sw.WriteLine("SRCSRVENV=PATH=%PATH%\\bSystemDrive=%SystemDrive%\\bSystemRoot=%SystemRoot%\\bProgramFiles=%ProgramFiles%\\bProgramData=%ProgramData%\\b%fnvar%(%VAR2%__ENV)");
            foreach (SourceProvider sp in providers.Values)
            {
                sp.WriteEnvironment(sw);
            }
            sw.WriteLine("SRCSRV: source files ---------------------------------------");

            // Note: the sourcefile block must be written in the order they are found by the PdbReader
            //	otherwise SrcTool skips all sourcefiles which don't exist locally and are out of order
            foreach (SourceFile sf in file.SourceFiles)
            {
                if (!sf.IsResolved || sf.NoSourceAvailable)
                    continue;

                sw.Write(sf.FullName);
                sw.Write('*');

                SourceReference sr = sf.SourceReference;
                SourceProvider provider = sr.SourceProvider;

                sw.Write(provider.Id);
                sw.Write('*');

                string[] strings = sr.GetSourceEntries();

                if (strings != null)
                    for (int i = 0; i < itemCount; i++)
                    {
                        if (i < strings.Length)
                            sw.Write(strings[i]);

                        sw.Write('*');
                    }
                else
                {
                    for (int i = 0; i < itemCount; i++)
                        sw.Write('*');
                }

                // Note: We defined the variables upto itemCount+2 (filename, type, itemcount),
                // All variables above this index are reserved for future extensions

                sw.WriteLine();
            }

            sw.WriteLine("SRCSRV: end ------------------------------------------------");

            return true;
        }