FDDB0020: EnableDynamicFields requires partial class
| Field | Value |
|---|---|
| Code | FDDB0020 |
| Severity | Error |
Message
Class '{0}' is marked with [EnableDynamicFields] but is not declared as 'partial'. The source generator needs to add a DynamicFields property to the class.
Description
Classes marked with [EnableDynamicFields] must be declared as partial to allow the source generator to add the DynamicFields property.
The [EnableDynamicFields] attribute instructs the source generator to add a DynamicFields property that captures DynamoDB attributes not explicitly mapped to entity properties. Without the partial modifier, the generator cannot add this property.
Example
The following code triggers this diagnostic:
[DynamoDbTable("nodes")]
[EnableDynamicFields]
public class TreeNode // Missing 'partial' keyword
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[SortKey]
[DynamoDbAttribute("sk")]
public string Sk { get; set; } = string.Empty;
}
Fix
The corrected version:
[DynamoDbTable("nodes")]
[EnableDynamicFields]
public partial class TreeNode
{
[PartitionKey]
[DynamoDbAttribute("pk")]
public string Pk { get; set; } = string.Empty;
[SortKey]
[DynamoDbAttribute("sk")]
public string Sk { get; set; } = string.Empty;
}