Class ForgeMapAttribute
- Namespace
- ForgeMap
- Assembly
- ForgeMap.Abstractions.dll
Marks a partial class as a ForgeMap forger. The source generator will implement all partial methods in this class.
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class ForgeMapAttribute : Attribute
- Inheritance
-
objectAttributeForgeMapAttribute
Remarks
By default, public properties with matching names between source and destination types
are mapped automatically when they are assignable (both source and destination members
must be readable, the destination must also be writable via a setter or init accessor,
or assignable through a constructor parameter, and the member types must be compatible).
When mapping from untrusted sources (e.g., API request
DTOs, form models), use IgnoreAttribute to exclude security-sensitive destination
properties such as IsAdmin, Role, or PasswordHash from automatic mapping.
Properties
AutoWireNestedMappings
Gets or sets whether the generator should auto-discover matching forge methods for nested complex properties. Default is true.
public bool AutoWireNestedMappings { get; set; }
Property Value
- bool
ConstructorPreference
Controls constructor selection for destination types. Default is Auto.
public ConstructorPreference ConstructorPreference { get; set; }
Property Value
NullHandling
Gets or sets how null source objects should be handled. Default is ReturnNull.
public NullHandling NullHandling { get; set; }
Property Value
NullPropertyHandling
Gets or sets how nullable source properties should be assigned to non-nullable destination properties. Default is NullForgiving.
public NullPropertyHandling NullPropertyHandling { get; set; }
Property Value
PropertyMatching
Gets or sets how properties should be matched between source and destination types. Default is ByName (case-sensitive).
public PropertyMatching PropertyMatching { get; set; }
Property Value
StringToEnum
Controls automatic string-to-enum conversion behavior. Default is Parse.
public StringToEnumConversion StringToEnum { get; set; }
Property Value
SuppressDiagnostics
Gets or sets diagnostic IDs to suppress for this forger.
public string[]? SuppressDiagnostics { get; set; }
Property Value
- string[]