Exemple #1
0
        public override bool TryParseSymbolData(string value, ClientWatsonFunctionNamePool functionNamePool, out T javaScriptSymbol)
        {
            javaScriptSymbol = default(T);
            if (value == null)
            {
                return(false);
            }
            string[] array = value.Split(new char[]
            {
                ','
            }, StringSplitOptions.None);
            if (array.Length != this.AjaxMinFieldCount)
            {
                return(false);
            }
            bool result;

            try
            {
                string item = array[11];
                if (this.symbolTypesToSkip.Contains(item))
                {
                    result = false;
                }
                else
                {
                    javaScriptSymbol = this.ParseSymbolData(array, functionNamePool);
                    result           = true;
                }
            }
            catch (ArgumentNullException)
            {
                result = false;
            }
            catch (OverflowException)
            {
                result = false;
            }
            catch (FormatException)
            {
                result = false;
            }
            return(result);
        }
        // Token: 0x06002437 RID: 9271 RVA: 0x00082F3C File Offset: 0x0008113C
        public JavaScriptSymbolsMap <T> Load()
        {
            Dictionary <string, List <T> > symbolMaps      = new Dictionary <string, List <T> >(20, StringComparer.InvariantCultureIgnoreCase);
            Dictionary <uint, string>      sourceFileIdMap = new Dictionary <uint, string>(1024);
            ClientWatsonFunctionNamePool   clientWatsonFunctionNamePool = new ClientWatsonFunctionNamePool();

            foreach (string filePath in this.symbolMapFiles)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                Exception ex        = null;
                try
                {
                    this.LoadSymbolsMapFromFile(filePath, symbolMaps, sourceFileIdMap, clientWatsonFunctionNamePool);
                }
                catch (XmlException ex2)
                {
                    ex = ex2;
                }
                catch (IOException ex3)
                {
                    ex = ex3;
                }
                catch (SecurityException ex4)
                {
                    ex = ex4;
                }
                finally
                {
                    stopwatch.Stop();
                }
                SymbolMapLoadLogEvent logEvent;
                if (ex == null)
                {
                    logEvent = SymbolMapLoadLogEvent.CreateForSuccess(filePath, stopwatch.Elapsed);
                }
                else
                {
                    logEvent = SymbolMapLoadLogEvent.CreateForError(filePath, ex, stopwatch.Elapsed);
                }
                OwaServerLogger.AppendToLog(logEvent);
            }
            return(new JavaScriptSymbolsMap <T>(symbolMaps, sourceFileIdMap, clientWatsonFunctionNamePool.ToArray()));
        }
