diff --git a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing/SourceGeneratorTest`1.cs b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing/SourceGeneratorTest`1.cs index 2fd0206cf..7120b5256 100644 --- a/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing/SourceGeneratorTest`1.cs +++ b/src/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing/SourceGeneratorTest`1.cs @@ -60,8 +60,6 @@ protected override IEnumerable GetDiagnosticAnalyzers() public override async Task RunAsync(CancellationToken cancellationToken = default) { - Verify.NotEmpty($"{nameof(TestState)}.{nameof(SolutionState.Sources)}", TestState.Sources); - var analyzers = GetDiagnosticAnalyzers().ToArray(); var defaultDiagnostic = GetDefaultDiagnostic(analyzers); var supportedDiagnostics = analyzers.SelectMany(analyzer => analyzer.SupportedDiagnostics).ToImmutableArray(); diff --git a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing.UnitTests/SourceGeneratorValidationTests.cs b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing.UnitTests/SourceGeneratorValidationTests.cs index d2db670ae..b226e905f 100644 --- a/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing.UnitTests/SourceGeneratorValidationTests.cs +++ b/tests/Microsoft.CodeAnalysis.Testing/Microsoft.CodeAnalysis.SourceGenerators.Testing.UnitTests/SourceGeneratorValidationTests.cs @@ -84,6 +84,27 @@ public async Task AddSimpleFileByGeneratorTypeWithEncoding() }.RunAsync(); } + [Fact] + public async Task AddSimpleFileToEmptyProject() + { + await new CSharpSourceGeneratorTest + { + TestState = + { + Sources = + { + }, + }, + FixedState = + { + Sources = + { + (typeof(AddEmptyFile), "EmptyGeneratedFile.cs", string.Empty), + }, + }, + }.RunAsync(); + } + [Fact] public async Task AddSimpleFileWithDiagnostic() {