Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors while parsing invalid SuppressMessage Target #44315

Open
sbomer opened this issue May 16, 2020 · 1 comment
Open

Errors while parsing invalid SuppressMessage Target #44315

sbomer opened this issue May 16, 2020 · 1 comment
Labels
Area-Compilers Tenet-Reliability Customer telemetry indicates that the product is failing in a crash/hang/dataloss manner.

Comments

@sbomer
Copy link
Member

sbomer commented May 16, 2020

Version Used:
SDK version 5.0.100-preview.2.20177.6
Microsoft.CodeAnalysis.FxCopAnalyzers: 3.0.0

Steps to Reproduce:

Run dotnet build on the following source with the FxCop analyzer.
suppress_repro.tar.gz

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

// these cause an IndexOutOfRangeException
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="M:A`1.M``1(``2147483648)")]
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="M:A`1.M``1(`1)")]
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="M:A`1.M``1(`2147483648)")]

// these work but seem like they shouldn't
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="MA`1.M``1(System.Collections.Generic.List{System.Int32})")]
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="MA`1.M``1(System.Collections.Generic.List{System.Int32}")]
[assembly:SuppressMessage("", "CA1031", Scope="member", Target="MA`1.M``1(System.Collections.Generic.List{System.Int32)")]

public class A<T> {
    public void M<TM> (List<int> i) {
        Console.WriteLine(i);
        try {} catch (Exception) {}
    }
}
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error : Unhandled exception. System.AggregateException: One or more errors occurred. (Index was outside the bounds of the array.)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :  ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseTypeParameterSymbol(String id, Int32& index, ISymbol typeParameterContext, List`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseTypeSymbol(String id, Int32& index, Compilation compilation, ISymbol typeParameterContext, List`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseTypeSymbol(String id, Int32& index, Compilation compilation, ISymbol typeParameterContext)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseParameter(String id, Int32& index, Compilation compilation, ISymbol typeParameterContext)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseParameterList(String id, Int32& index, Compilation compilation, ISymbol typeParameterContext, List`1 parameters)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.GetMatchingMethods(String id, Int32& index, List`1 containers, String memberName, Int32 arity, Compilation compilation, List`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseDeclaredId(String id, Int32& index, Compilation compilation, List`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.Parser.ParseDeclaredSymbolId(String id, Compilation compilation, List`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.DocumentationCommentId.GetSymbolsForDeclarationId(String id, Compilation compilation)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.TargetSymbolResolver.Resolve(IList`1 results)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.ResolveTargetSymbols(Compilation compilation, String target, TargetScope scope)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.DecodeGlobalSuppressMessageAttributes(Compilation compilation, ISymbol symbol, GlobalSuppressions globalSuppressions, IEnumerable`1 attributes)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.DecodeGlobalSuppressMessageAttributes(Compilation compilation, ISymbol symbol, GlobalSuppressions globalSuppressions)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.DecodeGlobalSuppressMessageAttributes()
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.SuppressMessageAttributeState.IsDiagnosticSuppressed(Diagnostic diagnostic, Func`3 getSemanticModel, SuppressMessageInfo& info)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.Diagnostics.AnalyzerDriver.GetDiagnosticsAsync(Compilation compilation)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    --- End of inner exception stack trace ---
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at System.Threading.Tasks.Task`1.get_Result()
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.CompileAndEmit(TouchedFileLogger touchedFilesLogger, Compilation& compilation, ImmutableArray`1 analyzers, ImmutableArray`1 additionalTextFiles, AnalyzerConfigSet analyzerConfigSet, ImmutableArray`1 sourceFileAnalyzerConfigOptions, ImmutableArray`1 embeddedTexts, DiagnosticBag diagnostics, CancellationToken cancellationToken, CancellationTokenSource& analyzerCts, Boolean& reportAnalyzer, AnalyzerDriver& analyzerDriver)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.RunCore(TextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommonCompiler.Run(TextWriter consoleOutput, CancellationToken cancellationToken)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.<>c__DisplayClass1_0.<Run>b__0(TextWriter tw)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommandLine.ConsoleUtil.RunWithUtf8Output[T](Boolean utf8Output, TextWriter textWriter, Func`2 func)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Csc.Run(String[] args, BuildPaths buildPaths, TextWriter textWriter, IAnalyzerAssemblyLoader analyzerLoader)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunLocalCompilation(String[] arguments, BuildPaths buildPaths, TextWriter textWriter)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.RunCompilation(IEnumerable`1 originalArguments, BuildPaths buildPaths, TextWriter textWriter, String pipeName)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CommandLine.BuildClient.Run(IEnumerable`1 arguments, RequestLanguage language, CompileFunc compileFunc)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.MainCore(String[] args)
sdk/5.0.100-preview.2.20177.6/Roslyn/Microsoft.CSharp.Core.targets(59,5): error :    at Microsoft.CodeAnalysis.CSharp.CommandLine.Program.Main(String[] args)
@gafter gafter added Area-Compilers Tenet-Reliability Customer telemetry indicates that the product is failing in a crash/hang/dataloss manner. labels May 18, 2020
@sbomer
Copy link
Member Author

sbomer commented May 21, 2020

More strange cases that work:

[assembly:SuppressMessage("", "CA1051", Scope="member", Target="F:A`1.field`gibberish")]
[assembly:SuppressMessage("", "CA1051", Scope="member", Target="F:A`1.field(gibberish")]
[assembly:SuppressMessage("", "CA1051", Scope="member", Target="T:A`1{")]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Tenet-Reliability Customer telemetry indicates that the product is failing in a crash/hang/dataloss manner.
Projects
None yet
Development

No branches or pull requests

2 participants