dotnet/roslyn

Improve file locations in the Roslyn Sarif reports for source generator files

开放

#51,773 创建于 2021年3月10日

 (2 条评论) (2 个反应) (0 位负责人)C# (4,257 个派生)batch import
Area-CompilersBugFeature - Source Generatorshelp wanted

仓库指标

星标
 (20,414 个星标)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 256 个 PR)

描述

Hello,

In the Roslyn Sarif reports the file locations for source generator code are not pointing to the right location on disk, even if EmitCompilerGeneratedFiles is set to true.

In SonarSource we parse these reports in order to import the raised issues and having the full path in the report (similar with the one for non generated code) will help us and the community write better tools which handle these files.

Expected Behavior:

{
  "ruleId": "S1144",
  "level": "warning",
  "message": "Remove the unused private method 'UnusedMethod'.",
  "locations": [
	{
	  "resultFile": {
		"uri": "file:///c:/src/SourceGeneratorPOC\SourceGeneratorPOC\obj\Debug\netcoreapp3.1\generated\SourceGeneratorPOC.Generators\SourceGeneratorPOC.SourceGenerator\Greetings.cs",
		"region": {
		  "startLine": 7,
		  "startColumn": 9,
		  "endLine": 7,
		  "endColumn": 47
		}
	  }
	}
  ],
}

Actual Behavior:

{
  "ruleId": "S1144",
  "level": "warning",
  "message": "Remove the unused private method 'UnusedMethod'.",
  "locations": [
	{
	  "resultFile": {
		"uri": "SourceGeneratorPOC.Generators/SourceGeneratorPOC.SourceGenerator/Greetings.cs",
		"region": {
		  "startLine": 7,
		  "startColumn": 9,
		  "endLine": 7,
		  "endColumn": 47
		}
	  }
	}
  ],
}

Thank you!

贡献者指南