Skip to content

Commit b9e620d

Browse files
committed
Add assembly attributes templates for AWS Lambda functions to alleviate Lambda Annotation error messages about 127 character limits.
1 parent 6fdd7a8 commit b9e620d

File tree

95 files changed

+3215
-865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+3215
-865
lines changed

Modules/Intent.Modules.Aws.Lambda.Functions.Sqs/Intent.Aws.Lambda.Functions.Sqs.imodspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>Intent.Aws.Lambda.Functions.Sqs</id>
4-
<version>1.0.0-pre.0</version>
4+
<version>1.0.0-pre.1</version>
55
<supportedClientVersions>[4.5.21-a,5.0.0)</supportedClientVersions>
66
<summary>Use Lambda Functions to receive and dispatch SQS messages to event handlers.</summary>
77
<description>Use Lambda Functions to receive and dispatch SQS messages to event handlers.</description>

Modules/Intent.Modules.Aws.Lambda.Functions.Sqs/Templates/LambdaFunctionConsumer/LambdaFunctionConsumerTemplatePartial.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
using Intent.Modelers.Services.EventInteractions;
66
using Intent.Modules.Aws.Sqs.Templates;
77
using Intent.Modules.Common;
8+
using Intent.Modules.Common.CSharp.Api;
89
using Intent.Modules.Common.CSharp.Builder;
910
using Intent.Modules.Common.CSharp.Templates;
1011
using Intent.Modules.Common.Templates;
12+
using Intent.Modules.Common.Types.Api;
1113
using Intent.Modules.Common.UnitOfWork.Shared;
1214
using Intent.Modules.Eventing.Contracts.Templates;
1315
using Intent.RoslynWeaver.Attributes;
@@ -33,6 +35,8 @@ public LambdaFunctionConsumerTemplate(IOutputTarget outputTarget, IntegrationEve
3335
AddNugetDependency(LambdaNugetPackages.AmazonLambdaAnnotations(OutputTarget));
3436
AddNugetDependency(SqsNugetPackages.AmazonLambdaSqsEvents(OutputTarget));
3537

38+
FulfillsRole("Aws.Lambda.Function");
39+
3640
CSharpFile = new CSharpFile(this.GetNamespace(), this.GetFolderPath())
3741
.AddUsing("System")
3842
.AddUsing("System.Collections.Generic")
@@ -112,5 +116,29 @@ private string GetConsumerName()
112116
{
113117
return Model.Name.RemoveSuffix("Handler").EnsureSuffixedWith("Consumer");
114118
}
119+
120+
string GetNamespace(
121+
params string[] additionalFolders)
122+
{
123+
return string.Join(".", new[]
124+
{
125+
"Lambda"
126+
}
127+
.Concat(Model.GetParentFolders()
128+
.Where(x =>
129+
{
130+
if (string.IsNullOrWhiteSpace(x.Name))
131+
return false;
132+
133+
if (x is FolderModel fm)
134+
{
135+
return !fm.HasFolderOptions() || fm.GetFolderOptions().NamespaceProvider();
136+
}
137+
138+
return true;
139+
})
140+
.Select(x => x.Name))
141+
.Concat(additionalFolders));
142+
}
115143
}
116144
}

