-
-
Notifications
You must be signed in to change notification settings - Fork 221
chore: Fix reference to Sentry.SourceGenerators #4290
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7329400
chore: Fix reference to Sentry.SourceGenerators
jamescrosswell 4f152c7
fix: build and pack Sentry Generators without dependency
Flash0ver ac399b3
Merge branch 'main' into fix-source-gen-ref
Flash0ver b3ca680
build: replace TfmSpecificPackageFile with custom Target
Flash0ver ee425d8
build: remve GenerateNuspec from BeforeTargets
Flash0ver File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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 have a feeling that this won't work as expected.
I don't think we are packing
Sentry.SourceGenerators.dll
to the expected PackagePath.Unfortunately, the NuGetPackageExplorer is Windows-only.
So I can't test it right away.
We need either
$(OutputPath)
-based path rather than hard-coding itTfmSpecificPackageFile
-item in a target instead, becauseSentry
is multi-targeted, but Roslyn-Compiler-Extensions should benetstandard2.0
Also
OutputItemType="Analyzer"
seems wrong in this context as we don't want to consume the Generator inSentry
, but pack it in the same package alongside the Sentrylib/
.Let me get back to that when I'm on a Windows machine.
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 think you're right... this would work if we only wanted to use the analyzer when building the SentrySDK:
But we want to package it and have it run when building projects that are using the Sentry SDK.
When I built a source generator myself, I simply put this in the csproj file for the analyzer itself:
https://github.com/mentaldesk/ducktype/blob/d06ab90bc698a30e33911b19901eb6833891eed9/MentalDesk.DuckType/MentalDesk.DuckType.csproj#L48-L52
Then other projects that wanted to use that source generator added a PackageReference to the analyzer.
If we published
Sentry.SourcfeGenerators
as a NuGet, would it be enough to add a package reference fromSentry
toSentry.SourceGenerators
? Would that then ensure that anyone who added Sentry also got Sentry.SourceGenerators?Uh oh!
There was an error while loading. Please reload this page.
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.
Yes ... this should work ... this is what
xunit
does.But ... I don't think we necessarily want this: Our SourceGen emits code that is depending on
Sentry
. The SourceGen does not make sense withoutSentry
. And also, I think it may be "dangerous" - to some degree" - to use different versions of the SourceGen-Package and theSentry
package.I prefer to have the SourceGen within the
Sentry
package, similar toMicrosoft.Extensions.Logging.Abstractions
.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.
change:
ProjectReference
to reliably build the project as a dependency in the correct orderReferenceOutputAssembly
to include in$(OutputPath)
PrivateAssets="all"
so thatSentry
does not have a dependency onSentry.SourceGenerators
TargetsForTfmSpecificContentInPackage
Target
that packsSentry.SourceGenerators
in the expectedPackagePath
forAnalyzer
PackagePath="analyzers/dotnet/cs"
dotnet pack
(Release) and check via NuGet Package Explorer on Windows:Uh oh!
There was an error while loading. Please reload this page.
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.
Build fails on CI though ... need to reiterate 🤔
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.
From failing on all Platforms now only failing on macOS ... I'm getting there 😉