用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/aws/aws-sdk-net --skill type-mapping命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Maps Smithy protocol traits to generated SDK marshaller/unmarshaller code patterns
Exact patterns generated code must follow to match the AWS SDK for .NET public API surface
How to deserialize a Smithy model.json into typed C# records and navigate the shape graph
基于 SOC 职业分类
正在显示 SKILL.md
| name | type-mapping |
| description | Rules for converting Smithy shape types to .NET types, including nullability and collection defaults |
Definitive mapping from Smithy shape types to .NET types, plus nullability and collection default rules.
| Smithy shape | .NET type | Notes |
|---|---|---|
boolean | bool? | Nullable |
string | string | Reference type, nullable by nature |
integer | int? | Nullable |
long | long? | Nullable |
float | float? | Nullable |
double | double? | Nullable |
timestamp | DateTime? | Nullable |
byte | — | Not supported yet — throws. No settled .NET mapping (the current SDK never emitted byte/short) |
short | — | Not supported yet — throws |
bigInteger | — | Not supported yet — throws. Wider-numeric types are earmarked for a dedicated numerics extension |
bigDecimal | — | Not supported yet — throws |
blob | MemoryStream | Not supported yet — throws. Target: streaming blobs → Stream, non-streaming → MemoryStream |
document | Amazon.Runtime.Documents.Document | Not supported yet — throws. SDK runtime type |
enum | string (Phase 1) / ConstantClass (Phase 2) | Not supported yet — throws. Phase 2 uses the ConstantClass pattern |
intEnum | int? | Not supported yet — throws |
list | List<T> | V4 default: null; see Collection Defaults |
map | Dictionary<TKey, TValue> | V4 default: null; see Collection Defaults |
structure | Generated class | See structure rules below |
union | Generated class | Generated as regular structure (matches current SDK) |
The AWS SDK for .NET V4 convention:
bool?, int?, DateTime?, etc. regardless of @required or @default traitsstring, MemoryStream) — nullable by nature, no ? suffix needed in the type declarationnull; see Collection Defaults section@default trait does NOT change nullability — this matches current SDK behavior@required trait does NOT change nullability — it only affects the [AWSProperty(Required=true)] attributeThe generator will support an opt-in mode that respects Smithy's nullability traits (@required, @default, @clientOptional) for non-AWS Smithy models. When disabled (the default for AWS), all value types are nullable regardless of traits.
Collections use AWSConfigs.InitializeCollections for SDK V4 backwards compatibility. The
generator emits an auto-property with the initializer expression directly, plus an internal
IsSet{Property}() method that the AWS SDK runtime (and marshallers) call:
public List<AuditEvent> AuditEvents { get; set; } = AWSConfigs.InitializeCollections ? new List<AuditEvent>() : null;
internal bool IsSetAuditEvents() => this.AuditEvents != null && (this.AuditEvents.Count > 0 || !AWSConfigs.InitializeCollections);
When AWSConfigs.InitializeCollections is false (V4 default), collections start as null,
and an empty list still counts as "set" (the caller cleared the value). When true (V3 compat),
collections start empty and an empty list counts as "not set". The IsSet method encodes that
rule so callers — including the public reflection API AWSSDKUtils.IsPropertySet — see the
correct answer in both modes.
Smithy allows constrained shapes (e.g. a string shape named Uuid with @length or @pattern). These do NOT get wrapper classes — they map to their underlying .NET type:
| Smithy | .NET |
|---|---|
Uuid (string shape with constraints) | string |
AuditEvents (list shape) | List<AuditEvent> inline |
ChannelArn (string shape) | string |
The constraints flow through to [AWSProperty] attributes on the member that references the shape. When resolving [AWSProperty], check traits on both the member and its target shape:
@required is on the member@length / @range are typically on the target shape (e.g. AuditEvents list has @length(min:1, max:100), so PutAuditEventsRequest.AuditEvents gets [AWSProperty(Required=true, Min=1, Max=100)])Smithy error shapes often omit the Exception suffix. The naming rules (matching the existing generator's ExceptionShape.Name logic):
Exception → keep as-is (e.g. UnsupportedOperationException)Fault → replace Fault with ExceptionException (e.g. ChannelNotFound → ChannelNotFoundException)Error shapes have a message member in the Smithy model, but the generated exception class does not expose it as a property. The message is passed to System.Exception via the constructor and inherited as Exception.Message. The generator must filter out the message member when generating exception properties.
To get the .NET type for a structure member:
Target shape IDGenerationContext.Resolve(target) returns the shape. Prelude shapes (smithy.api#String,
etc.) are not in the model's shape map, but Resolve falls back to PreludeShapes, so
callers never special-case them — a prelude String comes back as a StringShape like any
other. Map the resolved shape's type from the table:
type from the tableList<{resolve member.Target}>Dictionary<{resolve key.Target}, {resolve value.Target}>string (Phase 1), ConstantClass subclass (Phase 2)Uuid) resolve to a StringShape → string (no wrapper)These shapes are implicit (not in the model JSON) and map directly. The .NET types below are the
target mapping; see the Type Mapping Table above for which are supported today vs. still throw
(Blob/Document are not supported yet):
| Prelude shape ID | .NET type |
|---|---|
smithy.api#String | string |
smithy.api#Boolean | bool? |
smithy.api#Integer | int? |
smithy.api#Long | long? |
smithy.api#Float | float? |
smithy.api#Double | double? |
smithy.api#Blob | MemoryStream |
smithy.api#Timestamp | DateTime? |
smithy.api#Document | Amazon.Runtime.Documents.Document |
smithy.api#Unit | (no type — used for operations with no input/output) |