@@ -11,7 +11,7 @@ public class ExampleTests
1111 [ MemberData ( nameof ( GetExamples ) ) ]
1212 public async Task ExamplesGeneratedCode ( CodeFileTheoryData theoryData )
1313 {
14- var builder = CreateCompilation < AutoConstructAttribute > ( theoryData ) ;
14+ var builder = CreateCompilation ( theoryData ) ;
1515 var compilation = await builder . Build ( nameof ( ExampleTests ) ) ;
1616 var driver = new GeneratorDriverBuilder ( )
1717 . AddGenerator ( new AutoConstructSourceGenerator ( ) )
@@ -28,7 +28,7 @@ await Verify(driver)
2828 [ MemberData ( nameof ( GetExamples ) ) ]
2929 public async Task CodeCompilesProperly ( CodeFileTheoryData theoryData )
3030 {
31- var builder = CreateCompilation < AutoConstructAttribute > ( theoryData ) ;
31+ var builder = CreateCompilation ( theoryData ) ;
3232 var compilation = await builder . Build ( nameof ( ExampleTests ) ) ;
3333 new GeneratorDriverBuilder ( )
3434 . AddGenerator ( new AutoConstructSourceGenerator ( ) )
@@ -44,7 +44,7 @@ public async Task CodeCompilesProperly(CodeFileTheoryData theoryData)
4444 [ MemberData ( nameof ( GetExamples ) ) ]
4545 public async Task EnsureRunsAreCachedCorrectly ( CodeFileTheoryData theoryData )
4646 {
47- var builder = CreateCompilation < AutoConstructAttribute > ( theoryData ) ;
47+ var builder = CreateCompilation ( theoryData ) ;
4848 var compilation = await builder . Build ( nameof ( ExampleTests ) ) ;
4949
5050 var driver = new GeneratorDriverBuilder ( )
@@ -71,6 +71,13 @@ public async Task EnsureRunsAreCachedCorrectly(CodeFileTheoryData theoryData)
7171
7272 // ----------------------------------------------------------------------------------------
7373
74+ private static CompilationBuilder CreateCompilation ( CodeFileTheoryData theoryData )
75+ {
76+ return CreateCompilation < AutoConstructAttribute > ( theoryData )
77+ . AddNugetReference (
78+ "Microsoft.Extensions.DependencyInjection.Abstractions" , "9.0.4" ) ;
79+ }
80+
7481 private static DirectoryInfo ? BaseDir { get ; } = new DirectoryInfo ( Environment . CurrentDirectory ) ? . Parent ? . Parent ;
7582
7683 private static IEnumerable < string > GetExamplesFiles ( string path ) => Directory . GetFiles ( Path . Combine ( BaseDir ? . FullName ?? "" , path ) , "*.cs" ) . Where ( e => ! e . Contains ( ".g." ) ) ;
0 commit comments