-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Correctly respect NoWarn CLI/Task options in Compatibility logging interface #46061
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
Changes from 2 commits
b242e3e
212b97e
6501f41
39d4369
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,10 @@ | |
| /// <summary> | ||
| /// Class to define common logging abstraction to the console across the APICompat and GenAPI codebases. | ||
| /// </summary> | ||
| public class ConsoleLog(MessageImportance messageImportance) : ILog | ||
| public class ConsoleLog(MessageImportance messageImportance, string? noWarn = null) : ILog | ||
| { | ||
| private readonly HashSet<string> _noWarn = string.IsNullOrEmpty(noWarn) ? [] : new(noWarn!.Split(';')); | ||
|
|
||
| /// <inheritdoc /> | ||
| public bool HasLoggedErrors { get; private set; } | ||
|
|
||
|
|
@@ -30,8 +32,20 @@ | |
| Console.WriteLine(message); | ||
|
|
||
| /// <inheritdoc /> | ||
| public virtual void LogWarning(string code, string message) => | ||
| Console.WriteLine($"{code}: {message}"); | ||
| public virtual void LogWarning(string code, string message) | ||
| { | ||
| string messageTextWithCode = $"{code}: {message}"; | ||
|
|
||
| // Mimic MSBuild which logs suppressed warnings as low importance messages. | ||
| if (_noWarn.Contains(code)) | ||
| { | ||
| LogMessage(MessageImportance.Low, messageTextWithCode) | ||
|
Check failure on line 42 in src/Compatibility/Microsoft.DotNet.ApiSymbolExtensions/Logging/ConsoleLog.cs
|
||
carlossanlop marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| else | ||
| { | ||
| Console.WriteLine(messageTextWithCode); | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Considering we now know this code can break consumers like it happened with aspnetcore, I think we should have a couple tests to verify the behavior.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. I filed #46062 to track adding a new test project for the apicompat global tool. |
||
|
|
||
| /// <inheritdoc /> | ||
| public virtual void LogMessage(string message) => | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.