Skip to content

Commit

Permalink
Add output compilation verification
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Dec 30, 2024
1 parent 6af9ad1 commit 5a6dca9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ class C { }
}));

GeneratorDriver driver = CSharpGeneratorDriver.Create([generator], parseOptions: parseOptions, driverOptions: TestOptions.GeneratorDriverOptions);
driver = driver.RunGenerators(compilation);
driver = driver.RunGeneratorsAndUpdateCompilation(compilation, out var outputCompilation, out _);
var runResult = driver.GetRunResult().Results[0];

Assert.Single(runResult.GeneratedSources);
Expand All @@ -2480,6 +2480,8 @@ internal sealed partial class EmbeddedAttribute : global::System.Attribute
}
""", generatedSource.SourceText.ToString());
Assert.Equal("Microsoft.CodeAnalysis.EmbeddedAttribute.cs", generatedSource.HintName);

outputCompilation.VerifyDiagnostics();
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,9 @@ End Class
End Sub))

Check failure on line 646 in src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb#L646

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb(646,90): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 646 in src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb

View check run for this annotation

Azure Pipelines / roslyn-CI

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb#L646

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb(646,90): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 647 in src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb

View check run for this annotation

Azure Pipelines / roslyn-CI (Correctness Correctness_Analyzers)

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb#L647

src/Compilers/VisualBasic/Test/Semantic/SourceGeneration/GeneratorDriverTests.vb(647,1): error IDE0055: (NETCORE_ENGINEERING_TELEMETRY=Build) Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
Dim driver As GeneratorDriver = VisualBasicGeneratorDriver.Create(ImmutableArray.Create(Of ISourceGenerator)(generator), parseOptions:=parseOptions, driverOptions:=TestOptions.GeneratorDriverOptions)
driver = driver.RunGenerators(compilation)
Dim outputCompilation As Compilation = Nothing
Dim diagnostics As ImmutableArray(Of Diagnostic) = Nothing
driver = driver.RunGeneratorsAndUpdateCompilation(compilation, outputCompilation, diagnostics)
Dim runResult = driver.GetRunResult().Results(0)

Assert.Single(runResult.GeneratedSources)
Expand All @@ -659,6 +661,8 @@ End Class
End Class
End Namespace", generatedSource.SourceText.ToString())
Assert.Equal("Microsoft.CodeAnalysis.EmbeddedAttribute.vb", generatedSource.HintName)

outputCompilation.VerifyDiagnostics()
End Sub

<Fact>
Expand Down

0 comments on commit 5a6dca9

Please sign in to comment.