@@ -25,12 +25,12 @@ public void Can_generate_for_default_controller()
25
25
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
26
26
. InNamespace ( "ExampleApi.Models" )
27
27
. WithCode ( @"
28
- [Resource]
29
- public sealed class Item : Identifiable<long>
30
- {
31
- [Attr]
32
- public int Value { get; set; }
33
- }" )
28
+ [Resource]
29
+ public sealed class Item : Identifiable<long>
30
+ {
31
+ [Attr]
32
+ public int Value { get; set; }
33
+ }" )
34
34
. Build ( ) ;
35
35
36
36
Compilation inputCompilation = new CompilationBuilder ( )
@@ -87,12 +87,12 @@ public void Can_generate_for_read_only_controller()
87
87
. WithNamespaceImportFor ( typeof ( JsonApiEndpoints ) )
88
88
. InNamespace ( "ExampleApi.Models" )
89
89
. WithCode ( @"
90
- [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Query)]
91
- public sealed class Item : Identifiable<long>
92
- {
93
- [Attr]
94
- public int Value { get; set; }
95
- }" )
90
+ [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Query)]
91
+ public sealed class Item : Identifiable<long>
92
+ {
93
+ [Attr]
94
+ public int Value { get; set; }
95
+ }" )
96
96
. Build ( ) ;
97
97
98
98
Compilation inputCompilation = new CompilationBuilder ( )
@@ -149,12 +149,12 @@ public void Can_generate_for_write_only_controller()
149
149
. WithNamespaceImportFor ( typeof ( JsonApiEndpoints ) )
150
150
. InNamespace ( "ExampleApi.Models" )
151
151
. WithCode ( @"
152
- [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)]
153
- public sealed class Item : Identifiable<long>
154
- {
155
- [Attr]
156
- public int Value { get; set; }
157
- }" )
152
+ [Resource(GenerateControllerEndpoints = JsonApiEndpoints.Command)]
153
+ public sealed class Item : Identifiable<long>
154
+ {
155
+ [Attr]
156
+ public int Value { get; set; }
157
+ }" )
158
158
. Build ( ) ;
159
159
160
160
Compilation inputCompilation = new CompilationBuilder ( )
@@ -211,15 +211,15 @@ public void Can_generate_for_mixed_controller()
211
211
. WithNamespaceImportFor ( typeof ( JsonApiEndpoints ) )
212
212
. InNamespace ( "ExampleApi.Models" )
213
213
. WithCode ( @"
214
- [Resource(GenerateControllerEndpoints = NoRelationshipEndpoints)]
215
- public sealed class Item : Identifiable<long>
216
- {
217
- private const JsonApiEndpoints NoRelationshipEndpoints = JsonApiEndpoints.GetCollection |
218
- JsonApiEndpoints.GetSingle | JsonApiEndpoints.Post | JsonApiEndpoints.Patch | JsonApiEndpoints.Delete;
219
-
220
- [Attr]
221
- public int Value { get; set; }
222
- }" )
214
+ [Resource(GenerateControllerEndpoints = NoRelationshipEndpoints)]
215
+ public sealed class Item : Identifiable<long>
216
+ {
217
+ private const JsonApiEndpoints NoRelationshipEndpoints = JsonApiEndpoints.GetCollection |
218
+ JsonApiEndpoints.GetSingle | JsonApiEndpoints.Post | JsonApiEndpoints.Patch | JsonApiEndpoints.Delete;
219
+
220
+ [Attr]
221
+ public int Value { get; set; }
222
+ }" )
223
223
. Build ( ) ;
224
224
225
225
Compilation inputCompilation = new CompilationBuilder ( )
@@ -284,11 +284,11 @@ public void Skips_for_resource_without_ResourceAttribute()
284
284
. WithNamespaceImportFor ( typeof ( AttrAttribute ) )
285
285
. InNamespace ( "ExampleApi.Models" )
286
286
. WithCode ( @"
287
- public sealed class Item : Identifiable<long>
288
- {
289
- [Attr]
290
- public int Value { get; set; }
291
- }" )
287
+ public sealed class Item : Identifiable<long>
288
+ {
289
+ [Attr]
290
+ public int Value { get; set; }
291
+ }" )
292
292
. Build ( ) ;
293
293
294
294
Compilation inputCompilation = new CompilationBuilder ( )
@@ -326,12 +326,12 @@ public void Skips_for_resource_with_no_endpoints()
326
326
. WithNamespaceImportFor ( typeof ( JsonApiEndpoints ) )
327
327
. InNamespace ( "ExampleApi.Models" )
328
328
. WithCode ( @"
329
- [Resource(GenerateControllerEndpoints = JsonApiEndpoints.None)]
330
- public sealed class Item : Identifiable<long>
331
- {
332
- [Attr]
333
- public int Value { get; set; }
334
- }" )
329
+ [Resource(GenerateControllerEndpoints = JsonApiEndpoints.None)]
330
+ public sealed class Item : Identifiable<long>
331
+ {
332
+ [Attr]
333
+ public int Value { get; set; }
334
+ }" )
335
335
. Build ( ) ;
336
336
337
337
Compilation inputCompilation = new CompilationBuilder ( )
@@ -366,24 +366,24 @@ public void Skips_for_missing_dependency_on_JsonApiDotNetCore()
366
366
string source = new SourceCodeBuilder ( )
367
367
. InNamespace ( "ExampleApi.Models" )
368
368
. WithCode ( @"
369
- public abstract class Identifiable<TId>
370
- {
371
- }
372
-
373
- public sealed class ResourceAttribute : System.Attribute
374
- {
375
- }
376
-
377
- public sealed class AttrAttribute : System.Attribute
378
- {
379
- }
380
-
381
- [Resource]
382
- public sealed class Item : Identifiable<long>
383
- {
384
- [Attr]
385
- public int Value { get; set; }
386
- }" )
369
+ public abstract class Identifiable<TId>
370
+ {
371
+ }
372
+
373
+ public sealed class ResourceAttribute : System.Attribute
374
+ {
375
+ }
376
+
377
+ public sealed class AttrAttribute : System.Attribute
378
+ {
379
+ }
380
+
381
+ [Resource]
382
+ public sealed class Item : Identifiable<long>
383
+ {
384
+ [Attr]
385
+ public int Value { get; set; }
386
+ }" )
387
387
. Build ( ) ;
388
388
389
389
Compilation inputCompilation = new CompilationBuilder ( )
@@ -422,12 +422,12 @@ public void Skips_for_missing_dependency_on_LoggerFactory()
422
422
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
423
423
. InNamespace ( "ExampleApi.Models" )
424
424
. WithCode ( @"
425
- [Resource]
426
- public sealed class Item : Identifiable<long>
427
- {
428
- [Attr]
429
- public int Value { get; set; }
430
- }" )
425
+ [Resource]
426
+ public sealed class Item : Identifiable<long>
427
+ {
428
+ [Attr]
429
+ public int Value { get; set; }
430
+ }" )
431
431
. Build ( ) ;
432
432
433
433
Compilation inputCompilation = new CompilationBuilder ( )
@@ -465,12 +465,12 @@ public void Warns_for_resource_that_does_not_implement_IIdentifiable()
465
465
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
466
466
. InNamespace ( "ExampleApi.Models" )
467
467
. WithCode ( @"
468
- [Resource]
469
- public sealed class Item
470
- {
471
- [Attr]
472
- public int Value { get; set; }
473
- }" )
468
+ [Resource]
469
+ public sealed class Item
470
+ {
471
+ [Attr]
472
+ public int Value { get; set; }
473
+ }" )
474
474
. Build ( ) ;
475
475
476
476
Compilation inputCompilation = new CompilationBuilder ( )
@@ -491,7 +491,7 @@ public sealed class Item
491
491
GeneratorDriverRunResult runResult = driver . GetRunResult ( ) ;
492
492
493
493
runResult . Should ( ) . HaveSingleDiagnostic (
494
- "(6,21 ): warning JADNC001: Type 'Item' must implement IIdentifiable<TId> when using ResourceAttribute to auto-generate ASP.NET controllers" ) ;
494
+ "(6,17 ): warning JADNC001: Type 'Item' must implement IIdentifiable<TId> when using ResourceAttribute to auto-generate ASP.NET controllers" ) ;
495
495
496
496
runResult . Should ( ) . NotHaveProducedSourceCode ( ) ;
497
497
}
@@ -510,14 +510,14 @@ public void Adds_nullable_enable_for_nullable_reference_ID_type()
510
510
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
511
511
. InNamespace ( "ExampleApi.Models" )
512
512
. WithCode ( @"
513
- #nullable enable
514
-
515
- [Resource]
516
- public sealed class Item : Identifiable<string?>
517
- {
518
- [Attr]
519
- public int Value { get; set; }
520
- }" )
513
+ #nullable enable
514
+
515
+ [Resource]
516
+ public sealed class Item : Identifiable<string?>
517
+ {
518
+ [Attr]
519
+ public int Value { get; set; }
520
+ }" )
521
521
. Build ( ) ;
522
522
523
523
Compilation inputCompilation = new CompilationBuilder ( )
@@ -555,12 +555,12 @@ public void Can_generate_for_custom_namespace()
555
555
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
556
556
. InNamespace ( "ExampleApi.Models" )
557
557
. WithCode ( @"
558
- [Resource(ControllerNamespace = ""Some.Path.To.Generate.Code.In"")]
559
- public sealed class Item : Identifiable<long>
560
- {
561
- [Attr]
562
- public int Value { get; set; }
563
- }" )
558
+ [Resource(ControllerNamespace = ""Some.Path.To.Generate.Code.In"")]
559
+ public sealed class Item : Identifiable<long>
560
+ {
561
+ [Attr]
562
+ public int Value { get; set; }
563
+ }" )
564
564
. Build ( ) ;
565
565
566
566
Compilation inputCompilation = new CompilationBuilder ( )
@@ -616,12 +616,12 @@ public void Can_generate_for_top_level_namespace()
616
616
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
617
617
. InNamespace ( "TopLevel" )
618
618
. WithCode ( @"
619
- [Resource]
620
- public sealed class Item : Identifiable<long>
621
- {
622
- [Attr]
623
- public int Value { get; set; }
624
- }" )
619
+ [Resource]
620
+ public sealed class Item : Identifiable<long>
621
+ {
622
+ [Attr]
623
+ public int Value { get; set; }
624
+ }" )
625
625
. Build ( ) ;
626
626
627
627
Compilation inputCompilation = new CompilationBuilder ( )
@@ -676,12 +676,12 @@ public void Can_generate_for_global_namespace()
676
676
. WithNamespaceImportFor ( typeof ( IIdentifiable ) )
677
677
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
678
678
. WithCode ( @"
679
- [Resource]
680
- public sealed class Item : Identifiable<long>
681
- {
682
- [Attr]
683
- public int Value { get; set; }
684
- }" )
679
+ [Resource]
680
+ public sealed class Item : Identifiable<long>
681
+ {
682
+ [Attr]
683
+ public int Value { get; set; }
684
+ }" )
685
685
. Build ( ) ;
686
686
687
687
Compilation inputCompilation = new CompilationBuilder ( )
@@ -734,12 +734,12 @@ public void Can_generate_for_shared_namespace()
734
734
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
735
735
. InNamespace ( "ExampleApi" )
736
736
. WithCode ( @"
737
- [Resource(ControllerNamespace = ""ExampleApi"")]
738
- public sealed class Item : Identifiable<long>
739
- {
740
- [Attr]
741
- public int Value { get; set; }
742
- }" )
737
+ [Resource(ControllerNamespace = ""ExampleApi"")]
738
+ public sealed class Item : Identifiable<long>
739
+ {
740
+ [Attr]
741
+ public int Value { get; set; }
742
+ }" )
743
743
. Build ( ) ;
744
744
745
745
Compilation inputCompilation = new CompilationBuilder ( )
@@ -793,25 +793,25 @@ public void Generates_unique_file_names_for_duplicate_resource_name_in_different
793
793
. WithNamespaceImportFor ( typeof ( IIdentifiable ) )
794
794
. WithNamespaceImportFor ( typeof ( ResourceAttribute ) )
795
795
. WithCode ( @"
796
- namespace The.First.One
796
+ namespace The.First.One
797
+ {
798
+ [Resource]
799
+ public sealed class Item : Identifiable<long>
797
800
{
798
- [Resource]
799
- public sealed class Item : Identifiable<long>
800
- {
801
- [Attr]
802
- public int Value { get; set; }
803
- }
801
+ [Attr]
802
+ public int Value { get; set; }
804
803
}
804
+ }
805
805
806
- namespace The.Second.One
806
+ namespace The.Second.One
807
+ {
808
+ [Resource]
809
+ public sealed class Item : Identifiable<long>
807
810
{
808
- [Resource]
809
- public sealed class Item : Identifiable<long>
810
- {
811
- [Attr]
812
- public int Value { get; set; }
813
- }
814
- }" )
811
+ [Attr]
812
+ public int Value { get; set; }
813
+ }
814
+ }" )
815
815
. Build ( ) ;
816
816
817
817
Compilation inputCompilation = new CompilationBuilder ( )
0 commit comments