-
Notifications
You must be signed in to change notification settings - Fork 459
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
Conform to CustomDebugStringConvertible for Debug only #1246
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll note here that this change can only be made in a major release, so we can only merge this into the proposed 2.0 release.
My first thought (and haven't really thought about this) - Is it better to only have the conformance in |
The documentation of
which makes me believe that it should not be a problem, and in cases where engineers do rely on As for having conformance for both configurations, but with different implementations, I suspect it not to change much, if anything. |
Whether engineers should obey the rules above is largely immaterial IMO: this breaks the API. Code that used to work would update to this version and break, and while we can say that the engineers who did that work were holding We can choose to accept the breakage if we want to, but it would be better if we did this as part of a 2.0 release where that kind of breakage is expected. |
Now would be the time, since our next release off main is going to be 2.0 since decided to do some of the breaks now. |
@Lukasa To be clear, I do agree that this, in its current form, is an API breaking change and should be treated as such. I didn't mean to suggest otherwise. |
@bubski Fantastic. I think this approach is entirely fine by me, though it might be nice to be able to allow users to override this behaviour if they so choose by replacing the definition with |
I think we should take this for 2.0. |
Agree. |
No concerns here. |
Looks like the sanitizer configs are the only things that catch building the tests in release. There's a bunch of tests that will need some work to deal with building in both debug and release. |
@thomasvl RE: tests that access |
Yeah, disabling the |
let actual = m.debugDescription | ||
XCTAssertEqual(actual, expected, fmt ?? "debugDescription did not match", file: file, line: line) | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an assertDebugDescription()
variant where you can pass in an existing SwiftProtobuf.Message
. Both of the functions no-op for non-debug builds.
Bleargh. Bug in the upstream conformance test.
|
upstream conformance test finally fixed, I re-triggered CI. |
@tbkka Is there going to be an alpha branch for 2.0? Or is |
Personally, I don't think we'll have another 1.0 release unless there is some issue that comes up. But that's ultimately up to the Apple folks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! I've not been able to review the actual implementation as closely as I'd like, but the idea is good and I'm happy taking this for 2.0.
@Lukasa this ok to merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I'm happy with it. Nice patch!
Ok, merging… Thanks for the patch! |
👋 Sorry I am a bit confused: seems like this change never made it to the public right? As the latest releases are version 1.X, but this change is marked as v2.0? By looking at the commit, looks to be only present in |
Correct, it wasn't put on the 1.x branch as it could be considered a breaking change since it changes behaviors in a Release build, so the major change seemed safer. |
Thanks! In case I would like to build SwiftProtobuf with any similar breaking changes done in the past 2 years, is there a recommended way? Could you confirm: since there hasn't been any 2.X release yet, looks like the only option would be to build from master? |
Yes, As far as how to build off |
Resolves #1245
This boxes all references to
CustomDebugStringConvertible
anddebugDescription
in#if
checks to exclude them from the release binary. The existence of this conformance and default implementation on theMessage
protocol (and some other types) adds up quite considerably. Across our large iOS app, we can attribute 6.7 MB of the uncompressed binary size to generated swift protos. This change cuts that back by 780 KB (11.6%). Other efforts like #1240 will probably also help trim this back even further.I tried to do this with as little diff as possible. Added some inline comments on some things I'm unsure about.
Special thanks to @bubski for the idea.