Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ private Expression CreateSerializeExpression(object customerSerializerInstance,
if (customerSerializerInstance == null)
{
throw LambdaExceptions.ValidationException(Errors.UserCodeLoader.SerializeMissingAttribute,
_handler.AssemblyName, _handler.MethodName, dataType.FullName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

slight perf, we should cache the typeof(LambdaSerializerAttribute) in a member to avoid performing same operation. Not ship blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to cache it? If it runs that code and throws that Exception, it's lights out, fatal error, isn't it?

_handler.AssemblyName, _handler.MethodName, dataType.FullName, typeof(LambdaSerializerAttribute).FullName);
}

iLambdaSerializerType = customerSerializerInstance
Expand Down Expand Up @@ -372,7 +372,7 @@ private Expression CreateDeserializeExpression(object customerSerializerInstance
if (customerSerializerInstance == null)
{
throw LambdaExceptions.ValidationException(Errors.UserCodeLoader.DeserializeMissingAttribute,
_handler.AssemblyName, _handler.MethodName, dataType.FullName);
_handler.AssemblyName, _handler.MethodName, dataType.FullName, typeof(LambdaSerializerAttribute).FullName);
}

genericTypes = new[] {dataType};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ internal static class Internal
public const string CouldNotFindHandlerAssembly = "Could not find the specified handler assembly with the file name '{0}'. The assembly should be located in the root of your uploaded .zip file.";
public const string UnableToLoadAssembly = "Unable to load assembly '{0}'.";
public const string UnableToLoadType = "Unable to load type '{0}' from assembly '{1}'.";
public const string DeserializeMissingAttribute = "Could not find the LambdaSerializerAttribute on the assembly '{0}' or method '{1}' while attempting to deserialize input data of type '{2}'. To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with Amazon.Lambda.LambdaSerializerAttribute.";
public const string SerializeMissingAttribute = "Could not find the LambdaSerializerAttribute on the assembly '{0}' or method '{1}' while attempting to serialize output data of type '{2}'. To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with Amazon.Lambda.LambdaSerializerAttribute.";
public const string DeserializeMissingAttribute = "Could not find the LambdaSerializerAttribute on the assembly '{0}' or method '{1}' while attempting to deserialize input data of type '{2}'. To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with {3}.";
public const string SerializeMissingAttribute = "Could not find the LambdaSerializerAttribute on the assembly '{0}' or method '{1}' while attempting to serialize output data of type '{2}'. To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with {3}.";
public const string MethodTooManyParams = "Method '{0}' of type '{1}' is not supported: the method has more than 2 parameters.";
public const string MethodSecondParamNotContext = "Method '{0}' of type '{1}' is not supported: the method has 2 parameters, but the second parameter is not of type '{2}'.";
public const string NoMatchingMethod = "Unable to find method '{0}' in type '{1}' from assembly '{2}': Found no methods matching method name '{3}'.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Amazon.Lambda.Core;
using Amazon.Lambda.RuntimeSupport.Bootstrap;
using Amazon.Lambda.RuntimeSupport.ExceptionHandling;
using Amazon.Lambda.RuntimeSupport.Helpers;
Expand Down Expand Up @@ -149,8 +150,8 @@ public async Task NegativeBootstrapInitTestsAsync()
await TestHandlerFailAsync("HandlerTest::HandlerTest.CustomerType::TwoInputsNoContextMethod", "is not supported: the method has 2 parameters, but the second parameter is not of type");
await TestHandlerFailAsync("HandlerTest::HandlerTest.CustomerType::TooManyInputsMethod", "is not supported: the method has more than 2 parameters.");

await TestHandlerFailAsync("HandlerTestNoSerializer::HandlerTestNoSerializer.CustomerType::PocoInPocoOut", "To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with Amazon.Lambda.LambdaSerializerAttribute.");
await TestHandlerFailAsync("HandlerTestNoSerializer::HandlerTestNoSerializer.CustomerType::PocoInPocoOut", "To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with Amazon.Lambda.LambdaSerializerAttribute.");
await TestHandlerFailAsync("HandlerTestNoSerializer::HandlerTestNoSerializer.CustomerType::PocoInPocoOut", $"To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with {typeof(LambdaSerializerAttribute).FullName}.");
await TestHandlerFailAsync("HandlerTestNoSerializer::HandlerTestNoSerializer.CustomerType::PocoInPocoOut", $"To use types other than System.IO.Stream as input/output parameters, the assembly or Lambda function should be annotated with {typeof(LambdaSerializerAttribute).FullName}.");

var noZeroParamTypeEx = await TestHandlerFailAsync("HandlerTest::HandlerTest.NoZeroParamConstructorCustomerType::SimpleMethod", "No parameterless constructor defined");
Assert.IsAssignableFrom<MissingMethodException>(noZeroParamTypeEx);
Expand Down