diff --git a/.github/workflows/pr-build.yaml b/.github/workflows/pr-build.yaml index d69737c6..ccc2b638 100644 --- a/.github/workflows/pr-build.yaml +++ b/.github/workflows/pr-build.yaml @@ -13,7 +13,7 @@ permissions: write-all jobs: build: if: github.event.pull_request.draft == false - uses: LayeredCraft/devops-templates/.github/workflows/pr-build.yaml@v8.0 + uses: LayeredCraft/devops-templates/.github/workflows/pr-build.yaml@v8.1 with: solution: LayeredCraft.DynamoMapper.slnx hasTests: true diff --git a/.github/workflows/pr-title-check.yaml b/.github/workflows/pr-title-check.yaml index 762c0c53..c69a464b 100644 --- a/.github/workflows/pr-title-check.yaml +++ b/.github/workflows/pr-title-check.yaml @@ -10,4 +10,4 @@ permissions: jobs: validate: - uses: LayeredCraft/devops-templates/.github/workflows/pr-title-check.yml@v8.0 + uses: LayeredCraft/devops-templates/.github/workflows/pr-title-check.yml@v8.1 diff --git a/.github/workflows/publish-preview.yaml b/.github/workflows/publish-preview.yaml index 0185faa1..1e2aba9e 100644 --- a/.github/workflows/publish-preview.yaml +++ b/.github/workflows/publish-preview.yaml @@ -16,7 +16,7 @@ permissions: write-all jobs: publish: - uses: LayeredCraft/devops-templates/.github/workflows/publish-preview.yml@main + uses: LayeredCraft/devops-templates/.github/workflows/publish-preview.yml@v8.1 with: solution: LayeredCraft.DynamoMapper.slnx dotnetVersion: | diff --git a/.github/workflows/publish-release.yaml b/.github/workflows/publish-release.yaml index a8bf828e..ea17d3de 100644 --- a/.github/workflows/publish-release.yaml +++ b/.github/workflows/publish-release.yaml @@ -8,7 +8,7 @@ permissions: write-all jobs: publish: - uses: LayeredCraft/devops-templates/.github/workflows/publish-release.yml@main + uses: LayeredCraft/devops-templates/.github/workflows/publish-release.yml@v8.1 with: solution: LayeredCraft.DynamoMapper.slnx dotnetVersion: | diff --git a/.github/workflows/release-drafter.yaml b/.github/workflows/release-drafter.yaml index 87550814..f263aea4 100644 --- a/.github/workflows/release-drafter.yaml +++ b/.github/workflows/release-drafter.yaml @@ -14,7 +14,7 @@ permissions: jobs: draft: - uses: LayeredCraft/devops-templates/.github/workflows/release-drafter.yml@v8.0 + uses: LayeredCraft/devops-templates/.github/workflows/release-drafter.yml@v8.1 with: event_name: ${{ github.event_name }} pr_draft: ${{ github.event.pull_request.draft == true }} diff --git a/docs/changelog.md b/docs/changelog.md index dd02ad42..a21316ab 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -20,6 +20,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Diagnostics for nested cycles and invalid dot-notation paths (DM0006-DM0008). - `examples/DynamoMapper.Nested` for end-to-end nested mapping scenarios. +### Fixed + +- Nested `FromItem` fallback behavior now honors effective requiredness for nested object and + nested collection containers. +- Non-nullable optional nested object fallbacks now emit `null!` to avoid CS8601 warnings while + preserving optional semantics. + ### Planned - Phase 1: Attribute-based mapping - Phase 2: Fluent DSL configuration diff --git a/docs/usage/basic-mapping.md b/docs/usage/basic-mapping.md index f5c836bf..b7b9f889 100644 --- a/docs/usage/basic-mapping.md +++ b/docs/usage/basic-mapping.md @@ -65,6 +65,20 @@ Nested collections of sets (SS/NS/BS) are not supported. Nested object graphs cannot contain cycles. Cycles emit `DM0006`. +### Missing Nested Attributes During `FromItem` + +For nested object and nested collection containers, generated fallback behavior follows effective +requiredness: + +- `Required = true` (or C# `required`) -> missing attribute throws. +- `Required = false` -> nested object falls back to `null`/`null!`; nested collections fall back to + `null`/`[]` depending on container nullability. +- no explicit override -> `DefaultRequiredness` applies (default: + `Requiredness.InferFromNullability`). + +With `InferFromNullability`, non-nullable containers are treated as required and missing attributes +throw; nullable containers fall back to `null`. + ### Example ```csharp diff --git a/docs/usage/field-configuration.md b/docs/usage/field-configuration.md index eecbd36f..d2db29de 100644 --- a/docs/usage/field-configuration.md +++ b/docs/usage/field-configuration.md @@ -40,6 +40,8 @@ Notes: - Invalid paths emit `DM0008`. - `OmitIfNull` works on nested object and nested collection properties too, so paths like `"Customer.Profile"` or `"Customer.Addresses"` can omit null containers during `ToItem`. +- `Required` works on nested object and nested collection containers too, including dot-notation + paths. ### Collection Element Members @@ -88,3 +90,11 @@ Notes: | `ToMethod` | Uses a custom method to serialize a value. | | `FromMethod` | Uses a custom method to deserialize a value. | | `Format` | Overrides default format for date/time/enum conversions. | + +Notes: + +- If `Required` is omitted, `FromItem` uses mapper-level `DefaultRequiredness` + (`InferFromNullability` by default). +- For nested containers, effective requiredness controls missing-attribute fallback: + required -> throw; optional -> nullable containers use `null`, non-nullable collections use `[]`, + and non-nullable nested objects use `null!`. diff --git a/skills/dynamo-mapper/references/core-usage.md b/skills/dynamo-mapper/references/core-usage.md index 3e7d1e75..2cb17f6b 100644 --- a/skills/dynamo-mapper/references/core-usage.md +++ b/skills/dynamo-mapper/references/core-usage.md @@ -117,9 +117,11 @@ Order: ## Requiredness and defaults -- missing required root scalar values throw at runtime +- missing required values throw at runtime (scalars and nested containers) - nullable root scalar values read as `null` when absent - optional/default-initialized members can keep their C# defaults when the attribute is missing +- nested containers respect effective requiredness (`DynamoField.Required` override, otherwise + mapper default / nullability inference) ## Safe guidance diff --git a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/Models/NestedMappingInfo.cs b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/Models/NestedMappingInfo.cs index bba5ba49..b32cd099 100644 --- a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/Models/NestedMappingInfo.cs +++ b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/Models/NestedMappingInfo.cs @@ -1,4 +1,5 @@ using LayeredCraft.DynamoMapper.Generator.Models; +using LayeredCraft.DynamoMapper.Runtime; using LayeredCraft.SourceGeneratorTools.Types; namespace LayeredCraft.DynamoMapper.Generator.PropertyMapping.Models; @@ -49,6 +50,7 @@ EquatableArray Properties /// Whether the property is marked as required. /// Whether the property is init-only. /// Whether the property has a default value. +/// Configured requiredness for generated read paths. /// If the property is itself a nested object, its mapping info. internal sealed record NestedPropertySpec( string PropertyName, @@ -62,5 +64,6 @@ internal sealed record NestedPropertySpec( bool IsRequired, bool IsInitOnly, bool HasDefaultValue, + Requiredness Requiredness, NestedMappingInfo? NestedMapping = null ); diff --git a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/NestedObjectTypeAnalyzer.cs b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/NestedObjectTypeAnalyzer.cs index 6fb01fcd..57a6fff4 100644 --- a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/NestedObjectTypeAnalyzer.cs +++ b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/NestedObjectTypeAnalyzer.cs @@ -235,6 +235,12 @@ private static IPropertySymbol[] GetMappableProperties( } var propertyAnalysis = propertyAnalysisResult.Value!; + var requiredness = + RequirednessResolver.ResolveConfigured( + fieldOptions, + propertyAnalysis.IsRequired, + nestedContext.Context.MapperOptions.DefaultRequiredness + ); // Determine the DynamoDB attribute name var dynamoKey = @@ -268,6 +274,7 @@ private static IPropertySymbol[] GetMappableProperties( propertyAnalysis.IsRequired, propertyAnalysis.IsInitOnly, propertyAnalysis.HasDefaultValue, + requiredness, null ) ); @@ -331,6 +338,7 @@ private static IPropertySymbol[] GetMappableProperties( propertyAnalysis.IsRequired, propertyAnalysis.IsInitOnly, propertyAnalysis.HasDefaultValue, + requiredness, null ) ); @@ -362,6 +370,7 @@ private static IPropertySymbol[] GetMappableProperties( propertyAnalysis.IsRequired, propertyAnalysis.IsInitOnly, propertyAnalysis.HasDefaultValue, + requiredness, nestedResult.Value ) ); @@ -495,24 +504,24 @@ INamedTypeSymbol t when context.WellKnownTypes.IsType( [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeSpanFormat}\""], [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeSpanFormat}\""] ), - INamedTypeSymbol t - when supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsDateOnly(t, context) - => new TypeMappingStrategy( - "DateOnly", - "", - nullableModifier, - [$"\"{fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat}\""], - [$"\"{fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat}\""] - ), - INamedTypeSymbol t - when supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsTimeOnly(t, context) - => new TypeMappingStrategy( - "TimeOnly", - "", - nullableModifier, - [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat}\""], - [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat}\""] - ), + INamedTypeSymbol t when + supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsDateOnly(t, context) => new + TypeMappingStrategy( + "DateOnly", + "", + nullableModifier, + [$"\"{fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat}\""], + [$"\"{fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat}\""] + ), + INamedTypeSymbol t when + supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsTimeOnly(t, context) => new + TypeMappingStrategy( + "TimeOnly", + "", + nullableModifier, + [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat}\""], + [$"\"{fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat}\""] + ), IArrayTypeSymbol { ElementType.SpecialType: SpecialType.System_Byte } => new TypeMappingStrategy("Binary", "", nullableModifier, [], []), INamedTypeSymbol t when @@ -665,16 +674,14 @@ INamedTypeSymbol t when context.WellKnownTypes.IsType( ) => CreateCollectionFormatArgs( fieldOptions?.Format ?? context.MapperOptions.TimeSpanFormat ), - INamedTypeSymbol t - when supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsDateOnly(t, context) - => CreateCollectionFormatArgs( - fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat - ), - INamedTypeSymbol t - when supportsDateOnlyTimeOnly && DateOnlyTimeOnlySupport.IsTimeOnly(t, context) - => CreateCollectionFormatArgs( - fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat - ), + INamedTypeSymbol t when supportsDateOnlyTimeOnly && + DateOnlyTimeOnlySupport.IsDateOnly(t, context) => CreateCollectionFormatArgs( + fieldOptions?.Format ?? context.MapperOptions.DateOnlyFormat + ), + INamedTypeSymbol t when supportsDateOnlyTimeOnly && + DateOnlyTimeOnlySupport.IsTimeOnly(t, context) => CreateCollectionFormatArgs( + fieldOptions?.Format ?? context.MapperOptions.TimeOnlyFormat + ), INamedTypeSymbol { TypeKind: TypeKind.Enum } => CreateCollectionFormatArgs( fieldOptions?.Format ?? context.MapperOptions.EnumFormat ), diff --git a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingCodeRenderer.cs b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingCodeRenderer.cs index bb15a42a..f4f9ecaa 100644 --- a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingCodeRenderer.cs +++ b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/PropertyMappingCodeRenderer.cs @@ -564,7 +564,7 @@ HelperMethodRegistry helperRegistry var itemParam = context.MapperOptions.FromMethodParameterName; // Determine fallback based on required keyword and nullability - var fallback = GetNestedObjectFallback(spec, analysis); + var fallback = GetNestedObjectFallback(spec, analysis, context); return nestedMapping switch { @@ -592,21 +592,26 @@ HelperMethodRegistry helperRegistry /// Determines the fallback expression for a nested object when not found in DynamoDB. /// private static string GetNestedObjectFallback( - PropertyMappingSpec spec, PropertyAnalysis analysis + PropertyMappingSpec spec, PropertyAnalysis analysis, GeneratorContext context ) { - // If property has 'required' keyword, throw on missing - if (analysis.IsRequired) + var configuredRequiredness = + RequirednessResolver.ResolveConfigured( + analysis.FieldOptions, + analysis.IsRequired, + context.MapperOptions.DefaultRequiredness + ); + if (RequirednessResolver.IsEffectivelyRequired( + configuredRequiredness, + analysis.Nullability + )) return $"throw new System.InvalidOperationException(\"Required attribute '{spec.Key}' not found.\")"; - // For nullable types, return null if (analysis.Nullability.IsNullableType) return "null"; - // For non-nullable, non-required types, we still use null but this may cause CS8601 - // This is a design limitation - the model should either mark as required or nullable - return "null"; + return "null!"; } /// @@ -757,16 +762,13 @@ HelperMethodRegistry helperRegistry // Recursive nested object var nestedVarName = $"{mapVarName}_{prop.PropertyName.ToLowerInvariant()}"; - // Determine fallback based on required and nullability - string fallback; - if (prop.IsRequired) - fallback = - $"throw new System.InvalidOperationException(\"Required nested property '{prop.DynamoKey}' not found in DynamoDB item.\")"; - else if (prop.Nullability.IsNullableType) - fallback = "null"; - else - // Non-nullable, non-required - use null (design limitation) - fallback = "null"; + var fallback = + RequirednessResolver.IsEffectivelyRequired(prop.Requiredness, prop.Nullability) + ? + $"throw new System.InvalidOperationException(\"Required nested property '{prop.DynamoKey}' not found in DynamoDB item.\")" + : prop.Nullability.IsNullableType + ? "null" + : "null!"; string nestedCode; if (prop.NestedMapping is MapperBasedNesting mapperBased) @@ -800,7 +802,7 @@ HelperMethodRegistry helperRegistry var isNullable = prop.Nullability.IsNullableType; var varName = prop.PropertyName.ToLowerInvariant(); var fallback = - prop.IsRequired + RequirednessResolver.IsEffectivelyRequired(prop.Requiredness, prop.Nullability) ? $"throw new System.InvalidOperationException(\"Required attribute '{prop.DynamoKey}' not found.\")" : isNullable @@ -861,8 +863,7 @@ HelperMethodRegistry helperRegistry ) + ", " : ""; - // Determine requiredness based on property analysis - var requiredness = prop.IsRequired ? "Requiredness.Required" : "Requiredness.Optional"; + var requiredness = $"Requiredness.{prop.Requiredness}"; sb.Append( $"{prop.PropertyName} = {mapVarName}.{getMethod}{genericArg}(\"{prop.DynamoKey}\", {typeArgs}{requiredness})," @@ -894,8 +895,10 @@ private static string RenderTryGetCondition( ) + ", " : ""; + var requiredness = $"Requiredness.{prop.Requiredness}"; + return - $"{mapVarName}.{tryMethod}{genericArg}(\"{prop.DynamoKey}\", out var {outVarName}, {typeArgs}Requiredness.InferFromNullability)"; + $"{mapVarName}.{tryMethod}{genericArg}(\"{prop.DynamoKey}\", out var {outVarName}, {typeArgs}{requiredness})"; } /// @@ -1139,7 +1142,7 @@ HelperMethodRegistry helperRegistry var varName = spec.PropertyName.ToLowerInvariant(); // Determine fallback based on required keyword and nullability - var fallback = GetNestedCollectionFallback(spec, analysis); + var fallback = GetNestedCollectionFallback(spec, analysis, context); return collectionInfo.Category switch { @@ -1172,20 +1175,25 @@ HelperMethodRegistry helperRegistry /// Determines the fallback expression for a nested collection when not found in DynamoDB. /// private static string GetNestedCollectionFallback( - PropertyMappingSpec spec, PropertyAnalysis analysis + PropertyMappingSpec spec, PropertyAnalysis analysis, GeneratorContext context ) { - // If property has 'required' keyword, throw on missing - if (analysis.IsRequired) + var configuredRequiredness = + RequirednessResolver.ResolveConfigured( + analysis.FieldOptions, + analysis.IsRequired, + context.MapperOptions.DefaultRequiredness + ); + if (RequirednessResolver.IsEffectivelyRequired( + configuredRequiredness, + analysis.Nullability + )) return $"throw new System.InvalidOperationException(\"Required attribute '{spec.Key}' not found.\")"; - // For nullable types, return null if (analysis.Nullability.IsNullableType) return "null"; - // For non-nullable, non-required collections, return empty collection - // Using collection expression [] which works for arrays, lists, and dictionaries in C# 12+ return "[]"; } diff --git a/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/RequirednessResolver.cs b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/RequirednessResolver.cs new file mode 100644 index 00000000..d198fddb --- /dev/null +++ b/src/LayeredCraft.DynamoMapper.Generators/PropertyMapping/RequirednessResolver.cs @@ -0,0 +1,35 @@ +using LayeredCraft.DynamoMapper.Generator.PropertyMapping.Models; +using LayeredCraft.DynamoMapper.Runtime; + +namespace LayeredCraft.DynamoMapper.Generator.PropertyMapping; + +/// Resolves effective requiredness for generated read paths. +internal static class RequirednessResolver +{ + /// Resolves configured requiredness for a property before nullability inference. + internal static Requiredness ResolveConfigured( + DynamoFieldOptions? fieldOptions, bool isCSharpRequired, + Requiredness mapperDefaultRequiredness + ) => fieldOptions?.Required switch + { + true => Requiredness.Required, + false => Requiredness.Optional, + null when isCSharpRequired => Requiredness.Required, + null => mapperDefaultRequiredness, + }; + + /// Resolves whether a property is effectively required after nullability inference. + internal static bool IsEffectivelyRequired( + Requiredness configuredRequiredness, PropertyNullabilityInfo nullability + ) => configuredRequiredness switch + { + Requiredness.Required => true, + Requiredness.Optional => false, + Requiredness.InferFromNullability => !nullability.IsNullableType, + _ => throw new ArgumentOutOfRangeException( + nameof(configuredRequiredness), + configuredRequiredness, + null + ), + }; +} diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ArrayOfNestedObjects_WithDotNotationOverride#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ArrayOfNestedObjects_WithDotNotationOverride#OrderMapper.g.verified.cs index 8c12117c..751bc4e6 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ArrayOfNestedObjects_WithDotNotationOverride#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ArrayOfNestedObjects_WithDotNotationOverride#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList().ToArray() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList().ToArray() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return order; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("product_id", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), + ProductId = map.GetString("product_id", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_DictionaryOfNestedObjects_WithDotNotationOverride#CatalogMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_DictionaryOfNestedObjects_WithDotNotationOverride#CatalogMapper.g.verified.cs index 4aa2954e..fc57c499 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_DictionaryOfNestedObjects_WithDotNotationOverride#CatalogMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_DictionaryOfNestedObjects_WithDotNotationOverride#CatalogMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class CatalogMapper var catalog = new global::MyNamespace.Catalog { Id = item.GetString("id", Requiredness.InferFromNullability), - ProductMap = item.TryGetValue("productMap", out var productmapAttr) && productmapAttr.M is { } productmapMap ? productmapMap.ToDictionary(kvp => kvp.Key, kvp => FromItem_OrderItem(kvp.Value.M)) : [], + ProductMap = item.TryGetValue("productMap", out var productmapAttr) && productmapAttr.M is { } productmapMap ? productmapMap.ToDictionary(kvp => kvp.Key, kvp => FromItem_OrderItem(kvp.Value.M)) : throw new System.InvalidOperationException("Required attribute 'productMap' not found."), }; return catalog; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_OrderItem(global::MyNam { return new global::MyNamespace.OrderItem { - Name = map.GetString("name", Requiredness.Optional), - CreatedAt = map.GetDateTime("createdAt", format: "yyyy-MM-dd", Requiredness.Optional), + Name = map.GetString("name", Requiredness.InferFromNullability), + CreatedAt = map.GetDateTime("createdAt", format: "yyyy-MM-dd", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationAttributeNameOverride#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationAttributeNameOverride#OrderMapper.g.verified.cs index edceb39b..20ce5500 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationAttributeNameOverride#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationAttributeNameOverride#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return order; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("product_id", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), + ProductId = map.GetString("product_id", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationFormatOverride#CustomerMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationFormatOverride#CustomerMapper.g.verified.cs index d7bbc61c..a0dced17 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationFormatOverride#CustomerMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithDotNotationFormatOverride#CustomerMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class CustomerMapper var customer = new global::MyNamespace.Customer { Id = item.GetString("id", Requiredness.InferFromNullability), - Contacts = item.TryGetValue("contacts", out var contactsAttr) && contactsAttr.L is { } contactsList ? contactsList.Select(av => FromItem_CustomerContact(av.M)).ToList() : [], + Contacts = item.TryGetValue("contacts", out var contactsAttr) && contactsAttr.L is { } contactsList ? contactsList.Select(av => FromItem_CustomerContact(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'contacts' not found."), }; return customer; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_CustomerContact(global: { return new global::MyNamespace.CustomerContact { - Name = map.GetString("name", Requiredness.Optional), - VerifiedAt = map.GetDateTime("verifiedAt", format: "yyyy-MM-dd", Requiredness.Optional), + Name = map.GetString("name", Requiredness.InferFromNullability), + VerifiedAt = map.GetDateTime("verifiedAt", format: "yyyy-MM-dd", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithMultipleDotNotationOverrides#CustomerMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithMultipleDotNotationOverrides#CustomerMapper.g.verified.cs index 2d476be8..e3eaafad 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithMultipleDotNotationOverrides#CustomerMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionDotNotationVerifyTests.Collection_ListOfNestedObjects_WithMultipleDotNotationOverrides#CustomerMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class CustomerMapper var customer = new global::MyNamespace.Customer { Id = item.GetString("id", Requiredness.InferFromNullability), - Contacts = item.TryGetValue("contacts", out var contactsAttr) && contactsAttr.L is { } contactsList ? contactsList.Select(av => FromItem_CustomerContact(av.M)).ToList() : [], + Contacts = item.TryGetValue("contacts", out var contactsAttr) && contactsAttr.L is { } contactsList ? contactsList.Select(av => FromItem_CustomerContact(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'contacts' not found."), }; return customer; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_CustomerContact(global: { return new global::MyNamespace.CustomerContact { - Name = map.GetString("contact_name", Requiredness.Optional), - VerifiedAt = map.GetDateTime("verifiedAt", format: "yyyy-MM-dd", Requiredness.Optional), + Name = map.GetString("contact_name", Requiredness.InferFromNullability), + VerifiedAt = map.GetDateTime("verifiedAt", format: "yyyy-MM-dd", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionVerifyTests.Collection_NestedObjectElementType_ShouldSucceed#ExampleEntityMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionVerifyTests.Collection_NestedObjectElementType_ShouldSucceed#ExampleEntityMapper.g.verified.cs index 2d3f6c8c..9ba2b991 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionVerifyTests.Collection_NestedObjectElementType_ShouldSucceed#ExampleEntityMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/CollectionVerifyTests.Collection_NestedObjectElementType_ShouldSucceed#ExampleEntityMapper.g.verified.cs @@ -29,7 +29,7 @@ public static partial class ExampleEntityMapper { var entity = new global::MyNamespace.Entity { - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_CustomClass(av.M)).ToList() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_CustomClass(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return entity; } @@ -44,7 +44,7 @@ private static Dictionary ToItem_CustomClass(global::MyN { return new global::MyNamespace.CustomClass { - Name = map.GetString("name", Requiredness.Optional), + Name = map.GetString("name", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/InheritanceVerifyTests.Inheritance_DotNotation_BaseProperty_WithOptIn_Succeeds#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/InheritanceVerifyTests.Inheritance_DotNotation_BaseProperty_WithOptIn_Succeeds#OrderMapper.g.verified.cs index ae4d71ab..455b23df 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/InheritanceVerifyTests.Inheritance_DotNotation_BaseProperty_WithOptIn_Succeeds#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/InheritanceVerifyTests.Inheritance_DotNotation_BaseProperty_WithOptIn_Succeeds#OrderMapper.g.verified.cs @@ -29,7 +29,7 @@ internal static partial class OrderMapper { var order = new global::MyNamespace.Order { - Address = item.TryGetValue("address", out var addressAttr) && addressAttr.M is { } addressMap ? FromItem_Address(addressMap) : null, + Address = item.TryGetValue("address", out var addressAttr) && addressAttr.M is { } addressMap ? FromItem_Address(addressMap) : throw new System.InvalidOperationException("Required attribute 'address' not found."), }; return order; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ArrayOfNestedObjects#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ArrayOfNestedObjects#OrderMapper.g.verified.cs index 7bb7843b..02eb70a9 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ArrayOfNestedObjects#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ArrayOfNestedObjects#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList().ToArray() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList().ToArray() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return order; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("productId", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), + ProductId = map.GetString("productId", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs index 2216b335..6a4d1811 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class CatalogMapper var catalog = new global::MyNamespace.Catalog { Id = item.GetString("id", Requiredness.InferFromNullability), - Products = item.TryGetValue("products", out var productsAttr) && productsAttr.M is { } productsMap ? productsMap.ToDictionary(kvp => kvp.Key, kvp => FromItem_Product(kvp.Value.M)) : [], + Products = item.TryGetValue("products", out var productsAttr) && productsAttr.M is { } productsMap ? productsMap.ToDictionary(kvp => kvp.Key, kvp => FromItem_Product(kvp.Value.M)) : throw new System.InvalidOperationException("Required attribute 'products' not found."), }; return catalog; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_Product(global::MyNames { return new global::MyNamespace.Product { - Name = map.GetString("name", Requiredness.Optional), - Price = map.GetDecimal("price", Requiredness.Optional), + Name = map.GetString("name", Requiredness.InferFromNullability), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_MapperBased#CatalogMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_MapperBased#CatalogMapper.g.verified.cs index 0d6ba321..3317073d 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_MapperBased#CatalogMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_DictionaryOfNestedObjects_MapperBased#CatalogMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class CatalogMapper var catalog = new global::MyNamespace.Catalog { Id = item.GetString("id", Requiredness.InferFromNullability), - Products = item.TryGetValue("products", out var productsAttr) && productsAttr.M is { } productsMap ? productsMap.ToDictionary(kvp => kvp.Key, kvp => global::MyNamespace.ProductMapper.FromItem(kvp.Value.M)) : [], + Products = item.TryGetValue("products", out var productsAttr) && productsAttr.M is { } productsMap ? productsMap.ToDictionary(kvp => kvp.Key, kvp => global::MyNamespace.ProductMapper.FromItem(kvp.Value.M)) : throw new System.InvalidOperationException("Required attribute 'products' not found."), }; return catalog; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_Inline#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_Inline#OrderMapper.g.verified.cs index 146cd07d..980e5a9c 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_Inline#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_Inline#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_LineItem(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return order; } @@ -48,9 +48,9 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("productId", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), - Price = map.GetDecimal("price", Requiredness.Optional), + ProductId = map.GetString("productId", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_MapperBased#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_MapperBased#OrderMapper.g.verified.cs index 439bbd50..03826e90 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_MapperBased#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListOfNestedObjects_MapperBased#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => global::MyNamespace.LineItemMapper.FromItem(av.M)).ToList() : [], + Items = item.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => global::MyNamespace.LineItemMapper.FromItem(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; return order; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListWithNestedObjectContainingScalarTypes#EventLogMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListWithNestedObjectContainingScalarTypes#EventLogMapper.g.verified.cs index 94c74a76..13d8df6b 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListWithNestedObjectContainingScalarTypes#EventLogMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_ListWithNestedObjectContainingScalarTypes#EventLogMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class EventLogMapper var eventLog = new global::MyNamespace.EventLog { Id = item.GetString("id", Requiredness.InferFromNullability), - Entries = item.TryGetValue("entries", out var entriesAttr) && entriesAttr.L is { } entriesList ? entriesList.Select(av => FromItem_LogEntry(av.M)).ToList() : [], + Entries = item.TryGetValue("entries", out var entriesAttr) && entriesAttr.L is { } entriesList ? entriesList.Select(av => FromItem_LogEntry(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'entries' not found."), }; return eventLog; } @@ -49,10 +49,10 @@ private static Dictionary ToItem_LogEntry(global::MyName { return new global::MyNamespace.LogEntry { - Timestamp = map.GetDateTime("timestamp", format: "O", Requiredness.Optional), - Message = map.GetString("message", Requiredness.Optional), - Severity = map.GetInt("severity", Requiredness.Optional), - IsError = map.GetBool("isError", Requiredness.Optional), + Timestamp = map.GetDateTime("timestamp", format: "O", Requiredness.InferFromNullability), + Message = map.GetString("message", Requiredness.InferFromNullability), + Severity = map.GetInt("severity", Requiredness.InferFromNullability), + IsError = map.GetBool("isError", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableDictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableDictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs index 4c6c06d5..21b7001c 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableDictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableDictionaryOfNestedObjects_Inline#CatalogMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_Product(global::MyNames { return new global::MyNamespace.Product { - Name = map.GetString("name", Requiredness.Optional), - Price = map.GetDecimal("price", Requiredness.Optional), + Name = map.GetString("name", Requiredness.InferFromNullability), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects#OrderMapper.g.verified.cs index cb273cad..a3c8842f 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects#OrderMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("productId", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), + ProductId = map.GetString("productId", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects_Inline#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects_Inline#OrderMapper.g.verified.cs index cb273cad..a3c8842f 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects_Inline#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedCollection_NullableListOfNestedObjects_Inline#OrderMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - ProductId = map.GetString("productId", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), + ProductId = map.GetString("productId", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_DeepNestedObjectWithListContainingNestedObjects#AccountMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_DeepNestedObjectWithListContainingNestedObjects#AccountMapper.g.verified.cs index 6a78231d..08bef8c4 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_DeepNestedObjectWithListContainingNestedObjects#AccountMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_DeepNestedObjectWithListContainingNestedObjects#AccountMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class AccountMapper var account = new global::MyNamespace.Account { AccountId = item.GetString("accountId", Requiredness.InferFromNullability), - Profile = item.TryGetValue("profile", out var profileAttr) && profileAttr.M is { } profileMap ? FromItem_UserProfile(profileMap) : null, + Profile = item.TryGetValue("profile", out var profileAttr) && profileAttr.M is { } profileMap ? FromItem_UserProfile(profileMap) : throw new System.InvalidOperationException("Required attribute 'profile' not found."), }; return account; } @@ -48,9 +48,9 @@ private static Dictionary ToItem_UserProfile(global::MyN { return new global::MyNamespace.UserProfile { - DisplayName = map.GetString("displayName", Requiredness.Optional), - Roles = map.GetList("roles", Requiredness.Optional), - Orders = map.TryGetValue("orders", out var ordersAttr) && ordersAttr.L is { } ordersList ? ordersList.Select(av => FromItem_PurchaseOrder(av.M)).ToList() : [], + DisplayName = map.GetString("displayName", Requiredness.InferFromNullability), + Roles = map.GetList("roles", Requiredness.InferFromNullability), + Orders = map.TryGetValue("orders", out var ordersAttr) && ordersAttr.L is { } ordersList ? ordersList.Select(av => FromItem_PurchaseOrder(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'orders' not found."), }; } @@ -65,9 +65,9 @@ private static Dictionary ToItem_PurchaseOrder(global::M { return new global::MyNamespace.PurchaseOrder { - OrderId = map.GetString("orderId", Requiredness.Optional), - Destination = map.TryGetValue("destination", out var map_destinationAttr) && map_destinationAttr.M is { } map_destination ? FromItem_ShippingAddress(map_destination) : null, - Lines = map.TryGetValue("lines", out var linesAttr) && linesAttr.L is { } linesList ? linesList.Select(av => FromItem_LineItem(av.M)).ToList() : [], + OrderId = map.GetString("orderId", Requiredness.InferFromNullability), + Destination = map.TryGetValue("destination", out var map_destinationAttr) && map_destinationAttr.M is { } map_destination ? FromItem_ShippingAddress(map_destination) : throw new System.InvalidOperationException("Required nested property 'destination' not found in DynamoDB item."), + Lines = map.TryGetValue("lines", out var linesAttr) && linesAttr.L is { } linesList ? linesList.Select(av => FromItem_LineItem(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'lines' not found."), }; } @@ -88,9 +88,9 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.ShippingAddress { - Street = map.GetString("street", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), - PostalCode = map.GetString("postalCode", Requiredness.Optional), + Street = map.GetString("street", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), + PostalCode = map.GetString("postalCode", Requiredness.InferFromNullability), }; } @@ -99,9 +99,9 @@ private static Dictionary ToItem_LineItem(global::MyName { return new global::MyNamespace.LineItem { - Sku = map.GetString("sku", Requiredness.Optional), - Qty = map.GetInt("qty", Requiredness.Optional), - Price = map.GetDecimal("price", Requiredness.Optional), + Sku = map.GetString("sku", Requiredness.InferFromNullability), + Qty = map.GetInt("qty", Requiredness.InferFromNullability), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_FourLevelDeepNesting#OrgMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_FourLevelDeepNesting#OrgMapper.g.verified.cs index 8d13d7f7..d34cd303 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_FourLevelDeepNesting#OrgMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_FourLevelDeepNesting#OrgMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrgMapper var org = new global::MyNamespace.Org { OrgId = item.GetString("orgId", Requiredness.InferFromNullability), - Division = item.TryGetValue("division", out var divisionAttr) && divisionAttr.M is { } divisionMap ? FromItem_Division(divisionMap) : null, + Division = item.TryGetValue("division", out var divisionAttr) && divisionAttr.M is { } divisionMap ? FromItem_Division(divisionMap) : throw new System.InvalidOperationException("Required attribute 'division' not found."), }; return org; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_Division(global::MyName { return new global::MyNamespace.Division { - Name = map.GetString("name", Requiredness.Optional), - Departments = map.TryGetValue("departments", out var departmentsAttr) && departmentsAttr.L is { } departmentsList ? departmentsList.Select(av => FromItem_Department(av.M)).ToList() : [], + Name = map.GetString("name", Requiredness.InferFromNullability), + Departments = map.TryGetValue("departments", out var departmentsAttr) && departmentsAttr.L is { } departmentsList ? departmentsList.Select(av => FromItem_Department(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'departments' not found."), }; } @@ -63,9 +63,9 @@ private static Dictionary ToItem_Department(global::MyNa { return new global::MyNamespace.Department { - Code = map.GetString("code", Requiredness.Optional), - HeadManager = map.TryGetValue("headManager", out var map_headmanagerAttr) && map_headmanagerAttr.M is { } map_headmanager ? FromItem_Manager(map_headmanager) : null, - Employees = map.TryGetValue("employees", out var employeesAttr) && employeesAttr.L is { } employeesList ? employeesList.Select(av => FromItem_Employee(av.M)).ToList() : [], + Code = map.GetString("code", Requiredness.InferFromNullability), + HeadManager = map.TryGetValue("headManager", out var map_headmanagerAttr) && map_headmanagerAttr.M is { } map_headmanager ? FromItem_Manager(map_headmanager) : throw new System.InvalidOperationException("Required nested property 'headManager' not found in DynamoDB item."), + Employees = map.TryGetValue("employees", out var employeesAttr) && employeesAttr.L is { } employeesList ? employeesList.Select(av => FromItem_Employee(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'employees' not found."), }; } @@ -85,8 +85,8 @@ private static Dictionary ToItem_Employee(global::MyName { return new global::MyNamespace.Manager { - FullName = map.GetString("fullName", Requiredness.Optional), - Email = map.GetString("email", Requiredness.Optional), + FullName = map.GetString("fullName", Requiredness.InferFromNullability), + Email = map.GetString("email", Requiredness.InferFromNullability), }; } @@ -95,9 +95,9 @@ private static Dictionary ToItem_Employee(global::MyName { return new global::MyNamespace.Employee { - EmployeeId = map.GetString("employeeId", Requiredness.Optional), - Name = map.GetString("name", Requiredness.Optional), - Tags = map.GetList("tags", Requiredness.Optional), + EmployeeId = map.GetString("employeeId", Requiredness.InferFromNullability), + Name = map.GetString("name", Requiredness.InferFromNullability), + Tags = map.GetList("tags", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased#OrderMapper.g.verified.cs index 0a746bfc..1193b49c 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? global::MyNamespace.AddressMapper.FromItem(shippingaddressMap) : null, + ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? global::MyNamespace.AddressMapper.FromItem(shippingaddressMap) : throw new System.InvalidOperationException("Required attribute 'shippingAddress' not found."), }; return order; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased_MissingFromMethod_FallsBackToInline#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased_MissingFromMethod_FallsBackToInline#OrderMapper.g.verified.cs index 21065231..64b03ddc 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased_MissingFromMethod_FallsBackToInline#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MapperBased_MissingFromMethod_FallsBackToInline#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : null, + ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : throw new System.InvalidOperationException("Required attribute 'shippingAddress' not found."), }; return order; } @@ -48,9 +48,9 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), - PostalCode = map.GetString("postalCode", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), + PostalCode = map.GetString("postalCode", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultiLevel#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultiLevel#OrderMapper.g.verified.cs index 9ac03ca5..6b217074 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultiLevel#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultiLevel#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Customer = item.TryGetValue("customer", out var customerAttr) && customerAttr.M is { } customerMap ? FromItem_Customer(customerMap) : null, + Customer = item.TryGetValue("customer", out var customerAttr) && customerAttr.M is { } customerMap ? FromItem_Customer(customerMap) : throw new System.InvalidOperationException("Required attribute 'customer' not found."), }; return order; } @@ -47,8 +47,8 @@ private static Dictionary ToItem_Customer(global::MyName { return new global::MyNamespace.Customer { - Name = map.GetString("name", Requiredness.Optional), - Address = map.TryGetValue("address", out var map_addressAttr) && map_addressAttr.M is { } map_address ? FromItem_Address(map_address) : null, + Name = map.GetString("name", Requiredness.InferFromNullability), + Address = map.TryGetValue("address", out var map_addressAttr) && map_addressAttr.M is { } map_address ? FromItem_Address(map_address) : throw new System.InvalidOperationException("Required nested property 'address' not found in DynamoDB item."), }; } @@ -62,8 +62,8 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultipleLevels#Level1Mapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultipleLevels#Level1Mapper.g.verified.cs index f92fb348..91ab6e32 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultipleLevels#Level1Mapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_MultipleLevels#Level1Mapper.g.verified.cs @@ -68,7 +68,7 @@ private static Dictionary ToItem_Level3(global::MyNamesp { var level3 = new global::MyNamespace.Level3 { - Value = map.GetInt("value", Requiredness.Optional), + Value = map.GetInt("value", Requiredness.InferFromNullability), Level4Data = map.TryGetValue("level4Data", out var map_level4dataAttr) && map_level4dataAttr.M is { } map_level4data ? FromItem_Level4(map_level4data) : null, }; if (map.TryGetString("id", out var var0, Requiredness.InferFromNullability)) level3.Id = var0!; @@ -86,8 +86,8 @@ private static Dictionary ToItem_Level4(global::MyNamesp { var level4 = new global::MyNamespace.Level4 { - IsActive = map.GetBool("isActive", Requiredness.Optional), - Price = map.GetDecimal("price", Requiredness.Optional), + IsActive = map.GetBool("isActive", Requiredness.InferFromNullability), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), }; if (map.TryGetString("id", out var var0, Requiredness.InferFromNullability)) level4.Id = var0!; return level4; diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline#OrderMapper.g.verified.cs index 793c36a0..59bb61c9 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline#OrderMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValues#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValues#OrderMapper.g.verified.cs index 793c36a0..59bb61c9 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValues#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValues#OrderMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValuesFalse#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValuesFalse#OrderMapper.g.verified.cs index c822c7e8..ed67e521 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValuesFalse#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_NullableInline_OmitNullValuesFalse#OrderMapper.g.verified.cs @@ -47,8 +47,8 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_OwnedTypeContainingListOfComplexObjects#UserMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_OwnedTypeContainingListOfComplexObjects#UserMapper.g.verified.cs index 165d69b5..78054006 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_OwnedTypeContainingListOfComplexObjects#UserMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_OwnedTypeContainingListOfComplexObjects#UserMapper.g.verified.cs @@ -33,7 +33,7 @@ public static partial class UserMapper { Id = item.GetString("id", Requiredness.InferFromNullability), Name = item.GetString("name", Requiredness.InferFromNullability), - CurrentOrder = item.TryGetValue("currentOrder", out var currentorderAttr) && currentorderAttr.M is { } currentorderMap ? FromItem_Order(currentorderMap) : null, + CurrentOrder = item.TryGetValue("currentOrder", out var currentorderAttr) && currentorderAttr.M is { } currentorderMap ? FromItem_Order(currentorderMap) : throw new System.InvalidOperationException("Required attribute 'currentOrder' not found."), }; return user; } @@ -50,9 +50,9 @@ private static Dictionary ToItem_Order(global::MyNamespa { return new global::MyNamespace.Order { - OrderId = map.GetString("orderId", Requiredness.Optional), - Total = map.GetDecimal("total", Requiredness.Optional), - Items = map.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_OrderItem(av.M)).ToList() : [], + OrderId = map.GetString("orderId", Requiredness.InferFromNullability), + Total = map.GetDecimal("total", Requiredness.InferFromNullability), + Items = map.TryGetValue("items", out var itemsAttr) && itemsAttr.L is { } itemsList ? itemsList.Select(av => FromItem_OrderItem(av.M)).ToList() : throw new System.InvalidOperationException("Required attribute 'items' not found."), }; } @@ -67,9 +67,9 @@ private static Dictionary ToItem_OrderItem(global::MyNam { return new global::MyNamespace.OrderItem { - ProductId = map.GetString("productId", Requiredness.Optional), - Quantity = map.GetInt("quantity", Requiredness.Optional), - UnitPrice = map.GetDecimal("unitPrice", Requiredness.Optional), + ProductId = map.GetString("productId", Requiredness.InferFromNullability), + Quantity = map.GetInt("quantity", Requiredness.InferFromNullability), + UnitPrice = map.GetDecimal("unitPrice", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_SimpleInline#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_SimpleInline#OrderMapper.g.verified.cs index 21065231..64b03ddc 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_SimpleInline#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_SimpleInline#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : null, + ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : throw new System.InvalidOperationException("Required attribute 'shippingAddress' not found."), }; return order; } @@ -48,9 +48,9 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("line1", Requiredness.Optional), - City = map.GetString("city", Requiredness.Optional), - PostalCode = map.GetString("postalCode", Requiredness.Optional), + Line1 = map.GetString("line1", Requiredness.InferFromNullability), + City = map.GetString("city", Requiredness.InferFromNullability), + PostalCode = map.GetString("postalCode", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithBinaryAndStreamScalarMembers#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithBinaryAndStreamScalarMembers#OrderMapper.g.verified.cs index 13f20922..6741f88d 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithBinaryAndStreamScalarMembers#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithBinaryAndStreamScalarMembers#OrderMapper.g.verified.cs @@ -1,4 +1,4 @@ -//HintName: OrderMapper.g.cs +//HintName: OrderMapper.g.cs //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - Payload = item.TryGetValue("payload", out var payloadAttr) && payloadAttr.M is { } payloadMap ? FromItem_Attachment(payloadMap) : null, + Payload = item.TryGetValue("payload", out var payloadAttr) && payloadAttr.M is { } payloadMap ? FromItem_Attachment(payloadMap) : throw new System.InvalidOperationException("Required attribute 'payload' not found."), }; return order; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithDotNotationOverride#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithDotNotationOverride#OrderMapper.g.verified.cs index 6fed4b32..ef37787f 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithDotNotationOverride#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithDotNotationOverride#OrderMapper.g.verified.cs @@ -31,7 +31,7 @@ public static partial class OrderMapper var order = new global::MyNamespace.Order { Id = item.GetString("id", Requiredness.InferFromNullability), - ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : null, + ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : throw new System.InvalidOperationException("Required attribute 'shippingAddress' not found."), }; return order; } @@ -48,9 +48,9 @@ private static Dictionary ToItem_Address(global::MyNames { return new global::MyNamespace.Address { - Line1 = map.GetString("addr_line1", Requiredness.Optional), - City = map.GetString("addr_city", Requiredness.Optional), - PostalCode = map.GetString("postalCode", Requiredness.Optional), + Line1 = map.GetString("addr_line1", Requiredness.InferFromNullability), + City = map.GetString("addr_city", Requiredness.InferFromNullability), + PostalCode = map.GetString("postalCode", Requiredness.InferFromNullability), }; } diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithRequiredProperties_ShouldUseCorrectRequiredness#OrderMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithRequiredProperties_ShouldUseCorrectRequiredness#OrderMapper.g.verified.cs index 1fc05327..9e0c812f 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithRequiredProperties_ShouldUseCorrectRequiredness#OrderMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithRequiredProperties_ShouldUseCorrectRequiredness#OrderMapper.g.verified.cs @@ -30,7 +30,7 @@ public static partial class OrderMapper { var order = new global::MyNamespace.Order { - ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : null, + ShippingAddress = item.TryGetValue("shippingAddress", out var shippingaddressAttr) && shippingaddressAttr.M is { } shippingaddressMap ? FromItem_Address(shippingaddressMap) : throw new System.InvalidOperationException("Required attribute 'shippingAddress' not found."), }; if (item.TryGetString("id", out var var0, Requiredness.InferFromNullability)) order.Id = var0!; return order; @@ -52,7 +52,7 @@ private static Dictionary ToItem_Address(global::MyNames { Line1 = map.GetString("line1", Requiredness.Required), City = map.GetString("city", Requiredness.Required), - PostalCode = map.GetNullableString("postalCode", Requiredness.Optional), + PostalCode = map.GetNullableString("postalCode", Requiredness.InferFromNullability), State = map.GetString("state", Requiredness.Required), }; if (map.TryGetString("country", out var var0, Requiredness.InferFromNullability)) address.Country = var0!; diff --git a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithScalarTypes#ProductMapper.g.verified.cs b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithScalarTypes#ProductMapper.g.verified.cs index 5a47c6fc..da8d9ce9 100644 --- a/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithScalarTypes#ProductMapper.g.verified.cs +++ b/test/LayeredCraft.DynamoMapper.Generators.Tests/Snapshots/NestedObjectVerifyTests.NestedObject_WithScalarTypes#ProductMapper.g.verified.cs @@ -33,7 +33,7 @@ public static partial class ProductMapper { Id = item.GetString("id", Requiredness.InferFromNullability), Name = item.GetString("name", Requiredness.InferFromNullability), - Details = item.TryGetValue("details", out var detailsAttr) && detailsAttr.M is { } detailsMap ? FromItem_ProductDetails(detailsMap) : null, + Details = item.TryGetValue("details", out var detailsAttr) && detailsAttr.M is { } detailsMap ? FromItem_ProductDetails(detailsMap) : throw new System.InvalidOperationException("Required attribute 'details' not found."), }; return product; } @@ -51,10 +51,10 @@ private static Dictionary ToItem_ProductDetails(global:: { return new global::MyNamespace.ProductDetails { - Price = map.GetDecimal("price", Requiredness.Optional), - StockCount = map.GetInt("stockCount", Requiredness.Optional), - LastUpdated = map.GetDateTime("lastUpdated", format: "O", Requiredness.Optional), - IsActive = map.GetBool("isActive", Requiredness.Optional), + Price = map.GetDecimal("price", Requiredness.InferFromNullability), + StockCount = map.GetInt("stockCount", Requiredness.InferFromNullability), + LastUpdated = map.GetDateTime("lastUpdated", format: "O", Requiredness.InferFromNullability), + IsActive = map.GetBool("isActive", Requiredness.InferFromNullability), }; }