-
Notifications
You must be signed in to change notification settings - Fork 128
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
Output illink messages without --verbose #1030
Comments
Errors and Warnings should be reported always, even on I wonder if we could somehow hook into the |
I agree but that means we need a solution to suppress the warnings which also means to add UI to all VS-es for that. NuGet seems to allow that on package level which I think is not we want. |
Not sure about the UI for this, but it apparently can be specified globally as well: https://github.com/microsoft/msbuild/blob/a4878e187d0640ee79b7cdc12c640f68e28a326b/Directory.Build.props#L54 |
Oh, I didn't know they hacked into compiler warnings. This looks like prior art for us then which we can "just" use if we validate that the NU* prefix is not embedded anywhere in VS. |
I don't think we should feed in the MSBuild verbosity anywhere - rather, we should just make sure that our task uses stdout/stderr in a reasonable way, and formats warnings/errors how MSBuild expects them when it's being run from the task. ToolTask is already designed to assign reasonable MSBuild MessageImportance to various bits of output, in a way that makes sense with the default logger (which treats MessageImportance according to https://docs.microsoft.com/en-us/visualstudio/msbuild/obtaining-build-logs-with-msbuild?view=vs-2019#verbosity-settings). For us that means:
The importance of stdout/stderr can be changed if we prefer a different behavior. IMO we might want to make Stdout have MessageImportance.Normal, so that it is visible with "normal" verbosity (with the default importance of Low, it shows up only at detailed+, in a dark grey that is hard to read against a black background). We should then make sure that stdout and stderr by default only show messages we care about, and an extra property (say |
Also, apparently MSBuild intentionally doesn't provide a way to get the current verbosity |
This makes sense to me, we should tweak the msbuild output to respect that. Does it also mean the error/warning should go to stderr?
Please don't, that would complicate things with no good reason |
I agree that we should not have any logging which doesn't fall directly into one of the MSBuild categories. If there's a need for a more detailed trace, we can introduce a separate solution which produces this information to a file. But the existing support for dependency tracing is kind of already that. We could always extend that if needed. |
Actually, I forgot that @tlakollo already changed the stderr importance to High in https://github.com/mono/linker/pull/719/files. So currently text logged to stderr will be visible at minimal+ (minimal is the default verbosity at least when building from the command-line, if it's not specified), and text logged to stdout will be visible at normal+.
It doesn't matter for MSBuild - anything from stderr or stdout that is parsed as a warning/error will be treated as such independently (and it will only show up once in the output). I think it would make sense to log warnings/errors about "linker-unfriendly" code patterns to stdout, and internal errors, improper command-lines, malformed xml, diagnostics, etc. to stderr. That way when running from the command-line you can easily redirect warnings from code analysis to a separate file, while separately seeing tool errors/diagnostics output to console.
This was just to say that if we have a "--verbose" flag that includes extra diagnostics or similar, there should be a corresponding way to turn that on from the task. To keep this simple, I think we shouldn't change the content of what we log based on whether we are running from MSBuild - we should only change the format of warnings/errors so they are properly picked up. The way I imagine this working is that we would have something like the following helpers (or you could do it by defining a MessageKind or similar - I'm not trying to suggest the exact shape):
|
I looked into the suppression mechanism. The VS options from @vitek-karas's screenshot map to MSBuild properties There's also a new set of MSBuild properties like For the end-to-end experience, I suggest we rely on dotnet/msbuild#4421 which would make |
I don't think we should go this way all error and warnings including ones from custom steps should output the same way. The code analysis will most likely have its own switch if someone want to hide/show it they use the switch.
We have now this and I think it's sufficient, don't see any good reason for adding |
@sbomer Regarding the msbuild integration - if we can get the required functionality it would work great. The question is if we can get that funded and in time. Can you please reach out to the msbuild owners to figure it out? |
In that case, the existing
That sounds good, as long as the code analysis warnings, when they are on, are formatted as MSBuild warnings (presumably using Would
There's no supported way to get the current MSBuild verbosity from a task, so we can't exactly filter based on the MSBuild verbosity. We can filter based on our own verbosity flags, and we can decide what I think all we need to do here is to decide which messages go to stdout/stderr, and decide on a |
I changed the title to reflect the remaining work. @mateoatr's work on the new diagnostic infrastructure means that the warnings/errors are getting the right MSBuild importance, and there is a mechanism (
|
I think we need solutions for two scenarios here:
|
Agreed, hopefully we can fit it in.
Why do you suggest The argument I can see is that the "trim analysis" should be a separate category rather than a version. I do think it makes sense to have independent controls "version" and "analysis kind" (or "category") for warning behavior, but we have been going back and forth on the categories for a bit now. In my mind the definition of the "trim analysis" warning set should ultimately live in illink.dll, not in the SDK; using |
My reading/understanding of the warning level as designed for Roslyn is that it's not about default experiences for particular application, it's about warning behavior across major versions of the product (making sure that new SDKs don't break old apps and make this explicit). The fact that we disable trim analysis warnings by default now is a point-in-time decision based on the state of the product. In theory we may enable some of these in later 5.* release (very unlikely, but that's not the point). Trim analysis warnings will essentially work the same way in .NET 5 and in .NET 6 (we just hope that framework and other code will be more ready for it). This is similar to nullability warnings in Roslyn - I don't think warning level has anything specific for nullability - enabling or disabling nullability warnings is orthogonal to warning level. For example in .NET 5 all of framework is nullable-annotated (unlike 3.1) - does that mean we should enable nullability warnings for everything in .NET 5 apps (including application code)? Definitely no - but that has no tie to warning version - at least for me. I know we've been struggling with the analysis warning categorization - but to me that's a completely distinct problem from warning levels - tying them together is just "an easy way out" which I fear will hurt us in the future. In a way I agree that analysis warning categorization sort of belongs to the linker itself, but in reality it doesn't matter - the warnings are essentially part of public API and thus are "set in stone" - as in "Does IL2047 belong to 'trim correctness analysis' category?" will have the same answer in .NET 5 as well as in .NET 6 and any future release. So I'm fine if it's easier for us to currently encode this knowledge into the SDK and later on (in .NET 6 for example) we could move this down to the linker if that makes more sense. Additionally if we hide trim analysis warnings behind warning version as per the above we can run into this:
|
I think we fundamentally agree about the purpose of versions, and that single-file for example needs to be covered by an additional category, not just versions - I am not suggesting to use versions in place of categories. Since we only have the one category of warnings related to trimming in .NET5, and since we haven't designed the categories, effectively what I'm suggesting is to treat the defaults as "trim analysis is on, with only a subset of the warnings enabled in v5 (including warnings about incorrectly used attributes, but not Treating the defaults as "trim analysis is off in .NET5, but you can turn all trim analysis warnings on with a flag" makes sense too. I am also ok with temporarily defining that category in the SDK. I think the discussion then hinges on what belongs in the trim analysis category. I opened a new issue to discuss that: #1367 |
We need to propagate msbuild verbose level (-verbosity:level option) into illink.
The proposed mapping between msbuild verbosity and MessageCategory
q[uiet] >= MessageCategory.Error (not sure about this one)d[etailed] >= MessageCategory.Info
diag[nostic] >= MessageCategory.Diagnostic
This should be done for illink task only, the command line interface for illink should still use
-v
to print everything@vitek-karas how do you plan to use warning? If we go with an explicit
-nowarn
option we would need to expose that on VS UI.The text was updated successfully, but these errors were encountered: