提交 eea06571 编写于 作者: H Heejae Chang

add one more entry to InvalidDiagnosticLocationReported to show diagnostic id.

上级 eec2fc98
......@@ -613,7 +613,7 @@ internal class CodeAnalysisResources {
}
/// <summary>
/// Looks up a localized string similar to Reported diagnostic has a source location in file &apos;{0}&apos;, which is not part of the compilation being analyzed..
/// Looks up a localized string similar to Reported diagnostic &apos;{0}&apos; has a source location in file &apos;{1}&apos;, which is not part of the compilation being analyzed..
/// </summary>
internal static string InvalidDiagnosticLocationReported {
get {
......
......@@ -420,7 +420,7 @@
<value>Reported diagnostic has an ID '{0}', which is not a valid identifier.</value>
</data>
<data name="InvalidDiagnosticLocationReported" xml:space="preserve">
<value>Reported diagnostic has a source location in file '{0}', which is not part of the compilation being analyzed.</value>
<value>Reported diagnostic '{0}' has a source location in file '{1}', which is not part of the compilation being analyzed.</value>
</data>
<data name="NoBinderException" xml:space="preserve">
<value>Cannot deserialize type '{0}', no binder supplied.</value>
......
......@@ -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");
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册