Skip to content

Commit 7a1e2ea

Browse files
Add [GeneratedCode] for more RDG output (#48377)
* Add [GeneratedCode] for more RDG output
1 parent ecc1791 commit 7a1e2ea

File tree

38 files changed

+167
-4
lines changed

38 files changed

+167
-4
lines changed

src/Http/Http.Extensions/gen/RequestDelegateGeneratorSources.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ internal static class RequestDelegateGeneratorSources
2020

2121
public static string GeneratedCodeAttribute => $@"[System.CodeDom.Compiler.GeneratedCodeAttribute(""{typeof(RequestDelegateGeneratorSources).Assembly.FullName}"", ""{typeof(RequestDelegateGeneratorSources).Assembly.GetName().Version}"")]";
2222

23-
public static string ContentTypeConstantsType => """
23+
public static string ContentTypeConstantsType => $$"""
24+
{{GeneratedCodeAttribute}}
2425
file static class GeneratedMetadataConstants
2526
{
2627
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -31,7 +32,8 @@ file static class GeneratedMetadataConstants
3132
3233
""";
3334

34-
public static string ProducesResponseTypeMetadataType => """
35+
public static string ProducesResponseTypeMetadataType => $$"""
36+
{{GeneratedCodeAttribute}}
3537
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
3638
{
3739
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -50,7 +52,8 @@ public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[
5052
5153
""";
5254

53-
public static string AcceptsMetadataType => """
55+
public static string AcceptsMetadataType => $$"""
56+
{{GeneratedCodeAttribute}}
5457
file sealed class GeneratedAcceptsMetadata : IAcceptsMetadata
5558
{
5659
public GeneratedAcceptsMetadata(string[] contentTypes)
@@ -258,6 +261,7 @@ private static Task WriteToResponseAsync<T>(T? value, HttpContext httpContext, J
258261
""";
259262

260263
public static string LogOrThrowExceptionHelperClass => $$"""
264+
{{GeneratedCodeAttribute}}
261265
file sealed class LogOrThrowExceptionHelper
262266
{
263267
private readonly ILogger? _rdgLogger;
@@ -402,7 +406,8 @@ public void InvalidFormRequestBody(string parameterTypeName, string parameterNam
402406
}
403407
""";
404408

405-
public static string PropertyAsParameterInfoClass = """
409+
public static string PropertyAsParameterInfoClass = $$"""
410+
{{GeneratedCodeAttribute}}
406411
file sealed class PropertyAsParameterInfo : ParameterInfo
407412
{
408413
private readonly PropertyInfo _underlyingProperty;
@@ -547,6 +552,7 @@ namespace Microsoft.AspNetCore.Http.Generated
547552
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
548553
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
549554
555+
{{GeneratedCodeAttribute}}
550556
file static class GeneratedRouteBuilderExtensionsCore
551557
{
552558
{{GetGenericThunks(genericThunks)}}

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_BindAsync_Snapshot.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ namespace Microsoft.AspNetCore.Http.Generated
341341
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
342342
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
343343

344+
%GENERATEDCODEATTRIBUTE%
344345
file static class GeneratedRouteBuilderExtensionsCore
345346
{
346347

@@ -1839,6 +1840,7 @@ namespace Microsoft.AspNetCore.Http.Generated
18391840

18401841
}
18411842

1843+
%GENERATEDCODEATTRIBUTE%
18421844
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
18431845
{
18441846
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -1855,6 +1857,7 @@ namespace Microsoft.AspNetCore.Http.Generated
18551857
public IEnumerable<string> ContentTypes { get; }
18561858
}
18571859

1860+
%GENERATEDCODEATTRIBUTE%
18581861
file static class GeneratedMetadataConstants
18591862
{
18601863
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -1864,6 +1867,7 @@ namespace Microsoft.AspNetCore.Http.Generated
18641867
}
18651868

18661869

1870+
%GENERATEDCODEATTRIBUTE%
18671871
file sealed class LogOrThrowExceptionHelper
18681872
{
18691873
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitBodyParam_ComplexReturn_Snapshot.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -364,6 +365,7 @@ namespace Microsoft.AspNetCore.Http.Generated
364365

365366
}
366367

368+
%GENERATEDCODEATTRIBUTE%
367369
file sealed class GeneratedAcceptsMetadata : IAcceptsMetadata
368370
{
369371
public GeneratedAcceptsMetadata(string[] contentTypes)
@@ -389,6 +391,7 @@ namespace Microsoft.AspNetCore.Http.Generated
389391

390392
public bool IsOptional { get; }
391393
}
394+
%GENERATEDCODEATTRIBUTE%
392395
file static class GeneratedMetadataConstants
393396
{
394397
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -398,6 +401,7 @@ namespace Microsoft.AspNetCore.Http.Generated
398401
}
399402

400403

404+
%GENERATEDCODEATTRIBUTE%
401405
file sealed class LogOrThrowExceptionHelper
402406
{
403407
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_ComplexTypeArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -247,6 +248,7 @@ namespace Microsoft.AspNetCore.Http.Generated
247248

248249
}
249250

251+
%GENERATEDCODEATTRIBUTE%
250252
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
251253
{
252254
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -263,6 +265,7 @@ namespace Microsoft.AspNetCore.Http.Generated
263265
public IEnumerable<string> ContentTypes { get; }
264266
}
265267

268+
%GENERATEDCODEATTRIBUTE%
266269
file static class GeneratedMetadataConstants
267270
{
268271
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -272,6 +275,7 @@ namespace Microsoft.AspNetCore.Http.Generated
272275
}
273276

274277

278+
%GENERATEDCODEATTRIBUTE%
275279
file sealed class LogOrThrowExceptionHelper
276280
{
277281
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_NullableStringArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -219,6 +220,7 @@ namespace Microsoft.AspNetCore.Http.Generated
219220

220221
}
221222

223+
%GENERATEDCODEATTRIBUTE%
222224
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
223225
{
224226
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -235,6 +237,7 @@ namespace Microsoft.AspNetCore.Http.Generated
235237
public IEnumerable<string> ContentTypes { get; }
236238
}
237239

240+
%GENERATEDCODEATTRIBUTE%
238241
file static class GeneratedMetadataConstants
239242
{
240243
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -244,6 +247,7 @@ namespace Microsoft.AspNetCore.Http.Generated
244247
}
245248

246249

250+
%GENERATEDCODEATTRIBUTE%
247251
file sealed class LogOrThrowExceptionHelper
248252
{
249253
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitHeader_StringArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -219,6 +220,7 @@ namespace Microsoft.AspNetCore.Http.Generated
219220

220221
}
221222

223+
%GENERATEDCODEATTRIBUTE%
222224
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
223225
{
224226
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -235,6 +237,7 @@ namespace Microsoft.AspNetCore.Http.Generated
235237
public IEnumerable<string> ContentTypes { get; }
236238
}
237239

240+
%GENERATEDCODEATTRIBUTE%
238241
file static class GeneratedMetadataConstants
239242
{
240243
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -244,6 +247,7 @@ namespace Microsoft.AspNetCore.Http.Generated
244247
}
245248

246249

250+
%GENERATEDCODEATTRIBUTE%
247251
file sealed class LogOrThrowExceptionHelper
248252
{
249253
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_ComplexTypeArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -247,6 +248,7 @@ namespace Microsoft.AspNetCore.Http.Generated
247248

248249
}
249250

251+
%GENERATEDCODEATTRIBUTE%
250252
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
251253
{
252254
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -263,6 +265,7 @@ namespace Microsoft.AspNetCore.Http.Generated
263265
public IEnumerable<string> ContentTypes { get; }
264266
}
265267

268+
%GENERATEDCODEATTRIBUTE%
266269
file static class GeneratedMetadataConstants
267270
{
268271
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -272,6 +275,7 @@ namespace Microsoft.AspNetCore.Http.Generated
272275
}
273276

274277

278+
%GENERATEDCODEATTRIBUTE%
275279
file sealed class LogOrThrowExceptionHelper
276280
{
277281
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_NullableStringArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -218,6 +219,7 @@ namespace Microsoft.AspNetCore.Http.Generated
218219

219220
}
220221

222+
%GENERATEDCODEATTRIBUTE%
221223
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
222224
{
223225
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -234,6 +236,7 @@ namespace Microsoft.AspNetCore.Http.Generated
234236
public IEnumerable<string> ContentTypes { get; }
235237
}
236238

239+
%GENERATEDCODEATTRIBUTE%
237240
file static class GeneratedMetadataConstants
238241
{
239242
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -243,6 +246,7 @@ namespace Microsoft.AspNetCore.Http.Generated
243246
}
244247

245248

249+
%GENERATEDCODEATTRIBUTE%
246250
file sealed class LogOrThrowExceptionHelper
247251
{
248252
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitQuery_StringArrayParam.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -218,6 +219,7 @@ namespace Microsoft.AspNetCore.Http.Generated
218219

219220
}
220221

222+
%GENERATEDCODEATTRIBUTE%
221223
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
222224
{
223225
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -234,6 +236,7 @@ namespace Microsoft.AspNetCore.Http.Generated
234236
public IEnumerable<string> ContentTypes { get; }
235237
}
236238

239+
%GENERATEDCODEATTRIBUTE%
237240
file static class GeneratedMetadataConstants
238241
{
239242
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -243,6 +246,7 @@ namespace Microsoft.AspNetCore.Http.Generated
243246
}
244247

245248

249+
%GENERATEDCODEATTRIBUTE%
246250
file sealed class LogOrThrowExceptionHelper
247251
{
248252
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitServiceParam_SimpleReturn_Snapshot.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ namespace Microsoft.AspNetCore.Http.Generated
116116
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
117117
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
118118

119+
%GENERATEDCODEATTRIBUTE%
119120
file static class GeneratedRouteBuilderExtensionsCore
120121
{
121122

@@ -383,6 +384,7 @@ namespace Microsoft.AspNetCore.Http.Generated
383384

384385
}
385386

387+
%GENERATEDCODEATTRIBUTE%
386388
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
387389
{
388390
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -399,6 +401,7 @@ namespace Microsoft.AspNetCore.Http.Generated
399401
public IEnumerable<string> ContentTypes { get; }
400402
}
401403

404+
%GENERATEDCODEATTRIBUTE%
402405
file static class GeneratedMetadataConstants
403406
{
404407
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -408,6 +411,7 @@ namespace Microsoft.AspNetCore.Http.Generated
408411
}
409412

410413

414+
%GENERATEDCODEATTRIBUTE%
411415
file sealed class LogOrThrowExceptionHelper
412416
{
413417
private readonly ILogger? _rdgLogger;

src/Http/Http.Extensions/test/RequestDelegateGenerator/Baselines/MapAction_ExplicitSource_SimpleReturn_Snapshot.generated.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ namespace Microsoft.AspNetCore.Http.Generated
8686
using MetadataPopulator = System.Func<System.Reflection.MethodInfo, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions?, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult>;
8787
using RequestDelegateFactoryFunc = System.Func<System.Delegate, Microsoft.AspNetCore.Http.RequestDelegateFactoryOptions, Microsoft.AspNetCore.Http.RequestDelegateMetadataResult?, Microsoft.AspNetCore.Http.RequestDelegateResult>;
8888

89+
%GENERATEDCODEATTRIBUTE%
8990
file static class GeneratedRouteBuilderExtensionsCore
9091
{
9192

@@ -571,6 +572,7 @@ namespace Microsoft.AspNetCore.Http.Generated
571572

572573
}
573574

575+
%GENERATEDCODEATTRIBUTE%
574576
file sealed class GeneratedProducesResponseTypeMetadata : IProducesResponseTypeMetadata
575577
{
576578
public GeneratedProducesResponseTypeMetadata(Type? type, int statusCode, string[] contentTypes)
@@ -587,6 +589,7 @@ namespace Microsoft.AspNetCore.Http.Generated
587589
public IEnumerable<string> ContentTypes { get; }
588590
}
589591

592+
%GENERATEDCODEATTRIBUTE%
590593
file static class GeneratedMetadataConstants
591594
{
592595
public static readonly string[] JsonContentType = new [] { "application/json" };
@@ -596,6 +599,7 @@ namespace Microsoft.AspNetCore.Http.Generated
596599
}
597600

598601

602+
%GENERATEDCODEATTRIBUTE%
599603
file sealed class LogOrThrowExceptionHelper
600604
{
601605
private readonly ILogger? _rdgLogger;

0 commit comments

Comments
 (0)