aws / aws/aws-lambda-dotnet

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

オープン
#840 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る
feature-request module/lambda-client-lib p2 queued
主要言語
C#
スター
1.7k
フォーク
503
平均マージ
1日 18時間
マージ済み PR(30日)
21

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Issue ではファイルやテストが指定されていないため、まず LambdaSerializer 属性の宣言と serializer を解決するコードを特定します。メソッド・クラス・アセンブリの優先順位でクラスレベルの処理を追加し、その後、各レベルをカバーするテストを追加または更新して、要求されたクラス全体の動作を検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, csharp
領域
backend, cloud
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。