Exemple #3
0
        protected override void LoadSymbolsMapFromFile(string filePath, Dictionary <string, List <ScriptSharpSymbolWrapper> > symbolMaps, Dictionary <uint, string> sourceFileIdMap, ClientWatsonFunctionNamePool functionNamePool)
        {
            Dictionary <string, int> dictionary = new Dictionary <string, int>();
            Dictionary <int, List <ScriptSharpSymbolWrapper> >         dictionary2 = new Dictionary <int, List <ScriptSharpSymbolWrapper> >();
            Stack <ScriptSharpSourceMapLoader.ContainingMethodContext> stack       = new Stack <ScriptSharpSourceMapLoader.ContainingMethodContext>();
            Stack <ScriptSharpSourceMapLoader.ParentContext>           stack2      = new Stack <ScriptSharpSourceMapLoader.ParentContext>();
            string arg   = null;
            string arg2  = null;
            int    num   = -1;
            int    key   = -1;
            int    count = sourceFileIdMap.Count;

            using (XmlReader xmlReader = XmlReader.Create(filePath))
            {
                while (xmlReader.Read())
                {
                    XmlNodeType xmlNodeType = xmlReader.MoveToContent();
                    if (xmlNodeType == XmlNodeType.Element)
                    {
                        if (xmlReader.Name == "Statement")
                        {
                            ScriptSharpSourceMapLoader.ContainingMethodContext containingMethodContext = stack.Peek();
                            ScriptSharpSymbol scriptSharpSymbol;
                            if (ScriptSharpSourceMapLoader.TryParseSymbol(xmlReader, containingMethodContext.ScriptOffset, containingMethodContext.FunctionNameIndex, num, out scriptSharpSymbol))
                            {
                                ScriptSharpSourceMapLoader.PopNonParentSymbolsOut(stack2, scriptSharpSymbol, dictionary2[key]);
                                stack2.Push(new ScriptSharpSourceMapLoader.ParentContext(scriptSharpSymbol));
                            }
                        }
                        else if (xmlReader.Name == "Method")
                        {
                            string attribute = xmlReader.GetAttribute("SourceFile");
                            if (string.IsNullOrEmpty(attribute))
                            {
                                ScriptSharpSourceMapLoader.SkipSubTree(xmlReader, "Method");
                            }
                            else
                            {
                                if (!dictionary.TryGetValue(attribute, out num))
                                {
                                    num = dictionary.Count + count;
                                    dictionary.Add(attribute, num);
                                }
                                arg2 = xmlReader.GetAttribute("Name");
                                string            name = string.Format("{0}.{1}", arg, arg2);
                                int               orAddFunctionNameIndex = functionNamePool.GetOrAddFunctionNameIndex(name);
                                ScriptSharpSymbol symbol;
                                if (!ScriptSharpSourceMapLoader.TryParseSymbol(xmlReader, 0, orAddFunctionNameIndex, num, out symbol))
                                {
                                    ScriptSharpSourceMapLoader.SkipSubTree(xmlReader, "Method");
                                }
                                else if (!xmlReader.IsEmptyElement)
                                {
                                    stack.Push(new ScriptSharpSourceMapLoader.ContainingMethodContext(symbol.ScriptStartPosition, orAddFunctionNameIndex));
                                    stack2.Push(new ScriptSharpSourceMapLoader.ParentContext(symbol, true));
                                }
                                else
                                {
                                    dictionary2[key].Add(new ScriptSharpSymbolWrapper(symbol));
                                }
                            }
                        }
                        else if (xmlReader.Name == "AnonymousMethod")
                        {
                            ScriptSharpSourceMapLoader.ContainingMethodContext containingMethodContext2 = stack.Peek();
                            string            name2 = string.Format("{0}.<{1}>anonymous", arg, arg2);
                            int               orAddFunctionNameIndex2 = functionNamePool.GetOrAddFunctionNameIndex(name2);
                            ScriptSharpSymbol scriptSharpSymbol2;
                            if (!ScriptSharpSourceMapLoader.TryParseSymbol(xmlReader, containingMethodContext2.ScriptOffset, orAddFunctionNameIndex2, num, out scriptSharpSymbol2))
                            {
                                ScriptSharpSourceMapLoader.SkipSubTree(xmlReader, "AnonymousMethod");
                            }
                            else
                            {
                                List <ScriptSharpSymbolWrapper>          list          = dictionary2[key];
                                ScriptSharpSourceMapLoader.ParentContext parentContext = ScriptSharpSourceMapLoader.PopNonParentSymbolsOut(stack2, scriptSharpSymbol2, list);
                                if (!xmlReader.IsEmptyElement)
                                {
                                    stack.Push(new ScriptSharpSourceMapLoader.ContainingMethodContext(scriptSharpSymbol2.ScriptStartPosition, orAddFunctionNameIndex2));
                                    stack2.Push(new ScriptSharpSourceMapLoader.ParentContext(scriptSharpSymbol2, true));
                                }
                                else
                                {
                                    parentContext.Children.Add(list.Count);
                                    list.Add(new ScriptSharpSymbolWrapper(scriptSharpSymbol2));
                                }
                            }
                        }
                        else if (xmlReader.Name == "Type")
                        {
                            arg = xmlReader.GetAttribute("Name");
                            string attribute2 = xmlReader.GetAttribute("SegmentRef");
                            if (string.IsNullOrEmpty(attribute2) || !int.TryParse(attribute2, out key))
                            {
                                ScriptSharpSourceMapLoader.SkipSubTree(xmlReader, "Type");
                            }
                            else if (!dictionary2.ContainsKey(key))
                            {
                                dictionary2.Add(key, new List <ScriptSharpSymbolWrapper>(1024));
                            }
                        }
                        else if (xmlReader.Name == "Segments")
                        {
IL_3CE:
                            while (xmlReader.Read())
                            {
                                if (xmlReader.IsStartElement("Segment"))
                                {
                                    string attribute3 = xmlReader.GetAttribute("Id");
                                    int    key2;
                                    List <ScriptSharpSymbolWrapper> list2;
                                    if (int.TryParse(attribute3, out key2) && dictionary2.TryGetValue(key2, out list2))
                                    {
                                        string packageName = ScriptSharpSourceMapLoader.GetPackageName(xmlReader, filePath);
                                        try
                                        {
                                            symbolMaps.Add(packageName, list2);
                                            list2.TrimExcess();
                                        }
                                        catch (ArgumentException exception)
                                        {
                                            string extraData = string.Format("Package: {0}, File name: {1}", packageName, filePath);
                                            ExWatson.SendReport(exception, ReportOptions.DoNotCollectDumps, extraData);
                                        }
                                    }
                                }
                            }
                            goto IL_3E5;
                        }
                    }
                    else if (xmlNodeType == XmlNodeType.EndElement && (xmlReader.Name == "Method" || xmlReader.Name == "AnonymousMethod"))
                    {
                        stack.Pop();
                        List <ScriptSharpSymbolWrapper> symbolList = dictionary2[key];
                        bool flag = false;
                        while (stack2.Count > 0 && !flag)
                        {
                            ScriptSharpSourceMapLoader.ParentContext parentContext2 = ScriptSharpSourceMapLoader.PopItemAndAddToList(stack2, symbolList);
                            flag = parentContext2.IsMethod;
                        }
                    }
                }
                goto IL_3CE;
            }
IL_3E5:
            foreach (KeyValuePair <string, int> keyValuePair in dictionary)
            {
                sourceFileIdMap.Add((uint)keyValuePair.Value, keyValuePair.Key);
            }
        }
        // Token: 0x06002471 RID: 9329 RVA: 0x00083630 File Offset: 0x00081830
        protected override AjaxMinSymbolForJavaScript ParseSymbolData(string[] columns, ClientWatsonFunctionNamePool functionNamePool)
        {
            string text = columns[12];

            if (string.IsNullOrEmpty(text))
            {
                text = "GLOBAL";
            }
            return(new AjaxMinSymbolForJavaScript
            {
                ScriptStartLine = int.Parse(columns[0]),
                ScriptStartColumn = int.Parse(columns[1]),
                ScriptEndLine = int.Parse(columns[2]),
                ScriptEndColumn = int.Parse(columns[3]),
                SourceStartLine = int.Parse(columns[6]),
                SourceStartColumn = int.Parse(columns[7]),
                SourceEndLine = int.Parse(columns[8]),
                SourceEndColumn = int.Parse(columns[9]),
                SourceFileId = uint.Parse(columns[10]),
                FunctionNameIndex = functionNamePool.GetOrAddFunctionNameIndex(text)
            });
        }
