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

[CLI] Include compiler diagnostics in the xml output file of the roslynator analyze command #963

Closed
PeterKaszab opened this issue Oct 13, 2022 · 0 comments · Fixed by #964
Labels

Comments

@PeterKaszab
Copy link
Contributor

PeterKaszab commented Oct 13, 2022

Product and Version Used:
Roslynator.DotNet.Cli 0.3.3.0

Steps to Reproduce:

  1. Create a new console application
  2. Place the following class to the Program.cs file:
namespace ConsoleApp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int x, y;
            Console.WriteLine("Hello, World!");
        }

        public int Add(int x, int y)
        {
            return x + y;
        }
    }
}
  1. Run roslyn analyze path\to\solution\ConsoleApp.sln --output out.xml ( The --ignore-compiler-diagnostics parameter is not provided.)

Actual Behavior:
The compiler diagnostics are missing from the list of project diagnostics, but they are present in the summary. Console and text file loggers list the mentioned diagnostics correctly.

<?xml version="1.0" encoding="utf-8"?>
<Roslynator>
  <CodeAnalysis>
    <Summary>
      <Diagnostic Id="CA1822" Title="Mark members as static" Count="1" />
      <Diagnostic Id="CS0168" Title="Variable is declared but never used" Count="2" />
    </Summary>
    <Projects>
      <Project Name="ConsoleApp" FilePath="C:\ConsoleApp\ConsoleApp\ConsoleApp.csproj">
        <Diagnostics>
          <Diagnostic Id="CA1822">
            <Severity>Info</Severity>
            <Message>Mark members as static</Message>
            <FilePath>C:\ConsoleApp\ConsoleApp\Program.cs</FilePath>
            <Location Line="11" Character="20" />
          </Diagnostic>
        </Diagnostics>
      </Project>
    </Projects>
  </CodeAnalysis>
</Roslynator>

Expected Behavior:

<?xml version="1.0" encoding="utf-8"?>
<Roslynator>
  <CodeAnalysis>
    <Summary>
      <Diagnostic Id="CA1822" Title="Mark members as static" Count="1" />
      <Diagnostic Id="CS0168" Title="Variable is declared but never used" Count="2" />
    </Summary>
    <Projects>
      <Project Name="ConsoleApp" FilePath="C:\ConsoleApp\ConsoleApp\ConsoleApp.csproj">
        <Diagnostics>
          <Diagnostic Id="CA1822">
            <Severity>Info</Severity>
            <Message>Mark members as static</Message>
            <FilePath>C:\ConsoleApp\ConsoleApp\Program.cs</FilePath>
            <Location Line="11" Character="20" />
          </Diagnostic>
          <Diagnostic Id="CS0168">
            <Severity>Warning</Severity>
            <Message>Variable is declared but never used</Message>
            <FilePath>C:\ConsoleApp\ConsoleApp\Program.cs</FilePath>
            <Location Line="7" Character="17" />
          </Diagnostic>
          <Diagnostic Id="CS0168">
            <Severity>Warning</Severity>
            <Message>Variable is declared but never used</Message>
            <FilePath>C:\ConsoleApp\ConsoleApp\Program.cs</FilePath>
            <Location Line="7" Character="20" />
          </Diagnostic>
        </Diagnostics>
      </Project>
    </Projects>
  </CodeAnalysis>
</Roslynator>
@PeterKaszab PeterKaszab changed the title CLI: Include compiler diagnostics in the xml output file of the roslynator analyze command [CLI] Include compiler diagnostics in the xml output file of the roslynator analyze command Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants