public DeclaredSymbolInfo(ISymbol symbol, string assemblyName = null)
 {
     ID           = SymbolIdService.GetIdULong(symbol);
     Name         = SymbolIdService.GetName(symbol);
     Kind         = SymbolKindText.GetSymbolKind(symbol);
     Description  = SymbolIdService.GetDisplayString(symbol);
     Glyph        = SymbolIdService.GetGlyphNumber(symbol);
     AssemblyName = assemblyName;
 }
Ejemplo n.º 2
0
        private void GenerateDeclarations()
        {
            Log.Write("Declarations...");

            var lines = new List <string>();

            if (DeclaredSymbols != null)
            {
                foreach (var declaredSymbol in DeclaredSymbols
                         .OrderBy(s => SymbolIdService.GetName(s.Key))
                         .ThenBy(s => s.Value))
                {
                    lines.Add(string.Join(";",
                                          SymbolIdService.GetName(declaredSymbol.Key),                                   // symbol name
                                          declaredSymbol.Value,                                                          // 8-byte symbol ID
                                          SymbolKindText.GetSymbolKind(declaredSymbol.Key),                              // kind (e.g. "class")
                                          Markup.EscapeSemicolons(SymbolIdService.GetDisplayString(declaredSymbol.Key)), // symbol full name and signature
                                          SymbolIdService.GetGlyphNumber(declaredSymbol.Key)));                          // icon number
                }
            }

            if (OtherFiles != null)
            {
                foreach (var document in OtherFiles.OrderBy(d => d))
                {
                    lines.Add(string.Join(";",
                                          Path.GetFileName(document),
                                          SymbolIdService.GetId(document),
                                          "file",
                                          Markup.EscapeSemicolons(document),
                                          Serialization.GetIconForExtension(document)));
                }
            }

            Serialization.WriteDeclaredSymbols(ProjectDestinationFolder, lines);
        }
        private void Diagnostics(ClassifiedSpan classifiedSpan, SyntaxToken token, ISymbol symbol)
        {
            var tokenText = token.ToString();

            if (!(symbol is INamedTypeSymbol) ||
                classifiedSpan.ClassificationType == "t" ||
                tokenText == "this" ||
                tokenText == "base" ||
                tokenText == "var")
            {
                return;
            }

            if (tokenText == "SR" ||
                tokenText == "SR2" ||
                tokenText == "SRID" ||
                tokenText == "Strings" ||
                tokenText == "Res" ||
                tokenText == "VisualStudioVersionInfo" ||
                tokenText == "Error" ||
                tokenText == "Resource" ||
                tokenText == "Resources" ||
                tokenText == "AssemblyRef" ||
                tokenText == "ProjectResources")
            {
                return;
            }

            var symbolDisplayString = SymbolIdService.GetDisplayString(symbol);

            if (symbolDisplayString == "System.SR" ||
                symbolDisplayString == "System.Web.SR" ||
                symbolDisplayString == "ThisAssembly")
            {
                return;
            }

            if (!reportedSymbolDisplayStrings.Add(symbolDisplayString))
            {
                return;
            }

            if (reportedDiagnostics)
            {
                return;
            }

            reportedDiagnostics = true;

            string message =
                this.documentDestinationFilePath + "\r\n" +
                token.ToString() + ", " + token.Span.Start + "\r\n" +
                (classifiedSpan.ClassificationType ?? "null classification type") + "\r\n" +
                symbolDisplayString;

            var diagnostics = this.SemanticModel.GetDiagnostics().Where(d =>
            {
                var diagnostic = d.GetMessage();
                if (diagnostic.Contains("The type or namespace name 'Resources'") ||
                    diagnostic.Contains("must declare a body because it is not marked abstract"))
                {
                    return(false);
                }

                return(true);
            });

            if (diagnostics.Any())
            {
                var diagnosticsMessage = string.Join("\r\n", diagnostics.Select(d => d.ToString()));
                message = message + "\r\n" + diagnosticsMessage;
            }

            Log.Exception("Classification: " + message);
        }