Exemple #5
0
 protected override AjaxMinSymbolForScriptSharp ParseSymbolData(string[] columns, ClientWatsonFunctionNamePool functionNamePool)
 {
     return(new AjaxMinSymbolForScriptSharp
     {
         ScriptStartLine = int.Parse(columns[0]),
         ScriptStartColumn = int.Parse(columns[1]),
         ScriptEndLine = int.Parse(columns[2]),
         ScriptEndColumn = int.Parse(columns[3]),
         SourceStartPosition = int.Parse(columns[4]),
         SourceEndPosition = int.Parse(columns[5]),
         SourceFileId = uint.Parse(columns[10])
     });
 }
Exemple #6
0
 protected abstract T ParseSymbolData(string[] columns, ClientWatsonFunctionNamePool functionNamePool);
Exemple #7
0
 public abstract bool TryParseSymbolData(string value, ClientWatsonFunctionNamePool functionNamePool, out T javaScriptSymbol);
        // Token: 0x0600243A RID: 9274 RVA: 0x00083058 File Offset: 0x00081258
        protected override void LoadSymbolsMapFromFile(string filePath, Dictionary <string, List <T> > symbolMaps, Dictionary <uint, string> sourceFileIdMap, ClientWatsonFunctionNamePool functionNamePool)
        {
            uint             count   = (uint)sourceFileIdMap.Count;
            string           text    = null;
            HashSet <string> hashSet = new HashSet <string>();
            Dictionary <string, Stack <int> > dictionary = new Dictionary <string, Stack <int> >();

            using (XmlReader xmlReader = XmlReader.Create(filePath))
            {
                while (xmlReader.Read())
                {
                    if (xmlReader.IsStartElement("s"))
                    {
                        T t;
                        if (this.symbolParser.TryParseSymbolData(xmlReader.ReadString(), functionNamePool, out t))
                        {
                            if (text == null)
                            {
                                throw new XmlException("Found a <s> tag outside of a <scriptFile> section.");
                            }
                            t.SourceFileId += count;
                            Stack <int> stack;
                            if (!dictionary.TryGetValue(text, out stack))
                            {
                                stack = new Stack <int>();
                                dictionary.Add(text, stack);
                            }
                            List <T> list   = symbolMaps[text];
                            int      count2 = list.Count;
                            while (stack.Count > 0)
                            {
                                int index = stack.Peek();
                                T   t2    = list[index];
                                if (!AjaxMinSourceMapLoader <T> .CheckSymbolContainsAnother(t, t2))
                                {
                                    break;
                                }
                                t2.ParentSymbolIndex = count2;
                                list[index]          = t2;
                                stack.Pop();
                            }
                            t.ParentSymbolIndex = -1;
                            stack.Push(count2);
                            list.Add(t);
                        }
                    }
                    else if (xmlReader.Name == "sourceFile")
                    {
                        string attribute = xmlReader.GetAttribute("id");
                        if (attribute == null)
                        {
                            throw new XmlException("One of the source files had a null id");
                        }
                        sourceFileIdMap.Add(uint.Parse(attribute) + count, xmlReader.GetAttribute("path"));
                    }
                    else if (xmlReader.IsStartElement("scriptFile"))
                    {
                        string attribute2 = xmlReader.GetAttribute("path");
                        if (!this.symbolParser.ExtractScriptPackageName(filePath, attribute2, out text))
                        {
                            throw new XmlException("Unable to determine the script package name: " + filePath);
                        }
                        symbolMaps[text] = new List <T>(1024);
                        hashSet.Add(text);
                    }
                }
            }
            foreach (string key in hashSet)
            {
                symbolMaps[key].TrimExcess();
            }
        }
 // Token: 0x06002438 RID: 9272
 protected abstract void LoadSymbolsMapFromFile(string filePath, Dictionary <string, List <T> > symbolMaps, Dictionary <uint, string> sourceFileIdMap, ClientWatsonFunctionNamePool functionNamePool);