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

Fix reporting of MSBuild warnings in MSBuildWorkspace #75183

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/Workspaces/Core/MSBuild/MSBuild/DiagnosticReporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,25 @@ public void Report(IEnumerable<DiagnosticLogItem> log)
{
foreach (var logItem in log)
{
Report(DiagnosticReportingMode.Log, GetMSBuildFailedMessage(logItem.ProjectFilePath, logItem.ToString()));
var diagnosticKind = logItem.Kind is DiagnosticLogItemKind.Warning ? WorkspaceDiagnosticKind.Warning : WorkspaceDiagnosticKind.Failure;

Report(new WorkspaceDiagnostic(diagnosticKind, GetMSBuildFailedMessage(logItem.ProjectFilePath, logItem.ToString(), diagnosticKind)));
}
}

private static string GetMSBuildFailedMessage(string projectFilePath, string message)
=> RoslynString.IsNullOrWhiteSpace(message)
? string.Format(WorkspaceMSBuildResources.Msbuild_failed_when_processing_the_file_0, projectFilePath)
: string.Format(WorkspaceMSBuildResources.Msbuild_failed_when_processing_the_file_0_with_message_1, projectFilePath, message);
private static string GetMSBuildFailedMessage(string projectFilePath, string message, WorkspaceDiagnosticKind diagnosticKind)
{
if (RoslynString.IsNullOrWhiteSpace(message))
{
message = WorkspaceMSBuildResources.No_message;
}

return string.Format(
diagnosticKind == WorkspaceDiagnosticKind.Warning
? WorkspaceMSBuildResources.Msbuild_warned_when_processing_the_file_0_with_message_1
: WorkspaceMSBuildResources.Msbuild_failed_when_processing_the_file_0_with_message_1,
projectFilePath,
message);
}
}
}
11 changes: 7 additions & 4 deletions src/Workspaces/Core/MSBuild/WorkspaceMSBuildResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@
<data name="Invalid_0_specified_1" xml:space="preserve">
<value>Invalid {0} specified: {1}</value>
</data>
<data name="Msbuild_failed_when_processing_the_file_0" xml:space="preserve">
<value>Msbuild failed when processing the file '{0}'</value>
</data>
<data name="Msbuild_failed_when_processing_the_file_0_with_message_1" xml:space="preserve">
<value>Msbuild failed when processing the file '{0}' with message: {1}</value>
<value>MSBuild failed when processing the file '{0}' with message: {1}</value>
</data>
<data name="Msbuild_warned_when_processing_the_file_0_with_message_1" xml:space="preserve">
<value>MSBuild warned when processing the file '{0}' with message: {1}</value>
</data>
<data name="No_message" xml:space="preserve">
<value>No message</value>
</data>
<data name="Path_for_document_0_was_null" xml:space="preserve">
<value>Path for document '{0}' was null</value>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading