Skip to content

Commit 1ece228

Browse files
authored
make the reports create directory like compliance (#5919)
1 parent 49f3606 commit 1ece228

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/Generators/Microsoft.Gen.MetadataExtractor/MetadataReportsGenerator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void Execute(GeneratorExecutionContext context)
8080
// Report diagnostic:
8181
var diagnostic = new DiagnosticDescriptor(
8282
DiagnosticIds.AuditReports.AUDREPGEN000,
83-
"MetricsReports generator couldn't resolve output path for the report. It won't be generated.",
83+
"MetadataReport generator couldn't resolve output path for the report. It won't be generated.",
8484
"Both <MetadataReportOutputPath> and <OutputPath> MSBuild properties are not set. The report won't be generated.",
8585
nameof(DiagnosticIds.AuditReports),
8686
DiagnosticSeverity.Info,
@@ -105,6 +105,8 @@ public void Execute(GeneratorExecutionContext context)
105105
.Append((string.IsNullOrEmpty(metadataReport.metricReport) ? "[]" : metadataReport.metricReport) + " }");
106106

107107
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
108+
_ = Directory.CreateDirectory(path);
109+
108110
File.WriteAllText(Path.Combine(path, _fileName), reportStringBuilder.ToString(), Encoding.UTF8);
109111
#pragma warning restore RS1035 // Do not use APIs banned for analyzers
110112

src/Generators/Microsoft.Gen.MetricsReports/MetricsReportsGenerator.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ public void Execute(GeneratorExecutionContext context)
8181
// Suppressing until this issue is addressed in https://github.com/dotnet/extensions/issues/5390
8282

8383
#pragma warning disable RS1035 // Do not use APIs banned for analyzers
84+
_ = Directory.CreateDirectory(path);
85+
8486
File.WriteAllText(Path.Combine(path, _fileName), report, Encoding.UTF8);
8587
#pragma warning restore RS1035 // Do not use APIs banned for analyzers
8688
}

test/Generators/Microsoft.Gen.MetadataExtractor/Unit/GeneratorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public async Task Should_UseProjectDir_WhenOutputPathIsRelative()
176176
var options = new Dictionary<string, string>
177177
{
178178
["build_property.projectdir"] = projectDir,
179-
["build_property.MetadataReportOutputPath"] = fullReportPath
179+
["build_property.outputpath"] = outputPath
180180
};
181181

182182
var diags = await RunGenerator(await File.ReadAllTextAsync(inputFile), options);

0 commit comments

Comments
 (0)