A container for all DiagnosticDescriptor instances for errors reported by analyzers in this project.
 public void EMBED0008()
 {
     DiagnosticDescriptors.EMBED0008_NullableDirective(Location.None)
         .GetMessage(formatProvider)
         .Should()
         .Be("Nullable directive is unsupported");
 }
 public void EMBED0007()
 {
     DiagnosticDescriptors.EMBED0007_NullableProject()
         .GetMessage(formatProvider)
         .Should()
         .Be("Nullable option is unsupported");
 }
 public void EMBED0010()
 {
     DiagnosticDescriptors.EMBED0010_UsingAliasDirective(Location.None)
         .GetMessage(formatProvider)
         .Should()
         .Be("Avoid using alias directive because there is a risk of name collision");
 }
 public void EMBED0002()
 {
     DiagnosticDescriptors.EMBED0002_OlderVersion(new Version(2, 0, 0), "Newerlib", new Version(3, 0, 0))
         .GetMessage(formatProvider)
         .Should()
         .Be("Embeder version(2.0.0) is older than embedder of Newerlib(3.0.0)");
 }
示例#5
0
 public void EMBED0008()
 {
     DiagnosticDescriptors.EMBED0008_NullableDirective(Location.None)
     .GetMessage(formatProvider)
     .Should()
     .Be("nullableディレクティブは未対応です");
 }
示例#6
0
 public void EXPAND0007()
 {
     DiagnosticDescriptors.EXPAND0007_ParseConfigError("/home/source/SourceExpander.Generator.Config.json", "any error")
     .GetMessage(formatProvider)
     .Should()
     .Be("Error config file: Path: /home/source/SourceExpander.Generator.Config.json, Message: any error");
 }
示例#7
0
 public void EXPAND0008()
 {
     DiagnosticDescriptors.EXPAND0008_EmbeddedDataError("Anotherlib", "SourceExpander.EmbeddedSourceCode", "There was an error deserializing the object of type SourceExpander.SourceFileInfo[]. Encountered unexpected character '}'.")
     .GetMessage(formatProvider)
     .Should()
     .Be("Invalid embedded data: Anotherlib, Key: SourceExpander.EmbeddedSourceCode, Message: There was an error deserializing the object of type SourceExpander.SourceFileInfo[]. Encountered unexpected character '}'.");
 }
示例#8
0
 public void EMBED0010()
 {
     DiagnosticDescriptors.EMBED0010_UsingAliasDirective(Location.None)
     .GetMessage(formatProvider)
     .Should()
     .Be("名前衝突の危険があるため using alias ディレクティブは非推奨です");
 }
示例#9
0
 public void EMBED0006()
 {
     DiagnosticDescriptors.EMBED0006_AnotherAssemblyEmbeddedDataError("Other", "SourceExpander.EmbeddedSourceCode", "There was an error deserializing the object of type SourceExpander.SourceFileInfo[]. Encountered unexpected character '}'.")
     .GetMessage(formatProvider)
     .Should()
     .Be("他のアセンブリの埋め込みデータが不正です: Other, Key: SourceExpander.EmbeddedSourceCode, Message: There was an error deserializing the object of type SourceExpander.SourceFileInfo[]. Encountered unexpected character '}'.");
 }
示例#10
0
 public void EMBED0007()
 {
     DiagnosticDescriptors.EMBED0007_NullableProject()
     .GetMessage(formatProvider)
     .Should()
     .Be("nullableなプロジェクトは未対応です");
 }
示例#11
0
 public void EMBED0005()
 {
     DiagnosticDescriptors.EMBED0005_EmbeddedSourceDiff("Uns")
     .GetMessage(formatProvider)
     .Should()
     .Be("Different syntax: near Uns. This is Embedder error, please report this to GitHub repository.");
 }
示例#12
0
 public void EMBED0004()
 {
     DiagnosticDescriptors.EMBED0004_ErrorEmbeddedSource("P.cs", "any error")
     .GetMessage(formatProvider)
     .Should()
     .Be("Error embedded source: File: P.cs, Message: any error");
 }
