Skip to content

Remove RouteOptions NSCopying conformance#3484

Merged
1ec5 merged 1 commit into
mainfrom
1ec5-routeoptions-nscopying-3478
Oct 15, 2021
Merged

Remove RouteOptions NSCopying conformance#3484
1ec5 merged 1 commit into
mainfrom
1ec5-routeoptions-nscopying-3478

Conversation

@1ec5
Copy link
Copy Markdown
Contributor

@1ec5 1ec5 commented Oct 14, 2021

RouteOptions no longer conforms to NSCopying via an extension in MapboxCoreNavigation. Instead, the workaround for mapbox/mapbox-directions-swift#564 that was introduced in #3192 has been isolated into an internal, throwable method that RouteOptions.without(_:) and RouteProgress.reroutingOptions(with:) use to get a copy round-tripped through JSON. If the instance of RouteOptions (or a developer-defined subclass) fails to round-trip, these methods mutate the waypoints on the original object, as a last resort, to limit the fallout in the API.

Fixes #3478.

/cc @mapbox/navigation-ios

Formalized usage of JSONEncoder and JSONDecoder to copy a RouteOptions for consistency with other clients of MapboxDirections.
@1ec5 1ec5 added op-ex Refactoring, Tech Debt or any other operational excellence work. topic: directions backwards incompatible changes that break backwards compatibility of public API labels Oct 14, 2021
@1ec5 1ec5 added this to the v2.0 milestone Oct 14, 2021
@1ec5 1ec5 requested review from S2Ler, Udumft and azarovalex October 14, 2021 15:51
@1ec5 1ec5 self-assigned this Oct 14, 2021
do {
copy = try self.copy()
} catch {
copy = self
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.

Should we add an assertion here? So that we can acknowledge the issue in tests if something is broken in this copy method.

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.

The impact is minimal and only affects incorrectly implemented subclasses of RouteOptions, so I’m inclined to omit the assertion.

@1ec5 1ec5 merged commit 17ae3cb into main Oct 15, 2021
@1ec5 1ec5 deleted the 1ec5-routeoptions-nscopying-3478 branch October 15, 2021 16:21
@1ec5 1ec5 mentioned this pull request Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards incompatible changes that break backwards compatibility of public API op-ex Refactoring, Tech Debt or any other operational excellence work. topic: directions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: RouteOptions conformance to NSCopying in extension breaks archiving with BUILD_LIBRARY_FOR_DISTRIBUTION=YES

3 participants