Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
516 changes: 516 additions & 0 deletions docs/tech-debt-analysis.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/DynamoMapper.FieldLevelOverride/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώusing System.Collections.Generic;
using System.Collections.Generic;
using Amazon.DynamoDBv2.Model;
using DynamoMapper.Runtime;

Expand Down
2 changes: 1 addition & 1 deletion examples/DynamoMapper.MapperConstructor/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ// See https://aka.ms/new-console-template for more information
// See https://aka.ms/new-console-template for more information

using System;

Expand Down
14 changes: 7 additions & 7 deletions examples/DynamoMapper.Nested/MapperBasedNested.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ namespace DynamoMapper.Nested;
/// </summary>
public record BlogPost
{
public string Slug { get; set; }
public string Title { get; set; }
public Author Writer { get; set; }
public required string Slug { get; set; }
public required string Title { get; set; }
public required Author Writer { get; set; }
}

public record Author
{
public string Handle { get; set; }
public string DisplayName { get; set; }
public string Bio { get; set; }
public required string Handle { get; set; }
public required string DisplayName { get; set; }
public required string Bio { get; set; }
}

// Author has its own mapper - BlogPostMapper will use this
Expand All @@ -35,4 +35,4 @@ public static partial class BlogPostMapper
public static partial Dictionary<string, AttributeValue> ToItem(BlogPost source);

public static partial BlogPost FromItem(Dictionary<string, AttributeValue> item);
}
}
18 changes: 9 additions & 9 deletions examples/DynamoMapper.Nested/MultiLevelNested.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ namespace DynamoMapper.Nested;
/// </summary>
public record Company
{
public string Id { get; set; }
public string Name { get; set; }
public Department HeadOffice { get; set; }
public required string Id { get; set; }
public required string Name { get; set; }
public required Department HeadOffice { get; set; }
}

public record Department
{
public string Code { get; set; }
public string Name { get; set; }
public Manager Lead { get; set; }
public required string Code { get; set; }
public required string Name { get; set; }
public required Manager Lead { get; set; }
}

public record Manager
{
public string EmployeeId { get; set; }
public string FullName { get; set; }
public required string EmployeeId { get; set; }
public required string FullName { get; set; }
}

[DynamoMapper]
Expand All @@ -32,4 +32,4 @@ public static partial class CompanyMapper
public static partial Dictionary<string, AttributeValue> ToItem(Company source);

public static partial Company FromItem(Dictionary<string, AttributeValue> item);
}
}
12 changes: 6 additions & 6 deletions examples/DynamoMapper.Nested/NestedCollectionDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace DynamoMapper.Nested;
/// </summary>
public record EmployeeDirectory
{
public string DepartmentId { get; set; }
public string DepartmentName { get; set; }
public Dictionary<string, Employee> Employees { get; set; }
public required string DepartmentId { get; set; }
public required string DepartmentName { get; set; }
public required Dictionary<string, Employee> Employees { get; set; }
}

public record Employee
{
public string Name { get; set; }
public string Title { get; set; }
public required string Name { get; set; }
public required string Title { get; set; }
public decimal Salary { get; set; }
}

Expand All @@ -26,4 +26,4 @@ public static partial class EmployeeDirectoryMapper
public static partial Dictionary<string, AttributeValue> ToItem(EmployeeDirectory source);

public static partial EmployeeDirectory FromItem(Dictionary<string, AttributeValue> item);
}
}
10 changes: 5 additions & 5 deletions examples/DynamoMapper.Nested/NestedCollectionList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace DynamoMapper.Nested;
/// </summary>
public record ShoppingCart
{
public string CartId { get; set; }
public List<CartItem> Items { get; set; }
public required string CartId { get; set; }
public required List<CartItem> Items { get; set; }
}

public record CartItem
{
public string ProductId { get; set; }
public string ProductName { get; set; }
public required string ProductId { get; set; }
public required string ProductName { get; set; }
public int Quantity { get; set; }
public decimal UnitPrice { get; set; }
}
Expand All @@ -26,4 +26,4 @@ public static partial class ShoppingCartMapper
public static partial Dictionary<string, AttributeValue> ToItem(ShoppingCart source);

public static partial ShoppingCart FromItem(Dictionary<string, AttributeValue> item);
}
}
6 changes: 3 additions & 3 deletions examples/DynamoMapper.Nested/NestedWithScalars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace DynamoMapper.Nested;
/// </summary>
public record Invoice
{
public string InvoiceNumber { get; set; }
public PaymentInfo Payment { get; set; }
public required string InvoiceNumber { get; set; }
public required PaymentInfo Payment { get; set; }
}