示例#13
0
 public void EMBED0003()
 {
     DiagnosticDescriptors.EMBED0003_ParseConfigError("/home/source/SourceExpander.Embedder.Config.json", "any error")
     .GetMessage(formatProvider)
     .Should()
     .Be("Error config file: /home/source/SourceExpander.Embedder.Config.json");
 }
 public void EMBED0001()
 {
     DiagnosticDescriptors.EMBED0001_UnknownError("LX")
         .GetMessage(formatProvider)
         .Should()
         .Be("Unknown error: LX");
 }
示例#15
0
 public void EXPAND0005()
 {
     DiagnosticDescriptors.EXPAND0005_NewerCSharpVersion(LanguageVersion.CSharp7, "Newerlib", LanguageVersion.CSharp8)
     .GetMessage(formatProvider)
     .Should()
     .Be("C# version(7.0) is older than embedded Newerlib(8.0)");
 }
示例#16
0
 public void EXPAND0003()
 {
     DiagnosticDescriptors.EXPAND0003_NotFoundEmbedded()
     .GetMessage(formatProvider)
     .Should()
     .Be("Not found embedded source");
 }
示例#17
0
 public void EXPAND0006()
 {
     DiagnosticDescriptors.EXPAND0006_AllowUnsafe("Unsafelib")
     .GetMessage(formatProvider)
     .Should()
     .Be("Unsafelib が AllowUnsafeBlocks を持っているので AllowUnsafeBlocks が必要です");
 }
示例#18
0
 public void EXPAND0004()
 {
     DiagnosticDescriptors.EXPAND0004_MustBeNewerThanCSharp3()
     .GetMessage(formatProvider)
     .Should()
     .Be("Need C# 3 or later");
 }
示例#19
0
 public void EXPAND0005()
 {
     DiagnosticDescriptors.EXPAND0005_NewerCSharpVersion(LanguageVersion.CSharp7, "Newerlib", LanguageVersion.CSharp8)
     .GetMessage(formatProvider)
     .Should()
     .Be("C# のバージョン(7.0) が埋め込まれている Newerlib(8.0) より古いです。");
 }
示例#20
0
 public void EXPAND0002()
 {
     DiagnosticDescriptors.EXPAND0002_ExpanderVersion(new Version(2, 0, 0), "Newerlib", new Version(3, 0, 0))
     .GetMessage(formatProvider)
     .Should()
     .Be("Expander version(2.0.0) が Newerlib(3.0.0) の embedder より古いです");
 }
示例#21
0
 public void EXPAND0003()
 {
     DiagnosticDescriptors.EXPAND0003_NotFoundEmbedded()
     .GetMessage(formatProvider)
     .Should()
     .Be("埋め込みソースが見つかりません");
 }
示例#22
0
 public void EXPAND0001()
 {
     DiagnosticDescriptors.EXPAND0001_UnknownError("LX")
     .GetMessage(formatProvider)
     .Should()
     .Be("不明なエラー: LX");
 }
示例#23
0
 public void EXPAND0009()
 {
     DiagnosticDescriptors.EXPAND0009_MetadataEmbeddingFileNotFound("Program.cs")
     .GetMessage(formatProvider)
     .Should()
     .Be("MetadataEmbeddingFile is not found: name: Program.cs");
 }
