Split Android and Cocoa bindings into separate projects #1983
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the
net6.0-android
,net6.0-ios
, andnet6.0-maccatalyst
targets, we currently treat the mainSentry
project as both a regular class library and as the binding library for the Android and Cocoa SDKs. While this compiles, it seems to not be the normal expectation in documentation and tooling support.To make things worse, Rider's solution analysis fails if a binding library is loaded at all. I reported that here: https://youtrack.jetbrains.com/issue/RIDER-83532. The workaround is to unload the binding libraries from the solution, or exclude them with a solution filter. We can't do that - since we don't have them broken out into their own projects.
Presently, just with the
SentryCore.slnf
solution filter, there are over 100K analysis errors by default. Most of them are in source generated automatically from the bindings. If I addsrc/Sentry/obj
to the exclusions list, then it ignores those and the number is reduced to 338 errors in the actual code. This makes it very difficult to work with code that uses the bindings, as there is virtually no Intellisense. It also makes it hard to see anything important in the solution-wide analysis - whether from Andriod/iOS or not.Example Screenshot (with
src/Sentry/obj
excluded):This PR separates the binding libraries into their own projects,
Sentry.Bindings.Android
andSentry.Bindings.Cocoa
. It adds them to the solution, but keeps them out of most of the filters. The result forSentryCore.slnf
is a clean analysis and working Intellisense on platform-specific code. No exclusion ofsrc/Sentry/obj
is necessary now.This PR also moves the native libraries to
/lib
to keep them out of the .NET projects, simplifying a few things. There are some other minor associated fixes as well.There is a tradeoff with this approach though - We'll have two new NuGet packages to publish. The
Sentry
package will take a dependency on a newSentry.Bindings.Android
package for thenet6.0-android
target, and on a newSentry.Bindings.Cocoa
package for thenet6.0-ios
andnet6.0-maccatalyst
targets.I investigated the possibility of keeping everything in the
Sentry
package. However, due to the current state of the dotnet ecosystem, this isn't possible yet.PrivateAssets="all"
on the project reference (which stops the dependency from generating in the nuspec), and compensating withTargetsForTfmSpecificBuildOutput
andTargetsForTfmSpecificContentInPackage
. However, just settingPrivateAssets="all"
breaks our builds because assets stop flowing to samples and tests projects through theProjectReference
.nuspec
file and writing your own manually. That may work for smaller projects, but is too brittle for us due to the large amount of multitargeting and other packages we have.So - we go with separate packages for the binding projects. We can use
InternalsVisibleTo
to ensure they are only used as dependencies forSentry
, and we can make sure the package descriptions and readme files direct users to consumeSentry
orSentry.Maui
.#skip-changelog