Skip to content

Create Decodable helper method#1143

Merged
timkimadobe merged 7 commits intoadobe:dev-v5.5.1from
timkimadobe:codable-helpers
Jun 12, 2025
Merged

Create Decodable helper method#1143
timkimadobe merged 7 commits intoadobe:dev-v5.5.1from
timkimadobe:codable-helpers

Conversation

@timkimadobe
Copy link
Copy Markdown
Contributor

@timkimadobe timkimadobe commented May 7, 2025

Description

This PR creates a helper method on Decodable which converts a dictionary into an instance of that Decodable type; basically the opposite of the existing Encodable method asDictionary()

Alternative considered

Creating an .aep namespaced Codable helpers which help:

  • Convert Encodable instances into [String: Any] and
  • Convert [String: Any] into Decodable instances

The motivation for the namespace was to avoid polluting the global namespace, especially when attached to very high usage protocols like Encodable and Decodable

The existing Encodable helper method asDictionary would have been marked as deprecated and the associated warning also provide a one click fix-it to migrate to the new namespaced helper:

Before:

Screenshot 2025-05-07 at 1 42 30 PM

After:

Screenshot 2025-05-07 at 1 42 37 PM

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Copy Markdown
Contributor

@cdhoffmann cdhoffmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a couple of things.

Can we update all of our uses of the asDictionary API to use the new namespace?

Also, i am not 100% sold on the naming. idk why but the all lowercase aep just feels off to me. That being said i am going to let the naming KING @sbenedicadb decide the fate of the name.

@timkimadobe timkimadobe changed the title Create namespaced Codable helpers Create Decodable Codable helper method May 29, 2025
@timkimadobe timkimadobe changed the title Create Decodable Codable helper method Create Decodable helper method May 29, 2025
@timkimadobe timkimadobe requested a review from cdhoffmann May 29, 2025 23:25
Copy link
Copy Markdown
Member

@sbenedicadb sbenedicadb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good pending the possible update for access control

/// - dateDecodingStrategy: How `Date` values should be decoded.
/// Defaults to `.deferredToDate`.
/// - Returns: A fully-decoded instance of `Self`, or `nil` if decoding fails.
static func fromDictionary(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where all do we intend to use this? only inside of core? just asking because i noticed it's not public and wondered if that was intentional or not :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timkimadobe I think this was added to be used in Live Activity code (Messaging extension)
Do you modify the access to public ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, missed this access level thank you Steve! updating now

@PravinPK PravinPK changed the base branch from dev-v5.5.0 to dev-v5.5.1 June 11, 2025 22:01
@PravinPK
Copy link
Copy Markdown
Contributor

Changed the base branch to v5.5.1

@timkimadobe timkimadobe merged commit 4c6cd44 into adobe:dev-v5.5.1 Jun 12, 2025
17 checks passed
@timkimadobe timkimadobe deleted the codable-helpers branch June 12, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants