@@ -10,6 +10,25 @@ namespace Microsoft.Extensions.Validation.GeneratorTests;
1010[ UsesVerify ]
1111public partial class ValidationsGeneratorTests : ValidationsGeneratorTestBase
1212{
13+ private const string GeneratedAttributeSource = """
14+ // <auto-generated/>
15+ namespace Microsoft.CodeAnalysis
16+ {
17+ [global::System.AttributeUsage(global::System.AttributeTargets.All, AllowMultiple = true, Inherited = false)]
18+ internal sealed class EmbeddedAttribute : global::System.Attribute
19+ {
20+ }
21+ }
22+
23+ namespace Microsoft.Extensions.Validation.Embedded;
24+
25+ [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
26+ [global::System.AttributeUsage(global::System.AttributeTargets.Class)]
27+ internal sealed class ValidatableTypeAttribute : global::System.Attribute
28+ {
29+ }
30+ """ ;
31+
1332 [ Fact ]
1433 public async Task CanDiscoverGeneratedValidatableTypeAttribute ( )
1534 {
@@ -38,28 +57,8 @@ public class Customer
3857 app.Run();
3958 """ ;
4059
41- // Simulate the Razor SDK generating the attribute
42- var generatedAttributeSource = """
43- // <auto-generated/>
44- namespace Microsoft.CodeAnalysis
45- {
46- [global::System.AttributeUsage(global::System.AttributeTargets.All, AllowMultiple = true, Inherited = false)]
47- internal sealed class EmbeddedAttribute : global::System.Attribute
48- {
49- }
50- }
51-
52- namespace Microsoft.Extensions.Validation.Embedded;
53-
54- [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
55- [global::System.AttributeUsage(global::System.AttributeTargets.Class)]
56- internal sealed class ValidatableTypeAttribute : global::System.Attribute
57- {
58- }
59- """ ;
60-
6160 // Combine the generated attribute with the user's source
62- var combinedSource = generatedAttributeSource + "\n " + source ;
61+ var combinedSource = GeneratedAttributeSource + "\n " + source ;
6362
6463 await Verify ( combinedSource , out var compilation ) ;
6564 }
@@ -106,28 +105,8 @@ public class Product
106105 app.Run();
107106 """ ;
108107
109- // Simulate the Razor SDK generating the attribute
110- var generatedAttributeSource = """
111- // <auto-generated/>
112- namespace Microsoft.CodeAnalysis
113- {
114- [global::System.AttributeUsage(global::System.AttributeTargets.All, AllowMultiple = true, Inherited = false)]
115- internal sealed class EmbeddedAttribute : global::System.Attribute
116- {
117- }
118- }
119-
120- namespace Microsoft.Extensions.Validation.Embedded;
121-
122- [global::Microsoft.CodeAnalysis.EmbeddedAttribute]
123- [global::System.AttributeUsage(global::System.AttributeTargets.Class)]
124- internal sealed class ValidatableTypeAttribute : global::System.Attribute
125- {
126- }
127- """ ;
128-
129108 // Combine the generated attribute with the user's source
130- var combinedSource = generatedAttributeSource + "\n " + source ;
109+ var combinedSource = GeneratedAttributeSource + "\n " + source ;
131110
132111 await Verify ( combinedSource , out var compilation ) ;
133112 }
0 commit comments