Commit Graph
4 Commits
Author SHA1 Message Date
Gil 73fcb194d8 Add conditional conformance to Hashable to Firestore property wrapper types (#6249)
* Remove the extension that makes NSDate ServerTimestampWrappable.

This turns out not to actually work because NSDate does not conform to
Codable. Users can supply their own extensions that make NSDate conform
to Codable and also supply an extension like this one to make NSDate
conform to ServerTimestampWrappable.

Add a test that verifies ServerTimestamps of Dates actually work. The
equivalent test for NSDate does not compile.

* Fix minimum Swift version for FirebaseFirestoreSwift

FirebaseFirestoreSwift was already using synthesized Equatable and
Hashable conformance which requires Swift 4.1.

* Add conditional conformance to Hashable to Firestore property wrapper types

Mark these types as conforming to Hashable if the underlying type itself
conforms to hashable. This implementation relies on synthesized
Equatable and Hashable conformance that shipped as a part of Swift 4.1.

* Fix lint/style

* Changelog
2020-08-12 10:26:57 -04:00
Gil c04334ae0a Remove the extension that makes NSDate ServerTimestampWrappable. (#6247)
This turns out not to actually work because NSDate does not conform to
Codable. Users can supply their own extensions that make NSDate conform
to Codable and also supply an extension like this one to make NSDate
conform to ServerTimestampWrappable.

Add a test that verifies ServerTimestamps of Dates actually work. The
equivalent test for NSDate does not compile.
2020-08-10 15:42:50 -07:00
Gil 53e91860e0 Rewrite SelfDocumentID as a property wrapper (#4031)
* Rewrite SelfDocumentID as a property wrapper

Make wrapped types conform to DocumentReferenceConvertible and use that
protocol to implement the conversion.

* Change DocumentReferenceConvertible to DocumentIDWrappable

* Make ServerTimestampWrappable use static functions

Use the same form as DocumentIDWrappable.

* Update extension String: ServerTimestampWrappable

* Use #if compiler, not #if swift

The FirebaseFirestoreSwift module is declared as conforming to Swift
4.0 so #if swift is still false, even when compiling with Swift 5.1.
Using #if compiler will see the actual compiler version. Property
wrappers don't depend on runtime features, so this works.

Also, allow Wrappable protocols to throw during conversions.
2019-10-15 12:59:36 -07:00
Gil 0733736c5e Rewrite ServerTimestamp as a property wrapper (#4003)
* Move ServerTimestamp into its own file

* Rewrite ServerTimestamp as a property wrapper

Add Swift4ServerTimestamp that behaves as before.

* Make ServerTimestampWrappable dictate timestamp conversion.

This makes the @ServerTimestamp property wrapper completely open to
extension by end users too.
2019-10-08 10:11:28 -07:00