Skip to content

Commit b2030c3

Browse files
authored
Merge pull request #1260 from aws/normj/annotations-move-namespace
Breaking Change: Move all APIGateway attributes to a their own namespace
2 parents e78caae + df57c94 commit b2030c3

27 files changed

+59
-41
lines changed

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/AttributeModelBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Amazon.Lambda.Annotations.APIGateway;
23
using Microsoft.CodeAnalysis;
34

45
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/FromHeaderAttributeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Amazon.Lambda.Annotations.APIGateway;
12
using Microsoft.CodeAnalysis;
23

34
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/FromQueryAttributeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Amazon.Lambda.Annotations.APIGateway;
12
using Microsoft.CodeAnalysis;
23

34
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/FromRouteAttributeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Amazon.Lambda.Annotations.APIGateway;
12
using Microsoft.CodeAnalysis;
23

34
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/HttpApiAttributeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Linq;
3+
using Amazon.Lambda.Annotations.APIGateway;
34
using Microsoft.CodeAnalysis;
45

56
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/RestApiAttributeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Amazon.Lambda.Annotations.APIGateway;
23
using Microsoft.CodeAnalysis;
34

45
namespace Amazon.Lambda.Annotations.SourceGenerator.Models.Attributes

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/Attributes/TemplateParametersExtension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Amazon.Lambda.Annotations.APIGateway;
12
using System;
23
using System.Collections.Generic;
34
using System.Linq;

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Models/GeneratedMethodModelBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using Amazon.Lambda.Annotations;
4+
using Amazon.Lambda.Annotations.APIGateway;
55
using Amazon.Lambda.Annotations.SourceGenerator.Extensions;
66
using Microsoft.CodeAnalysis;
77

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/LambdaFunctionTemplate.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ public virtual string TransformText()
264264

265265
return p.Name;
266266
}));
267-
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel<RestApiAttribute>;
268-
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel<HttpApiAttribute>;
267+
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.RestApiAttribute>;
268+
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.HttpApiAttribute>;
269269

270270
if (restApiAttribute != null && httpApiAttribute != null)
271271
{
@@ -326,7 +326,7 @@ public virtual string TransformText()
326326
}
327327
else if (parameter.Attributes.Any(att => att.Type.FullName == TypeFullNames.FromQueryAttribute))
328328
{
329-
var fromQueryAttribute = parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromQueryAttribute) as AttributeModel<FromQueryAttribute>;
329+
var fromQueryAttribute = parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromQueryAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromQueryAttribute>;
330330

331331
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
332332
var parameterKey = fromQueryAttribute?.Data?.Name ?? parameter.Name;
@@ -362,14 +362,14 @@ public virtual string TransformText()
362362
// Therefore, it is required to split the string to convert to an enumerable
363363
// and convert individual item to target data type.
364364
var commaSplit = "";
365-
if (httpApiAttribute?.Data.Version == HttpApiVersion.V2)
365+
if (httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2)
366366
{
367367
commaSplit = @".Split("","")";
368368
}
369369

370370
// HTTP API V1 and Rest API, multiple values for the same parameter are provided
371371
// dedicated dictionary of string key and list value.
372-
if (restApiAttribute != null || httpApiAttribute?.Data.Version == HttpApiVersion.V1)
372+
if (restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1)
373373
{
374374
queryStringParameters = "MultiValueQueryStringParameters";
375375
}
@@ -553,7 +553,7 @@ public virtual string TransformText()
553553
{
554554
var fromHeaderAttribute =
555555
parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromHeaderAttribute) as
556-
AttributeModel<FromHeaderAttribute>;
556+
AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromHeaderAttribute>;
557557

558558
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
559559
var headerKey = fromHeaderAttribute?.Data?.Name ?? parameter.Name;
@@ -589,14 +589,14 @@ public virtual string TransformText()
589589
// Therefore, it is required to split the string to convert to an enumerable
590590
// and convert individual item to target data type.
591591
var commaSplit = "";
592-
if (httpApiAttribute?.Data.Version == HttpApiVersion.V2)
592+
if (httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2)
593593
{
594594
commaSplit = @".Split("","")";
595595
}
596596

