11using System . Text ;
2- using Microsoft . CodeAnalysis ;
3- using Microsoft . CodeAnalysis . CSharp . Syntax ;
42using Microsoft . CodeAnalysis . CSharp . Testing ;
53using Microsoft . CodeAnalysis . Testing ;
64
@@ -13,13 +11,6 @@ public async Task GenerateHandler()
1311 {
1412 var test = new StructIdGeneratorTest < DapperGenerator > ( "UserId" , "int" )
1513 {
16- SolutionTransforms =
17- {
18- ( solution , projectId ) => solution
19- . GetProject ( projectId ) ?
20- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Dapper . DbString ) . Assembly . ManifestModule . FullyQualifiedName ) )
21- . Solution ?? solution
22- } ,
2314 TestState =
2415 {
2516 Sources =
@@ -37,7 +28,8 @@ public async Task GenerateHandler()
3728 Encoding . UTF8 )
3829 } ,
3930 } ,
40- } . WithAnalyzerDefaults ( ) ;
31+ } . WithAnalyzerDefaults ( )
32+ . WithReferencePackages ( new PackageIdentity ( "Dapper" , "2.1.35" ) ) ;
4133
4234 await test . RunAsync ( ) ;
4335 }
@@ -47,13 +39,6 @@ public async Task GenerateStringHandler()
4739 {
4840 var test = new StructIdGeneratorTest < DapperGenerator > ( "UserId" , "string" )
4941 {
50- SolutionTransforms =
51- {
52- ( solution , projectId ) => solution
53- . GetProject ( projectId ) ?
54- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Dapper . DbString ) . Assembly . ManifestModule . FullyQualifiedName ) )
55- . Solution ?? solution
56- } ,
5742 TestState =
5843 {
5944 Sources =
@@ -71,7 +56,8 @@ public async Task GenerateStringHandler()
7156 Encoding . UTF8 )
7257 } ,
7358 } ,
74- } . WithAnalyzerDefaults ( ) ;
59+ } . WithAnalyzerDefaults ( )
60+ . WithReferencePackages ( new PackageIdentity ( "Dapper" , "2.1.35" ) ) ;
7561
7662 await test . RunAsync ( ) ;
7763 }
@@ -83,14 +69,6 @@ public async Task GenerateCustomHandler()
8369
8470 var test = new StructIdGeneratorTest < DapperGenerator > ( "UserId" , "System.Ulid" )
8571 {
86- SolutionTransforms =
87- {
88- ( solution , projectId ) => solution
89- . GetProject ( projectId ) ?
90- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Dapper . DbString ) . Assembly . Location ) )
91- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Ulid ) . Assembly . Location ) )
92- . Solution ?? solution
93- } ,
9472 TestState =
9573 {
9674 Sources =
@@ -127,7 +105,10 @@ public override void SetValue(IDbDataParameter parameter, Ulid value)
127105 ( typeof ( DapperGenerator ) , "DapperExtensions.cs" , code , Encoding . UTF8 )
128106 } ,
129107 } ,
130- } . WithAnalyzerDefaults ( ) ;
108+ } . WithAnalyzerDefaults ( )
109+ . WithReferencePackages (
110+ new PackageIdentity ( "Dapper" , "2.1.35" ) ,
111+ new PackageIdentity ( "Ulid" , "1.3.4" ) ) ;
131112
132113 await test . RunAsync ( ) ;
133114 }
@@ -151,14 +132,6 @@ public override void SetValue(IDbDataParameter parameter, System.Ulid value)
151132
152133 var test = new StructIdGeneratorTest < DapperGenerator > ( "UserId" , "System.Ulid" )
153134 {
154- SolutionTransforms =
155- {
156- ( solution , projectId ) => solution
157- . GetProject ( projectId ) ?
158- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Dapper . DbString ) . Assembly . Location ) )
159- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Ulid ) . Assembly . Location ) )
160- . Solution ?? solution
161- } ,
162135 TestState =
163136 {
164137 Sources =
@@ -176,7 +149,10 @@ public override void SetValue(IDbDataParameter parameter, System.Ulid value)
176149 ( typeof ( DapperGenerator ) , "DapperExtensions.cs" , code , Encoding . UTF8 )
177150 } ,
178151 } ,
179- } . WithAnalyzerDefaults ( ) ;
152+ } . WithAnalyzerDefaults ( )
153+ . WithReferencePackages (
154+ new PackageIdentity ( "Dapper" , "2.1.35" ) ,
155+ new PackageIdentity ( "Ulid" , "1.3.4" ) ) ;
180156
181157 await test . RunAsync ( ) ;
182158 }
@@ -187,13 +163,6 @@ public async Task SkipsUnsupported()
187163 var test = new CSharpSourceGeneratorTest < DapperGenerator , DefaultVerifier >
188164 {
189165 ReferenceAssemblies = ReferenceAssemblies . Net . Net80 ,
190- SolutionTransforms =
191- {
192- ( solution , projectId ) => solution
193- . GetProject ( projectId ) ?
194- . AddMetadataReference ( MetadataReference . CreateFromFile ( typeof ( Dapper . DbString ) . Assembly . ManifestModule . FullyQualifiedName ) )
195- . Solution ?? solution
196- } ,
197166 TestState =
198167 {
199168 Sources =
@@ -208,7 +177,8 @@ public readonly partial record struct UserId(uint Value) : IStructId<uint>, INew
208177 """ ,
209178 } ,
210179 } ,
211- } . WithAnalyzerDefaults ( ) ;
180+ } . WithAnalyzerDefaults ( )
181+ . WithReferencePackages ( new PackageIdentity ( "Dapper" , "2.1.35" ) ) ;
212182
213183 await test . RunAsync ( ) ;
214184 }
0 commit comments