From eea0657119d06bbf1227b5cfe86fa5d5759635cb Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Thu, 14 Jan 2016 13:44:37 -0800 Subject: [PATCH] add one more entry to InvalidDiagnosticLocationReported to show diagnostic id. --- .../Core/Portable/CodeAnalysisResources.Designer.cs | 2 +- src/Compilers/Core/Portable/CodeAnalysisResources.resx | 2 +- .../DiagnosticAnalysisContextHelpers.cs | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs b/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs index 37be3b66281..a584bf6a4aa 100644 --- a/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs +++ b/src/Compilers/Core/Portable/CodeAnalysisResources.Designer.cs @@ -613,7 +613,7 @@ internal class CodeAnalysisResources { } /// - /// Looks up a localized string similar to Reported diagnostic has a source location in file '{0}', which is not part of the compilation being analyzed.. + /// Looks up a localized string similar to Reported diagnostic '{0}' has a source location in file '{1}', which is not part of the compilation being analyzed.. /// internal static string InvalidDiagnosticLocationReported { get { diff --git a/src/Compilers/Core/Portable/CodeAnalysisResources.resx b/src/Compilers/Core/Portable/CodeAnalysisResources.resx index 8bda1bd8e6e..31d313a9d19 100644 --- a/src/Compilers/Core/Portable/CodeAnalysisResources.resx +++ b/src/Compilers/Core/Portable/CodeAnalysisResources.resx @@ -420,7 +420,7 @@ Reported diagnostic has an ID '{0}', which is not a valid identifier. - Reported diagnostic has a source location in file '{0}', which is not part of the compilation being analyzed. + Reported diagnostic '{0}' has a source location in file '{1}', which is not part of the compilation being analyzed. Cannot deserialize type '{0}', no binder supplied. diff --git a/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContextHelpers.cs b/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContextHelpers.cs index 824aafa6561..afae45fcf92 100644 --- a/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContextHelpers.cs +++ b/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContextHelpers.cs @@ -54,28 +54,28 @@ internal static void VerifyArguments(Diagnostic diagnostic, Compilation compilat // Note that the parsing logic in Csc/Vbc MSBuild tasks to decode command line compiler output relies on diagnostics having a valid ID. // See https://github.com/dotnet/roslyn/issues/4376 for details. throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticIdReported, diagnostic.Id), nameof(diagnostic)); - } + } } internal static void VerifyDiagnosticLocationsInCompilation(Diagnostic diagnostic, Compilation compilation) { - VerifyDiagnosticLocationInCompilation(diagnostic.Location, compilation); + VerifyDiagnosticLocationInCompilation(diagnostic.Id, diagnostic.Location, compilation); if (diagnostic.AdditionalLocations != null) { foreach (var location in diagnostic.AdditionalLocations) { - VerifyDiagnosticLocationInCompilation(location, compilation); + VerifyDiagnosticLocationInCompilation(diagnostic.Id, diagnostic.Location, compilation); } } } - private static void VerifyDiagnosticLocationInCompilation(Location location, Compilation compilation) + private static void VerifyDiagnosticLocationInCompilation(string id, Location location, Compilation compilation) { if (location.IsInSource && !compilation.ContainsSyntaxTree(location.SourceTree)) { // Disallow diagnostics with source locations outside this compilation. - throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticLocationReported, location.SourceTree.FilePath), "diagnostic"); + throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticLocationReported, id, location.SourceTree.FilePath), "diagnostic"); } } -- GitLab