-
Notifications
You must be signed in to change notification settings - Fork 491
Fix issue with Source generator for Lambda functions that return void #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
04311e5
to
1dbc9d2
Compare
philasmar
approved these changes
Aug 2, 2022
ganeshnj
reviewed
Aug 2, 2022
@@ -0,0 +1 @@ | |||
{"AWSTemplateFormatVersion":"2010-09-09","Transform":"AWS::Serverless-2016-10-31","Description":"An AWS Serverless Application.","Parameters":{"ArchitectureTypeParameter":{"Type":"String","Default":"x86_64","AllowedValues":["x86_64","arm64"]}},"Globals":{"Function":{"Architectures":[{"Ref":"ArchitectureTypeParameter"}]}},"Resources":{"GreeterSayHello":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":1024,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootGet":{"Type":"HttpApi","Properties":{"Path":"/Greeter/SayHello","Method":"GET","PayloadFormatVersion":"1.0"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.Greeter_SayHello_Generated::SayHello"]}}},"SimpleCalculatorAdd":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":256,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootGet":{"Type":"Api","Properties":{"Path":"/SimpleCalculator/Add","Method":"GET"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Add_Generated::Add"]}}},"SimpleCalculatorSubtract":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":256,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootGet":{"Type":"Api","Properties":{"Path":"/SimpleCalculator/Subtract","Method":"GET"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Subtract_Generated::Subtract"]}}},"SimpleCalculatorMultiply":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":256,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootGet":{"Type":"Api","Properties":{"Path":"/SimpleCalculator/Multiply/{x}/{y}","Method":"GET"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Multiply_Generated::Multiply"]}}},"SimpleCalculatorDivideAsync":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":256,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootGet":{"Type":"Api","Properties":{"Path":"/SimpleCalculator/DivideAsync/{x}/{y}","Method":"GET"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_DivideAsync_Generated::DivideAsync"]}}},"TestServerlessAppComplexCalculatorAddGenerated":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootPost"]},"Properties":{"MemorySize":256,"Timeout":30,"Role":null,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootPost":{"Type":"HttpApi","Properties":{"Path":"/ComplexCalculator/Add","Method":"POST","PayloadFormatVersion":"2.0"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.ComplexCalculator_Add_Generated::Add"]}}},"TestServerlessAppComplexCalculatorSubtractGenerated":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootPost"]},"Properties":{"MemorySize":256,"Timeout":30,"Policies":["AWSLambdaBasicExecutionRole"],"Events":{"RootPost":{"Type":"HttpApi","Properties":{"Path":"/ComplexCalculator/Subtract","Method":"POST","PayloadFormatVersion":"2.0"}}},"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.ComplexCalculator_Subtract_Generated::Subtract"]}}},"PI":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations"},"Properties":{"MemorySize":256,"Timeout":30,"Policies":["AWSLambdaBasicExecutionRole"],"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Pi_Generated::Pi"]}}},"Random":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations"},"Properties":{"MemorySize":256,"Timeout":30,"Policies":["AWSLambdaBasicExecutionRole"],"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Random_Generated::Random"]}}},"Randoms":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations"},"Properties":{"MemorySize":256,"Timeout":30,"Policies":["AWSLambdaBasicExecutionRole"],"PackageType":"Image","ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.SimpleCalculator_Randoms_Generated::Randoms"]}}},"GreeterSayHelloAsync":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations","SyncedEvents":["RootGet"]},"Properties":{"MemorySize":256,"Timeout":50,"Policies":["AWSLambdaBasicExecutionRole"],"PackageType":"Image","Events":{"RootGet":{"Type":"HttpApi","Properties":{"Path":"/Greeter/SayHelloAsync","Method":"GET","PayloadFormatVersion":"1.0"}}},"ImageUri":"626492997873.dkr.ecr.us-west-2.amazonaws.com/testserverlessapp:greetersayhello-c013811cde6a-latest","ImageConfig":{"Command":["TestServerlessApp::TestServerlessApp.Greeter_SayHelloAsync_Generated::SayHelloAsync"]}}},"ToUpper":{"Type":"AWS::Serverless::Function","Metadata":{"Tool":"Amazon.Lambda.Annotations"},"Properties":{"Runtime":"dotnet6","CodeUri":"s3://normj-west2/","MemorySize":256,"Timeout":30,"Policies":["AWSLambdaBasicExecutionRole"],"PackageType":"Zip","Handler":"TestServerlessApp::TestServerlessApp.Sub1.Functions_ToUpper_Generated::ToUpper"}}},"Outputs":{"RestApiURL":{"Description":"Rest API endpoint URL for Prod environment","Value":{"Fn::Sub":"https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"}},"HttpApiURL":{"Description":"HTTP API endpoint URL for Prod environment","Value":{"Fn::Sub":"https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com"}}}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this exist?
serverless.template must have the new function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
1dbc9d2
to
454cf93
Compare
ganeshnj
approved these changes
Aug 2, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of changes:
For Amazon.Lambda.Annotations if a method with the
LambdaMethod
attribute has its return type set tovoid
the source generator would generate invalid code.For example if you had a Lambda function like this
The generated code that wraps this call would previously look like this with an invalid
return
statement when calling this void method.This fix removes the invalid
return
statement. The reason this code was happening is the code was treating methods that returnvoid
andTask
as the same via theReturnVoidOrTask
property. Since it is not safe to treat void and task the same I replaced this property withReturnVoid
andReturnTask
forcing users to think what is the right thing to do in the context.Ignore the
LambdaFunctionTemplate.cs
file because that is generated from theLambdaFunctionTemplate.tt
file.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.