Modules/Intent.Modules.Aws.Lambda.Functions/Intent.Aws.Lambda.Functions.imodspec

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<package>
33
<id>Intent.Aws.Lambda.Functions</id>
4-
<version>1.0.2-pre.1</version>
4+
<version>1.0.2-pre.2</version>
55
<supportedClientVersions>[4.5.21-a, 5.0.0-a)</supportedClientVersions>
66
<summary>Serverless AWS Lambda Functions in the Services designer.</summary>
77
<description>Serverless AWS Lambda Functions in the Services designer.</description>
88
<authors>Intent Architect</authors>
99
<iconUrl>data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2aWV3Qm94PSIwIDAgODAgODAiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8IS0tIEdlbmVyYXRvc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1MzU0NSwxMi45OTkgTDIxLjg4NDMyOSwyNC45OTkgQzIxLjg4NDMyOSwyNS4yNjUgMjEuOTg4NTcwOCwyNS41MTkgMjIuMTc4MDEwMywyNS43MDcgQzIyLjM2NTQ0NTIsMjUuODk1IDIyLjYyMDAzNTgsMjYgMjIuODg2NjU0NCwyNiBMMzEuMzI5MjQxNywyNiBMNTEuMTIyMTYyNSw2Ny40MyBDNTEuMjg4NTQ4NSw2Ny43NzggNTEuNjM5MzYyNCw2OCA1Mi4wMjYyNiw2OCBMNjUuOTk3Njc0NSw2OCBDNjYuNTUxOTYwNSw2OCA2Nyw2Ny41NTIgNjcsNjcgTDY3LDU1IEM2Nyw1NC40NDggNjYuNTUxOTYwNSw1NCA2NS45OTc2NzQ1LDU0IEw2NS45OTc2NzQ1LDU0IFoiIGlkPSJBV1MtTGFtYmRhX0ljb25fNjRfU3F1aWQiIGZpbGw9IiNGRkZGRkYiPjwvcGF0aD4KICAgIDwvZz4KPC9zdmc+</iconUrl>
1010
<templates>
11+
<template id="Intent.Aws.Lambda.Functions.AssemblyAttributes" externalReference="c8ab9feb-a55e-4a48-8612-5e9aa20d5f73">
12+
<config>
13+
<add key="ClassName" description="Class name formula override (e.g. '${Model.Name}')" />
14+
<add key="Namespace" description="Class namespace formula override (e.g. '${Project.Name}'" />
15+
</config>
16+
<role>Aws.Lambda.Api</role>
17+
<location></location>
18+
</template>
1119
<template id="Intent.Aws.Lambda.Functions.AwsLambdaReadMeTemplate" externalReference="50c45d98-de3f-4be7-b684-c62a0673d64a">
1220
<role>Aws.Lambda.Api</role>
1321
<location></location>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<class id="c8ab9feb-a55e-4a48-8612-5e9aa20d5f73" type="C# Template" typeId="f6456232-0f1b-4235-b5f8-b4cce548ca59">
3+
<name>AssemblyAttributes</name>
4+
<display>AssemblyAttributes: Single File</display>
5+
<isAbstract>false</isAbstract>
6+
<genericTypes />
7+
<typeReference id="4c02caf6-6377-45d6-b87a-fb054482b7bd">
8+
<typeId>f65d2904-88c9-4501-873a-a4eec8303b1d</typeId>
9+
<isNavigable>true</isNavigable>
10+
<isNullable>false</isNullable>
11+
<isCollection>false</isCollection>
12+
<isRequired>true</isRequired>
13+
<typePackageName>Intent.ModuleBuilder</typePackageName>
14+
<typePackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</typePackageId>
15+
<stereotypes />
16+
<genericTypeParameters />
17+
</typeReference>
18+
<isMapped>false</isMapped>
19+
<parentFolderId>4741e086-f1fa-4135-88df-1a329c15a271</parentFolderId>
20+
<packageId>4741e086-f1fa-4135-88df-1a329c15a271</packageId>
21+
<packageName>Intent.Aws.Lambda.Functions</packageName>
22+
<stereotypes>
23+
<stereotype stereotypeDefinitionId="78be0482-1cd7-4b9f-b457-5ebe1536786e" name="C# Template Settings">
24+
<addedByDefault>true</addedByDefault>
25+
<definitionPackageName>Intent.ModuleBuilder.CSharp</definitionPackageName>
26+
<definitionPackageId>f2bfb0f7-d304-466f-b923-021d4016b48d</definitionPackageId>
27+
<properties>
28+
<property name="3b9e1f1b-e253-4c04-89aa-30fef0a9bfa8" display="Templating Method" value="C# File Builder" isActive="true" />
29+
</properties>
30+
</stereotype>
31+
<stereotype stereotypeDefinitionId="b1f08a30-9aae-4702-bfc8-e285e6b43a61" name="Template Settings">
32+
<addedByDefault>true</addedByDefault>
33+
<definitionPackageName>Intent.ModuleBuilder</definitionPackageName>
34+
<definitionPackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</definitionPackageId>
35+
<properties>
36+
<property name="a9de6cf5-6d4f-4ae1-aa60-5ca85e458709" display="Source" value="Lookup Type" isActive="true" />
37+
<property name="00d3537c-f71f-4450-8cc8-d9e87c12baee" display="Designer" isActive="true" />
38+
<property name="75b89367-1808-43f8-9f18-785915ec1630" display="Model Type" isActive="true" />
39+
<property name="d1e89313-0647-48bd-81da-b04b644db475" display="Model Name" value="object" isActive="false" />
40+
<property name="f1d88e59-1ca6-426e-b52d-42f3467e6bd5" display="Role" value="Aws.Lambda.Api" isActive="true" />
41+
<property name="1ac0fa39-ecea-48f8-92e4-41616a639586" display="Default Location" isActive="true" />
42+
</properties>
43+
</stereotype>
44+
</stereotypes>
45+
<metadata />
46+
<childElements />
47+
</class>