示例#24
0
        private void AnalyzeIntToLongSyntaxNode(SyntaxNodeAnalysisContext context)
        {
            var semanticModel = context.SemanticModel;
            var node          = context.Node;

            var typeInfo = semanticModel.GetTypeInfo(node, cancellationToken: context.CancellationToken);

            if (typeInfo.Type.SpecialType != SpecialType.System_Int32)
            {
                return;
            }

            Diagnostic diagnostic = node.Kind() switch
            {
                SyntaxKind.MultiplyExpression => DiagnosticDescriptors.AC0001_MultiplyOverflowInt32(context.Node),
                SyntaxKind.LeftShiftExpression => DiagnosticDescriptors.AC0002_LeftShiftOverflowInt32(context.Node),
                _ => throw new InvalidOperationException(),
            };

            for (; node is not null; node = GetParent(node))
            {
                if (semanticModel.GetTypeInfo(node, cancellationToken: context.CancellationToken)
                    .ConvertedType.SpecialType == SpecialType.System_Int64)
                {
                    context.ReportDiagnostic(diagnostic);
                    return;
                }
            }
示例#25
0
 public void EXPAND0006()
 {
     DiagnosticDescriptors.EXPAND0006_AllowUnsafe("Unsafelib")
     .GetMessage(formatProvider)
     .Should()
     .Be("Needs AllowUnsafeBlocks because Unsafelib has AllowUnsafeBlocks");
 }
 public void EMBED0011()
 {
     DiagnosticDescriptors.EMBED0011_ObsoleteConfigProperty(
         Location.None, "/home/user/SourceExpander.Embedder.Config.json", "old-property", "instead-property")
         .GetMessage(formatProvider)
         .Should()
         .Be("/home/user/SourceExpander.Embedder.Config.json: Obsolete embedder config property. old-property is obsolete. Use instead-property.");
 }
示例#27
0
 public void EMBED0011()
 {
     DiagnosticDescriptors.EMBED0011_ObsoleteConfigProperty(
         Location.None, "/home/user/SourceExpander.Embedder.Config.json", "old-property", "instead-property")
     .GetMessage(formatProvider)
     .Should()
     .Be("/home/user/SourceExpander.Embedder.Config.json: old-property は廃止されました。代わりに instead-property を使用してください");
 }
 public override SyntaxTrivia VisitTrivia(SyntaxTrivia trivia)
 {
     if (trivia.IsKind(SyntaxKind.NullableDirectiveTrivia))
     {
         reporter.ReportDiagnostic(
             DiagnosticDescriptors.EMBED0008_NullableDirective(trivia.GetLocation()));
     }
     return(SyntaxFactory.ElasticMarker);
 }
示例#29
0
        public async Task <IEnumerable <string> > GetAnalyzerFilesAsync(string identifier, CancellationToken cancellationToken = default)
        {
            ISymbol diagnosticDescriptor = DiagnosticDescriptors.First(f => f.Name == identifier);

            IEnumerable <ReferencedSymbol> referencedSymbols = await SymbolFinder.FindReferencesAsync(diagnosticDescriptor, Solution, cancellationToken).ConfigureAwait(false);

            ISymbol diagnosticIdentifier = DiagnosticIdentifiers.First(f => f.Name == identifier);

            IEnumerable <ReferencedSymbol> referencedSymbols2 = await SymbolFinder.FindReferencesAsync(diagnosticIdentifier, Solution, cancellationToken).ConfigureAwait(false);

            return(GetFilePaths(referencedSymbols.Concat(referencedSymbols2)));
        }
示例#30
0
        public void AppendDiagnostics(IEnumerable <Diagnostic> diagnosticResults)
        {
            if (_exporters.Count == 0)
            {
                return;
            }

            foreach (var diagnostic in diagnosticResults)
            {
                var location          = diagnostic.Location;
                var lineNumber        = 0;
                var characterPosition = 0;
                var fileName          = string.Empty;

                if (location != Location.None)
                {
                    var locationSpan = location.SourceSpan;
                    var lineSpan     = location.SourceTree.GetLineSpan(locationSpan);
                    lineNumber        = lineSpan.StartLinePosition.Line;
                    characterPosition = lineSpan.StartLinePosition.Character;
                    fileName          = location.SourceTree?.FilePath;
                }

                var diagnosticInfo = new DiagnosticInfo
                {
                    Id                = diagnostic.Id,
                    Message           = diagnostic.GetMessage(),
                    FileName          = fileName,
                    LineNumber        = lineNumber,
                    CharacterPosition = characterPosition,
                    Severity          = (DiagnosticInfo.DiagnosticInfoSeverity)diagnostic.Severity,
                    VersionSpan       = DiagnosticDescriptors.GetVersion(diagnostic.Descriptor)
                };

                foreach (var exporter in _exporters)
                {
                    exporter.AppendDiagnostic(diagnosticInfo);
                }
            }
        }