597597
// HTTP API V1 and Rest API, multiple values for the same header are provided
598598
// dedicated dictionary of string key and list value.
599-
if (restApiAttribute != null || httpApiAttribute?.Data.Version == HttpApiVersion.V1)
599+
if (restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1)
600600
{
601601
headers = "MultiValueHeaders";
602602
}
@@ -847,7 +847,7 @@ public virtual string TransformText()
847847
}
848848
else if (parameter.Attributes.Any(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) || routeParameters.Contains(parameter.Name))
849849
{
850-
var fromRouteAttribute = parameter.Attributes?.FirstOrDefault(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) as AttributeModel<FromRouteAttribute>;
850+
var fromRouteAttribute = parameter.Attributes?.FirstOrDefault(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromRouteAttribute>;
851851

852852
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
853853
var routeKey = fromRouteAttribute?.Data?.Name ?? parameter.Name;

Libraries/src/Amazon.Lambda.Annotations.SourceGenerator/Templates/LambdaFunctionTemplate.tt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
9797

9898
return p.Name;
9999
}));
100-
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel<RestApiAttribute>;
101-
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel<HttpApiAttribute>;
100+
var restApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.RestApiAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.RestApiAttribute>;
101+
var httpApiAttribute = _model.LambdaMethod.Attributes.FirstOrDefault(att => att.Type.FullName == TypeFullNames.HttpApiAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.HttpApiAttribute>;
102102

103103
if (restApiAttribute != null && httpApiAttribute != null)
104104
{
@@ -136,7 +136,7 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
136136
}
137137
else if (parameter.Attributes.Any(att => att.Type.FullName == TypeFullNames.FromQueryAttribute))
138138
{
139-
var fromQueryAttribute = parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromQueryAttribute) as AttributeModel<FromQueryAttribute>;
139+
var fromQueryAttribute = parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromQueryAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromQueryAttribute>;
140140

141141
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
142142
var parameterKey = fromQueryAttribute?.Data?.Name ?? parameter.Name;
@@ -153,14 +153,14 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
153153
// Therefore, it is required to split the string to convert to an enumerable
154154
// and convert individual item to target data type.
155155
var commaSplit = "";
156-
if (httpApiAttribute?.Data.Version == HttpApiVersion.V2)
156+
if (httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2)
157157
{
158158
commaSplit = @".Split("","")";
159159
}
160160

161161
// HTTP API V1 and Rest API, multiple values for the same parameter are provided
162162
// dedicated dictionary of string key and list value.
163-
if (restApiAttribute != null || httpApiAttribute?.Data.Version == HttpApiVersion.V1)
163+
if (restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1)
164164
{
165165
queryStringParameters = "MultiValueQueryStringParameters";
166166
}
@@ -217,7 +217,7 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
217217
{
218218
var fromHeaderAttribute =
219219
parameter.Attributes.First(att => att.Type.FullName == TypeFullNames.FromHeaderAttribute) as
220-
AttributeModel<FromHeaderAttribute>;
220+
AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromHeaderAttribute>;
221221

222222
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
223223
var headerKey = fromHeaderAttribute?.Data?.Name ?? parameter.Name;
@@ -234,14 +234,14 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
234234
// Therefore, it is required to split the string to convert to an enumerable
235235
// and convert individual item to target data type.
236236
var commaSplit = "";
237-
if (httpApiAttribute?.Data.Version == HttpApiVersion.V2)
237+
if (httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V2)
238238
{
239239
commaSplit = @".Split("","")";
240240
}
241241

242242
// HTTP API V1 and Rest API, multiple values for the same header are provided
243243
// dedicated dictionary of string key and list value.
244-
if (restApiAttribute != null || httpApiAttribute?.Data.Version == HttpApiVersion.V1)
244+
if (restApiAttribute != null || httpApiAttribute?.Data.Version == Amazon.Lambda.Annotations.APIGateway.HttpApiVersion.V1)
245245
{
246246
headers = "MultiValueHeaders";
247247
}
@@ -321,7 +321,7 @@ namespace <#= _model.LambdaMethod.ContainingNamespace #>
321321
}
322322
else if (parameter.Attributes.Any(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) || routeParameters.Contains(parameter.Name))
323323
{
324-
var fromRouteAttribute = parameter.Attributes?.FirstOrDefault(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) as AttributeModel<FromRouteAttribute>;
324+
var fromRouteAttribute = parameter.Attributes?.FirstOrDefault(att => att.Type.FullName == TypeFullNames.FromRouteAttribute) as AttributeModel<Amazon.Lambda.Annotations.APIGateway.FromRouteAttribute>;
325325

326326
// Use parameter name as key, if Name has not specified explicitly in the attribute definition.
327327
var routeKey = fromRouteAttribute?.Data?.Name ?? parameter.Name;

0 commit comments

Comments
 (0)