Modules/Intent.Modules.Aws.Lambda.Functions/Intent.Metadata/Module Builder/Intent.Aws.Lambda.Functions/Intent.Aws.Lambda.Functions.pkg.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<definitionPackageName>Intent.ModuleBuilder</definitionPackageName>
3535
<definitionPackageId>9972b2a9-b749-4bba-b5c8-824bf694c6ef</definitionPackageId>
3636
<properties>
37-
<property name="4bb9695b-6004-46e1-acea-c48c60c5f8ce" display="Version" value="1.0.2-pre.1" isActive="true" />
37+
<property name="4bb9695b-6004-46e1-acea-c48c60c5f8ce" display="Version" value="1.0.2-pre.2" isActive="true" />
3838
<property name="177a2415-e749-46e7-8257-440e19ecfb5e" display="API Namespace" isActive="true" />
3939
<property name="0d2ae582-090e-42d6-a7d6-689144433254" display="NuGet Package Id" isActive="true" />
4040
<property name="27cf6544-a9a2-4992-9fef-51d0ed49e66e" display="NuGet Package Version" value="" isActive="true" />

Modules/Intent.Modules.Aws.Lambda.Functions/Intent.Modules.Aws.Lambda.Functions.application.output.log

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@
4040
<ProjectRelativeFilePath>release-notes.md</ProjectRelativeFilePath>
4141
<IsIgnored>true</IsIgnored>
4242
</FileLog>
43+
<FileLog>
44+
<ProjectId>31c48fca-00ff-4da4-8528-a1337c70ce6b</ProjectId>
45+
<CorrelationId>Intent.ModuleBuilder.CSharp.Templates.CSharpTemplatePartial#c8ab9feb-a55e-4a48-8612-5e9aa20d5f73</CorrelationId>
46+
<OverwriteBehaviour>always</OverwriteBehaviour>
47+
<ApplicationRelativeFilePath>Templates/AssemblyAttributes/AssemblyAttributesTemplatePartial.cs</ApplicationRelativeFilePath>
48+
<ProjectRelativeFilePath>AssemblyAttributes/AssemblyAttributesTemplatePartial.cs</ProjectRelativeFilePath>
49+
<IsIgnored>false</IsIgnored>
50+
</FileLog>
51+
<FileLog>
52+
<ProjectId>31c48fca-00ff-4da4-8528-a1337c70ce6b</ProjectId>
53+
<CorrelationId>Intent.ModuleBuilder.TemplateRegistration.SingleFileNoModel#c8ab9feb-a55e-4a48-8612-5e9aa20d5f73</CorrelationId>
54+
<OverwriteBehaviour>always</OverwriteBehaviour>
55+
<ApplicationRelativeFilePath>Templates/AssemblyAttributes/AssemblyAttributesTemplateRegistration.cs</ApplicationRelativeFilePath>
56+
<ProjectRelativeFilePath>AssemblyAttributes/AssemblyAttributesTemplateRegistration.cs</ProjectRelativeFilePath>
57+
<IsIgnored>false</IsIgnored>
58+
</FileLog>
4359
<FileLog>
4460
<ProjectId>31c48fca-00ff-4da4-8528-a1337c70ce6b</ProjectId>
4561
<CorrelationId>Intent.ModuleBuilder.Templates.FileTemplateStringInterpolation#50c45d98-de3f-4be7-b684-c62a0673d64a</CorrelationId>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Intent.Engine;
5+
using Intent.Modules.Common;
6+
using Intent.Modules.Common.CSharp.Builder;
7+
using Intent.Modules.Common.CSharp.Templates;
8+
using Intent.Modules.Common.Templates;
9+
using Intent.RoslynWeaver.Attributes;
10+
using Intent.Templates;
11+
12+
[assembly: DefaultIntentManaged(Mode.Fully)]
13+
[assembly: IntentTemplate("Intent.ModuleBuilder.CSharp.Templates.CSharpTemplatePartial", Version = "1.0")]
14+
15+
namespace Intent.Modules.Aws.Lambda.Functions.Templates.AssemblyAttributes
16+
{
17+
[IntentManaged(Mode.Fully, Body = Mode.Merge)]
18+
public partial class AssemblyAttributesTemplate : CSharpTemplateBase<object>, ICSharpFileBuilderTemplate
19+
{
20+
public const string TemplateId = "Intent.Aws.Lambda.Functions.AssemblyAttributes";
21+
22+
[IntentManaged(Mode.Fully, Body = Mode.Ignore)]
23+
public AssemblyAttributesTemplate(IOutputTarget outputTarget, object model = null) : base(TemplateId, outputTarget, model)
24+
{
25+
CSharpFile = new CSharpFile(this.GetNamespace(), this.GetFolderPath())
26+
.AddUsing("System.Diagnostics.CodeAnalysis")
27+
.OnBuild(file =>
28+
{
29+
var lambdaFunctionTemplates = ExecutionContext.FindTemplateInstances<ICSharpFileBuilderTemplate>("Aws.Lambda.Function").ToList();
30+
if (lambdaFunctionTemplates?.Any() != true)
31+
{
32+
return;
33+
}
34+
35+
var namespaces = lambdaFunctionTemplates.Select(x => x.Namespace).Distinct().ToList();
36+
37+
foreach (var @namespace in namespaces.Order())
38+
{
39+
file.AddAssemblyAttribute("SuppressMessage", a =>
40+
{
41+
a.AddArgument("\"Formatting\"");
42+
a.AddArgument("\"IDE0130:Namespace does not match folder structure.\"");
43+
a.AddArgument($"Target = \"{@namespace}\"");
44+
a.AddArgument("Scope = \"namespaceanddescendants\"");
45+
a.AddArgument("Justification = \"Reducing namespace length should alleviate Lambda Annotation error messages about 127 character limits.\"");
46+
});
47+
}
48+
});
49+
}
50+
51+
public override bool CanRunTemplate()
52+
{
53+
var lambdaFunctionTemplates = ExecutionContext.FindTemplateInstances<ICSharpFileBuilderTemplate>("Aws.Lambda.Function").ToList();
54+
return lambdaFunctionTemplates?.Any() == true;
55+
}
56+
57+
[IntentManaged(Mode.Fully)]
58+
public CSharpFile CSharpFile { get; }
59+
60+
[IntentManaged(Mode.Ignore)]
61+
protected override CSharpFileConfig DefineFileConfig()
62+
{
63+
return new CSharpFileConfig(
64+
className: "AssemblyAttributes",
65+
@namespace: $"{this.GetNamespace()}",
66+
relativeLocation: this.GetFolderPath());
67+
}
68+
69+
[IntentManaged(Mode.Fully)]
70+
public override string TransformText()
71+
{
72+
return CSharpFile.ToString();
73+
}
74+
}
75+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using Intent.Engine;
5+
using Intent.Metadata.Models;
6+
using Intent.Modules.Common;
7+
using Intent.Modules.Common.Registrations;
8+
using Intent.RoslynWeaver.Attributes;
9+
using Intent.Templates;
10+
11+
[assembly: DefaultIntentManaged(Mode.Fully)]
12+
[assembly: IntentTemplate("Intent.ModuleBuilder.TemplateRegistration.SingleFileNoModel", Version = "1.0")]
13+
14+
namespace Intent.Modules.Aws.Lambda.Functions.Templates.AssemblyAttributes
15+
{
16+
[IntentManaged(Mode.Merge, Body = Mode.Merge, Signature = Mode.Fully)]
17+
public class AssemblyAttributesTemplateRegistration : SingleFileTemplateRegistration
18+
{
19+
public override string TemplateId => AssemblyAttributesTemplate.TemplateId;
20+
21+
[IntentManaged(Mode.Fully)]
22+
public override ITemplate CreateTemplateInstance(IOutputTarget outputTarget)
23+
{
24+
return new AssemblyAttributesTemplate(outputTarget);
25+
}
26+
}
27+
}

Modules/Intent.Modules.Aws.Lambda.Functions/Templates/LambdaFunctionClass/LambdaFunctionClassTemplatePartial.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
using Intent.Metadata.Models;
77
using Intent.Modules.Aws.Lambda.Functions.Api;
88
using Intent.Modules.Common;
9+
using Intent.Modules.Common.CSharp.Api;
910
using Intent.Modules.Common.CSharp.Builder;
1011
using Intent.Modules.Common.CSharp.Templates;
1112
using Intent.Modules.Common.CSharp.VisualStudio;
1213
using Intent.Modules.Common.Templates;
14+
using Intent.Modules.Common.Types.Api;
1315
using Intent.Modules.Common.VisualStudio;
1416
using Intent.Modules.Constants;
1517
using Intent.Modules.Metadata.WebApi.Models;
@@ -40,6 +42,8 @@ public LambdaFunctionClassTemplate(IOutputTarget outputTarget, ILambdaFunctionCo
4042
AddTypeSource(TemplateRoles.Application.Query);
4143
AddTypeSource(TemplateRoles.Application.Contracts.Enum);
4244

45+
FulfillsRole("Aws.Lambda.Function");
46+
4347
CSharpFile = new CSharpFile(this.GetNamespace(), this.GetFolderPath())
4448
.AddUsing("System")
4549
.AddUsing("System.Collections.Generic")
@@ -296,6 +300,30 @@ private static bool CSharpTypeIsCollection(ITypeReference? typeReference)
296300

297301
return stereotype.GetProperty<bool>("Is Collection");
298302
}
303+
304+
string GetNamespace(
305+
params string[] additionalFolders)
306+
{
307+
return string.Join(".", new[]
308+
{
309+
"Lambda"
310+
}
311+
.Concat(Model.GetParentFolders()
312+
.Where(x =>
313+
{
314+
if (string.IsNullOrWhiteSpace(x.Name))
315+
return false;
316+
317+
if (x is FolderModel fm)
318+
{
319+
return !fm.HasFolderOptions() || fm.GetFolderOptions().NamespaceProvider();
320+
}
321+
322+
return true;
323+
})
324+
.Select(x => x.Name))
325+
.Concat(additionalFolders));
326+
}
299327

300328
[IntentManaged(Mode.Fully)]
301329
public CSharpFile CSharpFile { get; }

Modules/Intent.Modules.Aws.Lambda.Functions/Templates/TemplateExtensions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using Intent.Modules.Aws.Lambda.Functions.Api;
3+
using Intent.Modules.Aws.Lambda.Functions.Templates.AssemblyAttributes;
34
using Intent.Modules.Aws.Lambda.Functions.Templates.ExceptionHandlerHelper;
45
using Intent.Modules.Aws.Lambda.Functions.Templates.JsonResponse;
56
using Intent.Modules.Aws.Lambda.Functions.Templates.LambdaFunctionClass;
@@ -15,6 +16,10 @@ namespace Intent.Modules.Aws.Lambda.Functions.Templates
1516
{
1617
public static class TemplateExtensions
1718
{
19+
public static string GetAssemblyAttributesName(this IIntentTemplate template)
20+
{
21+
return template.GetTypeName(AssemblyAttributesTemplate.TemplateId);
22+
}
1823
public static string GetExceptionHandlerHelperName(this IIntentTemplate template)
1924
{
2025
return template.GetTypeName(ExceptionHandlerHelperTemplate.TemplateId);

0 commit comments

Comments
 (0)