public record PaymentInfo
Expand All @@ -26,4 +26,4 @@ public static partial class InvoiceMapper
public static partial Dictionary<string, AttributeValue> ToItem(Invoice source);

public static partial Invoice FromItem(Dictionary<string, AttributeValue> item);
}
}
8 changes: 4 additions & 4 deletions examples/DynamoMapper.Nested/NullableNested.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ namespace DynamoMapper.Nested;
/// </summary>
public record Product
{
public string Sku { get; set; }
public string Name { get; set; }
public required string Sku { get; set; }
public required string Name { get; set; }
public Warranty? Warranty { get; set; } // Nullable nested object
}

public record Warranty
{
public int DurationMonths { get; set; }
public string Provider { get; set; }
public required string Provider { get; set; }
}

[DynamoMapper]
Expand All @@ -25,4 +25,4 @@ public static partial class ProductMapper
public static partial Dictionary<string, AttributeValue> ToItem(Product source);

public static partial Product FromItem(Dictionary<string, AttributeValue> item);
}
}
10 changes: 5 additions & 5 deletions examples/DynamoMapper.Nested/Order.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ namespace DynamoMapper.Nested;

public record Order
{
public string Id { get; set; }
public Address ShippingAddress { get; set; }
public required string Id { get; set; }
public required Address ShippingAddress { get; set; }
}

public record Address
{
public string Line1 { get; set; }
public string City { get; set; }
public string PostalCode { get; set; }
public required string Line1 { get; set; }
public required string City { get; set; }
public required string PostalCode { get; set; }
}

[DynamoMapper]
Expand Down
8 changes: 6 additions & 2 deletions examples/DynamoMapper.Nested/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
var productWithoutWarranty =
new Product
{
Sku = "CABLE-001", Name = "USB Cable", Warranty = null, // No warranty
Sku = "CABLE-001",
Name = "USB Cable",
Warranty = null, // No warranty
};

Console.WriteLine($"Product with warranty: {productWithWarranty}");
Expand Down Expand Up @@ -208,7 +210,9 @@
["emp002"] =
new Employee
{
Name = "Bob Smith", Title = "Junior Engineer", Salary = 75000m,
Name = "Bob Smith",
Title = "Junior Engineer",
Salary = 75000m,
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ GeneratorContext context
if (!hasParameterlessConstructor)
{
// NO parameterless constructor β†’ MUST use a non-parameterless constructor
var selectedConstructor = SelectConstructorWithMostParameters(constructors);
return AnalyzeConstructorSelection(selectedConstructor, properties, false, context);
return AnalyzeConstructorSelection(
SelectConstructorWithMostParameters(constructors),
properties,
false,
context
);
}

// PRIORITY 3: Parameterless constructor exists - check deserialization accessibility
Expand All @@ -73,8 +77,12 @@ GeneratorContext context
}

// PRIORITY 4: Has read-only properties - use constructor with most parameters
var selectedConstructor2 = SelectConstructorWithMostParameters(constructors);
return AnalyzeConstructorSelection(selectedConstructor2, properties, false, context);
return AnalyzeConstructorSelection(
SelectConstructorWithMostParameters(constructors),
properties,
false,
context
);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ WellKnownTypes.WellKnownTypes wellKnownTypes
namedType.TypeArguments[1],
WellKnownType.Amazon_DynamoDBv2_Model_AttributeValue
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ internal sealed record MapperReference(
string MapperFullyQualifiedName,
bool HasToItemMethod,
bool HasFromItemMethod
);
);
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ internal bool HasMapper(ITypeSymbol modelTypeSymbol)
);
return ModelToMapper.ContainsKey(fullyQualifiedName);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ internal static PropertyNullabilityInfo AnalyzeNullability(ITypeSymbol type)
var isNullableType =
type
is INamedTypeSymbol
{
OriginalDefinition.SpecialType: SpecialType.System_Nullable_T,
}
{
OriginalDefinition.SpecialType: SpecialType.System_Nullable_T,
}
|| (isReferenceType && annotation == NullableAnnotation.Annotated);

return new PropertyNullabilityInfo(isNullableType, isReferenceType, annotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ internal enum CollectionCategory
/// Set-like collections (HashSet&lt;T&gt;, ISet&lt;T&gt;) β†’ DynamoKind.SS/NS/BS based on element type
/// </summary>
Set
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ internal sealed record NestedPropertySpec(
string DynamoKey,
TypeMappingStrategy? Strategy,
NestedMappingInfo? NestedMapping = null
);
);
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ internal bool HasOverridesForCurrentPath()
/// <returns>A new nested analysis context.</returns>
internal static NestedAnalysisContext Create(GeneratorContext context, MapperRegistry registry) =>
new(context, registry, ImmutableHashSet<string>.Empty);
}
}
Loading
Loading