Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Downgrade to Swift 5.0 #128

Merged
merged 6 commits into from
Aug 18, 2020
Merged

Downgrade to Swift 5.0 #128

merged 6 commits into from
Aug 18, 2020

Conversation

slashmo
Copy link
Owner

@slashmo slashmo commented Aug 17, 2020

Adds support for Swift 5.0 & Swift 5.1 which is necessary for being integrated by other libraries that still support these versions. The CI now executes tests in parallel on 5.0.3, 5.1, and 5.2.

@slashmo slashmo added this to the Coding Period 3 milestone Aug 17, 2020
@slashmo slashmo self-assigned this Aug 17, 2020
@slashmo slashmo force-pushed the fix/swift-5-support branch 3 times, most recently from dd96d4c to 71385b4 Compare August 17, 2020 13:43
@slashmo slashmo force-pushed the fix/swift-5-support branch from 71385b4 to f82b55d Compare August 17, 2020 13:45
@slashmo slashmo marked this pull request as ready for review August 17, 2020 13:48
@slashmo slashmo requested a review from ktoso August 17, 2020 13:48
Package.swift Show resolved Hide resolved
Copy link
Collaborator

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Some comments in-line, shaping up well.

We should also document this tradeoff but perhaps we can do a big documentation day one day soon... we should write up a "pitch" and overall design info in README -- we can do that as one big task soon

Package.swift Show resolved Hide resolved
/// This is a "magic value" that is used to enable the KeyPath based accessors to specific attributes.
/// This value will never be stored or returned, and any attempt of doing so would WILL crash your application.
case __namespace
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure we should do this about the enum case; keep it in, even if we dont use it.

Also, we should see if we can remove this __namespace -- it's a bit of a hack.
Can you make a ticket for it? "See if we can remove the case __namespace in attributes"?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

I left this out on purpose because it's not being used anywhere but the 5.2 "magic". What would be the benefit of leaving it in for < 5.2?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you have a library that supports all swift versions, and they happen to switch over the attributes enum, then they'd be unable to write ONE switch implementation that works on all compiler versions without using default since they have to handle __namespace on 5.2+ and they couldn't handle it on previous versions because it's compiled out.

We should keep enums always the same across all supported compiler versions

@@ -353,7 +363,33 @@ public struct SpanAttributes: Equatable {
where Namespace: SpanAttributeNamespace {
SpanAttribute.__namespace[keyPath: dynamicMember]
}
}
#else
Copy link
Collaborator

Choose a reason for hiding this comment

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

why the entire type? can we not #if only the "offending" subscript?

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's slightly more than just the subscript. Prior to 5.2 we e.g. won't need @dynamicMemberLookup on SpanAttributes, right? Also, subscript(_ name: String) in the case of < 5.2 doesn't need to handle __namespace.

@@ -128,9 +129,11 @@ final class SpanTests: XCTestCase {
XCTAssertEqual(attributes.name, SpanAttribute.string("kappa"))
XCTAssertEqual(attributes.name, "kappa")
XCTAssertEqual(attributes.sampleHttp.statusCode, 200)
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

#else 
print some info about shy this is skipped?
#endif

Copy link
Owner Author

@slashmo slashmo Aug 18, 2020

Choose a reason for hiding this comment

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

What do you mean by "print"? Something like #warning or an actual runtime print, or simply a comment?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Added a comment for it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I meant print("oh oh") to be honest :)
In my own test suites I usually print something in yellow for such tests...

but either's fine really

Tests/TracingInstrumentationTests/SpanTests.swift Outdated Show resolved Hide resolved
UseCases/Package.swift Show resolved Hide resolved
scripts/sanity.sh Show resolved Hide resolved
@slashmo slashmo force-pushed the fix/swift-5-support branch from efd52c2 to d87b196 Compare August 18, 2020 07:07
@slashmo slashmo requested a review from ktoso August 18, 2020 07:17
@slashmo
Copy link
Owner Author

slashmo commented Aug 18, 2020

@ktoso Feel free to squash this one if accepted. Had some smaller commits fixing up unit tests / CI.

@ktoso
Copy link
Collaborator

ktoso commented Aug 18, 2020

This is LGTM once the enum __namespace is not excluded 👍

@slashmo slashmo merged commit 1986c52 into main Aug 18, 2020
@slashmo slashmo deleted the fix/swift-5-support branch August 18, 2020 14:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants