Commit 2392c79
Fix terminal logger quiet mode to show project context for warnings/errors (#12930)
### Context
In quiet mode (`-v:q`), warnings and errors were rendered immediately
without project context. Users saw diagnostic messages but couldn't
identify which project they came from.
```
CSC : warning MSTEST0001: Explicitly enable or disable tests parallelization
```
### Changes Made
**Modified diagnostic accumulation logic**
- `WarningRaised` and `ErrorRaised` now accumulate diagnostics in the
project's `BuildMessages` collection regardless of verbosity
- Removed verbosity check that caused immediate rendering in quiet mode
- Preserved immediate rendering for auth provider warnings and immediate
warnings (MSB3026)
**Modified project summary rendering**
- `ProjectFinished` now displays project summaries in quiet mode when
`HasErrorsOrWarnings` is true
- Projects without diagnostics remain hidden in quiet mode as expected
- Simplified quiet mode detection logic: `Verbosity <
LoggerVerbosity.Quiet || (Verbosity == LoggerVerbosity.Quiet &&
!project.HasErrorsOrWarnings)`
- Skip `DisplayNodes()` call in quiet mode to avoid writing unnecessary
cursor hide/show ANSI codes since there's no dynamic refresh
**Result in quiet mode:**
```
project failed with 1 error(s) and 2 warning(s) (0.2s)
directory/file(1,2,3,4): warning AA0000: Warning message
directory/file(1,2,3,4): error AA0000: Error message
```
### Testing
- Updated snapshot files for
`PrintBuildSummaryQuietVerbosity_FailedWithErrors` across
Linux/OSX/Windows
- All 69 TerminalLogger tests pass
- Verified successful projects still produce no output in quiet mode
- Verified no cursor control codes are written in quiet mode output
### Notes
Uses the same project-grouping primitives as higher verbosity levels,
toggled by runtime state per maintainer guidance.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Terminal logger quiet mode hides projects</issue_title>
> <issue_description>This was reported by @gao-artur in
microsoft/testfx#7051
>
> > Here is a new project created from the MSTest template without
`MSTestSettings.cs` file + the binlog. Built with
> >
> > `dotnet build -bl -v q`
> >
[TestProject11.zip](https://github.com/user-attachments/files/23968849/TestProject11.zip)
>
> In that thread we determined that `-tl` status affects the usefulness
of the output for messages that do not have a specific file associated
with them:
>
> ```sh-session
> ❯ dotnet build
> Restore complete (4.0s)
> TestProject11 net9.0 succeeded with 1 warning(s) (2.3s) →
bin\Debug\net9.0\TestProject11.dll
> CSC : warning MSTEST0001: Explicitly enable or disable tests
parallelization
(https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0001)
>
> Build succeeded with 1 warning(s) in 7.2s
>
> ❯ rm -r .\obj\
>
> ❯ dotnet build -v:q
> CSC : warning MSTEST0001: Explicitly enable or disable tests
parallelization
(https://learn.microsoft.com/dotnet/core/testing/mstest-analyzers/mstest0001)
> ```
>
> The associated project `TestProject11` is not mentioned anywhere in
the latter. I think that's unreasonable even when the user has requested
"quiet".</issue_description>
>
> <agent_instructions>Try to update the diagnostic/warning/error message
rendering in quiet mode so that it doesn't use the 'immediate' mode
formatting, the final output should only show the diagnostics for
projects that failed or had warnings.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> <comment_new><author>@baronfel</author><body>
> A few approaches to consider:
>
> * in quiet mode appending/prepending the project if it exists to the
'message formatting' part of the line
> * in quiet mode using the same project-based grouping as we do in
non-quiet mode, instead of assuming that quiet mode should trigger some
kind of flat-list-only output</body></comment_new>
> <comment_new><author>@rainersigwald</author><body>
> Yeah I waffled between the two myself, I think I lean to the latter
right now though.</body></comment_new>
> <comment_new><author>@baronfel</author><body>
> I do too - it feels more like a 'modular' approach - use the same
'primitives' that can be toggled on/off based on run-time state,
etc.</body></comment_new>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #12929
<!-- START COPILOT CODING AGENT TIPS -->
---
💬 We'd love your input! Share your thoughts on Copilot coding agent in
our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: baronfel <[email protected]>
Co-authored-by: Chet Husk <[email protected]>
Co-authored-by: Copilot <[email protected]>1 parent fb77584 commit 2392c79
File tree
4 files changed
+45
-38
lines changed- src
- Build.UnitTests/Snapshots
- Build/Logging/TerminalLogger
4 files changed
+45
-38
lines changedLines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
Lines changed: 8 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | 757 | | |
764 | 758 | | |
765 | 759 | | |
766 | 760 | | |
767 | 761 | | |
768 | 762 | | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
769 | 774 | | |
770 | 775 | | |
771 | 776 | | |
| |||
809 | 814 | | |
810 | 815 | | |
811 | 816 | | |
| 817 | + | |
812 | 818 | | |
813 | 819 | | |
814 | 820 | | |
| |||
839 | 845 | | |
840 | 846 | | |
841 | 847 | | |
842 | | - | |
| 848 | + | |
843 | 849 | | |
844 | 850 | | |
845 | 851 | | |
| |||
1300 | 1306 | | |
1301 | 1307 | | |
1302 | 1308 | | |
1303 | | - | |
1304 | | - | |
| 1309 | + | |
1305 | 1310 | | |
1306 | 1311 | | |
1307 | 1312 | | |
1308 | | - | |
| 1313 | + | |
1309 | 1314 | | |
1310 | 1315 | | |
1311 | 1316 | | |
1312 | 1317 | | |
1313 | 1318 | | |
1314 | 1319 | | |
| 1320 | + | |
1315 | 1321 | | |
1316 | 1322 | | |
1317 | 1323 | | |
1318 | 1324 | | |
1319 | 1325 | | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
| 1326 | + | |
1324 | 1327 | | |
1325 | 1328 | | |
1326 | 1329 | | |
| |||
1385 | 1388 | | |
1386 | 1389 | | |
1387 | 1390 | | |
1388 | | - | |
1389 | | - | |
| 1391 | + | |
1390 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
1391 | 1395 | | |
1392 | 1396 | | |
1393 | 1397 | | |
1394 | 1398 | | |
1395 | | - | |
| 1399 | + | |
1396 | 1400 | | |
1397 | 1401 | | |
1398 | 1402 | | |
| |||
0 commit comments