aws / aws/aws-lambda-dotnet

Add support for specifying '[LambdaSerializer]' at the class level

Abierto
#840 3 comentarios 2 reacciones 0 asignados Ver en GitHub
feature-request module/lambda-client-lib p2 queued
Lenguaje dominante
C#
Estrellas
1.7k
Forks
503
Merge medio
1 d 18 h
PR fusionados (30 d)
21

Descripción

Allow specifying a lambda serializer for a whole class.

## Describe the Feature
The `[LambdaSerializer]` attribute can currently only be specified either at the assembly level (applying to all lambda functions in the whole dll) or at the method level (which only applies the serializer for that specific method).

When both the assembly and method attributes are applied, the method-level one takes precedence, which is a sensible design.

However, it would be very useful to also allow the attribute at the class level, so that it applies the serializer to all lambda functions inside the class.

### Is your Feature Request related to a problem?
We have a base class defined for all lambda functions as part of a shared library project. Several consuming projects rely on this package to expose their lambda functions by inheriting from this base class.

We had a situation where we needed to have different serializers configured in the same assembly for different functions, but .Net does not expose a way to add attributes to the methods of a base class from the inheriting class. In our scenario, we had to create a new method in the parent class, add the method-level attribute to it, and then redirect the call to the base class' method.

This design is less than ideal, and could be completely avoided on our end if it was possible to just specify the attribute on the class instead: no redirection would be needed.

## Proposed Solution
1. Add the `Class` attribute target to the `[LambdaSerializer]` and use it to indicate which serializer should be used for all functions in a class.
2. Change the place where the serializer is fetched to consider the class-level attribute as well
3. The order of precedence for the attributes should be method->class->assembly.

### Describe alternatives you've considered
Only alternative we found in our scenario was creating a redirection method in the class with the serializer attribute, and then pointing AWS to that method instead of the original one.

## Additional Context
We want to have a strong interface for lambda functions on our side, so this was created as a shared library that other projects implement. We don't want to force a specific serializer in that base class, since the decision depends on the actual implementors.

### Environment
Not environment specific

* [ ] :wave: I may be able to implement this feature request
* [ ] :warning: This feature might incur a breaking change

---

This is a :rocket: Feature Request

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

El issue no nombra archivos ni tests; empieza por localizar la declaración del atributo LambdaSerializer y el código que resuelve los serializers. Añade el manejo a nivel de clase con precedencia método-clase-assembly y, después, añade o actualiza tests que cubran cada nivel y verifica el comportamiento solicitado para toda la clase.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
aws, csharp
Área
backend, cloud
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.