Contents

ReportableMetadata()

Automatically generates ReportableMetadata conformance for a type.

Declaration

@attached(member, names: named(metadataDictionary)) @attached(extension, conformances: ReportableMetadata) macro ReportableMetadata()

Mentioned in

Overview

Apply @ReportableMetadata to a struct or class to enable generation of a metadataDictionary from its stored properties. Properties with supported types (String, Int, Double, Date, Bool) are included; properties with unsupported types are silently skipped. The macro generates a metadataDictionary that maps each included property name to the corresponding ReportableMetadataValue case.

Use ReportableMetadataKey(_:) to override the dictionary key for a specific property, and ReportableMetadataIgnored() to exclude a property entirely.

@ReportableMetadata
struct CheckoutMetadata {
    var cartItemCount: Int
    var promoCode: String?
    @ReportableMetadataKey("ts") var timestamp: Date
    @ReportableMetadataIgnored var internalToken: String
}

See Also

Metadata type macros