Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove RouteOptions NSCopying conformance #3484

Merged
merged 1 commit into from
Oct 15, 2021

Conversation

1ec5
Copy link
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, azarovalex and Udumft October 14, 2021 15:51
@1ec5 1ec5 self-assigned this Oct 14, 2021
do {
copy = try self.copy()
} catch {
copy = self
Copy link
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
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
3 participants