[Pre-Pitch] Codable Customization using PropertyWrappers

I think this is an excellent start on a list of requirements for improving our ability to customize the synthesized Codable implementations. I think user-defined attributes is the right approach to improving Codable synthesis and customization. However, I don't think property wrappers is the right way to go about that.

Property wrappers are only available on properties. They are not available on types, enum cases or associated values. I wrote a large Sourcery template that synthesizes Codable implementations for my team. The encodings we have to support require the ability to annotate all of the above mentioned declarations. Property wrappers simply don't provide a general enough foundation to build a robust facility for customizing Codable synthesis.

Any facility that makes it into the language should be able to support a broad range of customized encodings. Instead of using property wrappers, we should have general user-defined attributes and contracts that allow them to participate in Codable synthesis (perhaps similar in nature to the property wrappers contract, but oriented specifically at encodings). Rust's serde uses an approach along these lines. @Chris_Lattner3 has previously described something similar for Swift.

8 Likes