-
-
Notifications
You must be signed in to change notification settings - Fork 226
build: Generate Swift types from Sentry-Swift.h #4488
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
Conversation
1a6e0f0 to
eba48ba
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## version6 #4488 +/- ##
===========================================
Coverage ? 73.17%
===========================================
Files ? 480
Lines ? 17421
Branches ? 3437
===========================================
Hits ? 12748
Misses ? 3822
Partials ? 851 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
46b4261 to
7870f84
Compare
0df2de9 to
f05a3aa
Compare
|
@jamescrosswell @Flash0ver There haven't been any Swift binding updates that required manual intervention recently, so I forgot I had this PR lying here. This can generate C# bindings for Swift types, so we'd no longer need those error-prone, manually crafted bindings in |
f05a3aa to
28efafc
Compare
It looks like it's easier to surgically remove the stuff that's problematic with the Roslyn code. I guess we're placing a bet that there will be less work required to maintain the whitelist/blacklist here than the manual bindings. There's no way to be sure of that in advance really - just have to give it a crack. I think it's worth trying 👍🏻 |
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 - our first c# script!
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.
😏
|
The auto-generated $interfacesToKeep = @(...)
$pattern = $interfacesToKeep.Count -gt 0 ? ($interfacesToKeep -join '|') : '(?!)'
$content = $content -replace "(?ms)^(?:[ \t]*SWIFT_AVAILABILITY\([^)]+\)[^\r\n]*\r?\n)*[ \t]*@interface\s+(?!($pattern)\b)[A-Za-z_][A-Za-z0-9_]*(?:\s*\([^)]+\))?(?:\s*<[^>]*>)?[\s\S]*?\r?\n@end", ''
$protocolsToKeep = @(...)
$pattern = $protocolsToKeep.Count -gt 0 ? ($protocolsToKeep -join '|') : '(?!)'
$content = $content -replace "(?ms)^(?!#\s*define\s+SWIFT_PROTOCOL(_NAMED)?)[ \t]*SWIFT_PROTOCOL(_NAMED)?\([^)]+\)[^\r\n]*?(?:\s+SWIFT_AVAILABILITY\([^)]+\))*\s*\r?\n@protocol\s+(?!($pattern)\b)[A-Za-z_][A-Za-z0-9_]*\s*(?:<[^>]*>)?[\s\S]*?\r?\n@end", ''That's one of my earlier attempts that I failed to make work correctly, as it swallowed some unrelated types. 😅 I thought there must be an easier way to filter types by name, which is how I ended up giving Roslyn a try... P.S. I have also successfully used this together with sentry-cocoa#6193 after rebasing it on the latest main (v9) branch that has quite a few API changes compared to v8. |
jamescrosswell
left a comment
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.
Awesome... just tested it out on #4664 and I think easier than hand coded bindings 👍🏻
Sentry-Swift.h(Obj-C header auto-generated by the Swift compiler)StructsAndEnums.csandApiDefinitions.cs(because doing the same with regexps in PWSH is extremely difficult to get right)#skip-changelog