Skip to content

Commit 0514bfe

Browse files
aritchiegetsentry-botjamescrosswellbruno-garcia
authored
Build Variables Source Generator (#4101)
* Initial commit * Update CHANGELOG.md * Updates path refs * Format code * Package analyzer with sentry nuget * add tests - having tooling issues lighting this up - trying in CI * Format code * Updates * Format code * code review fix * Update Sentry.SourceGenerators.csproj * Update for unit tests * Fixes and name alignments * Fix bad bot changes * Add disable sentry changes per code review as well as unit tests for it * Try to revert bad bot * Format code * Done * Update CHANGELOG.md Co-authored-by: Bruno Garcia <bruno@brunogarcia.com> * Update SentrySdk.cs * Update slnf as stated in CI :| * update verify tests * Finally forced these to update * Ensure source generator isn't included as reference * Moving to its own project * Update slnf * Update solution filters * Fixes - Skip tests on windows for now * Update generate-solution-filters-config.yaml * Update AotHelper.cs --------- Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io> Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com> Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
1 parent 70466b1 commit 0514bfe

32 files changed

+1542
-10
lines changed

.generated.NoMobile.sln

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Hangfire", "src\Sent
170170
EndProject
171171
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Hangfire.Tests", "test\Sentry.Hangfire.Tests\Sentry.Hangfire.Tests.csproj", "{46E40BE8-1AB0-4846-B0A2-A40AD0272C64}"
172172
EndProject
173-
Project("{00000000-0000-0000-0000-000000000000}") = "Sentry.Samples.AspNetCore.WebAPI.Profiling", "samples\Sentry.Samples.AspNetCore.WebAPI.Profiling\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj", "{A5B26C14-7313-4EDC-91E3-287F9374AB75}"
173+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Samples.AspNetCore.WebAPI.Profiling", "samples\Sentry.Samples.AspNetCore.WebAPI.Profiling\Sentry.Samples.AspNetCore.WebAPI.Profiling.csproj", "{A5B26C14-7313-4EDC-91E3-287F9374AB75}"
174174
EndProject
175175
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{233D34AB-970E-4913-AA1E-172E833FB5B2}"
176176
ProjectSection(SolutionItems) = preProject
@@ -197,6 +197,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.TrimTest", "test\Sen
197197
EndProject
198198
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.MauiTrimTest", "test\Sentry.MauiTrimTest\Sentry.MauiTrimTest.csproj", "{DF92E098-822C-4B94-B96B-56BFB91FBB54}"
199199
EndProject
200+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.SourceGenerators", "src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj", "{C3CDF61C-3E28-441C-A9CE-011C89D11719}"
201+
EndProject
202+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.SourceGenerators.Tests", "test\Sentry.SourceGenerators.Tests\Sentry.SourceGenerators.Tests.csproj", "{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}"
203+
EndProject
200204
Global
201205
GlobalSection(SolutionConfigurationPlatforms) = preSolution
202206
Debug|Any CPU = Debug|Any CPU
@@ -532,6 +536,14 @@ Global
532536
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.Build.0 = Debug|Any CPU
533537
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.ActiveCfg = Release|Any CPU
534538
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.Build.0 = Release|Any CPU
539+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
540+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Debug|Any CPU.Build.0 = Debug|Any CPU
541+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Release|Any CPU.ActiveCfg = Release|Any CPU
542+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Release|Any CPU.Build.0 = Release|Any CPU
543+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
544+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Debug|Any CPU.Build.0 = Debug|Any CPU
545+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Release|Any CPU.ActiveCfg = Release|Any CPU
546+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Release|Any CPU.Build.0 = Release|Any CPU
535547
EndGlobalSection
536548
GlobalSection(SolutionProperties) = preSolution
537549
HideSolutionNode = FALSE
@@ -619,5 +631,7 @@ Global
619631
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821} = {21B42F60-5802-404E-90F0-AEBCC56760C0}
620632
{6030B748-0000-43B5-B8A8-399AA42F5229} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
621633
{DF92E098-822C-4B94-B96B-56BFB91FBB54} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
634+
{C3CDF61C-3E28-441C-A9CE-011C89D11719} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
635+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
622636
EndGlobalSection
623637
EndGlobal

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## Unreleased
44

5+
### Features
6+
7+
- New source generator allows Sentry to see true build variables like PublishAot and PublishTrimmed to properly adapt checks in the Sentry SDK ([#4101](https://github.com/getsentry/sentry-dotnet/pull/4101))
58
### Dependencies
69

710
- Bump CLI from v2.43.1 to v2.44.0 ([#4169](https://github.com/getsentry/sentry-dotnet/pull/4169))

Sentry-CI-Build-Linux.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
5050
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
5151
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
52+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
5253
"src\\Sentry\\Sentry.csproj",
5354
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
5455
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
@@ -69,6 +70,7 @@
6970
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
7071
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
7172
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
73+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
7274
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
7375
"test\\Sentry.Testing\\Sentry.Testing.csproj",
7476
"test\\Sentry.Tests\\Sentry.Tests.csproj",

Sentry-CI-Build-Windows.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
5252
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
5353
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
54+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
5455
"src\\Sentry\\Sentry.csproj",
5556
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
5657
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
@@ -71,6 +72,7 @@
7172
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
7273
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
7374
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
75+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
7476
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
7577
"test\\Sentry.Testing\\Sentry.Testing.csproj",
7678
"test\\Sentry.Tests\\Sentry.Tests.csproj",

Sentry-CI-Build-macOS.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
5757
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
5858
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
59+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
5960
"src\\Sentry\\Sentry.csproj",
6061
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
6162
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
@@ -77,6 +78,7 @@
7778
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
7879
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
7980
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
81+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
8082
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
8183
"test\\Sentry.Testing\\Sentry.Testing.csproj",
8284
"test\\Sentry.Tests\\Sentry.Tests.csproj",

Sentry-CI-CodeQL.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
2121
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
2222
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
23+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
2324
"src\\Sentry\\Sentry.csproj"
2425
]
2526
}

Sentry.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.TrimTest", "test\Sen
197197
EndProject
198198
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.MauiTrimTest", "test\Sentry.MauiTrimTest\Sentry.MauiTrimTest.csproj", "{DF92E098-822C-4B94-B96B-56BFB91FBB54}"
199199
EndProject
200+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.SourceGenerators", "src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj", "{C3CDF61C-3E28-441C-A9CE-011C89D11719}"
201+
EndProject
202+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.SourceGenerators.Tests", "test\Sentry.SourceGenerators.Tests\Sentry.SourceGenerators.Tests.csproj", "{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}"
203+
EndProject
200204
Global
201205
GlobalSection(SolutionConfigurationPlatforms) = preSolution
202206
Debug|Any CPU = Debug|Any CPU
@@ -532,6 +536,14 @@ Global
532536
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Debug|Any CPU.Build.0 = Debug|Any CPU
533537
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.ActiveCfg = Release|Any CPU
534538
{DF92E098-822C-4B94-B96B-56BFB91FBB54}.Release|Any CPU.Build.0 = Release|Any CPU
539+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
540+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Debug|Any CPU.Build.0 = Debug|Any CPU
541+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Release|Any CPU.ActiveCfg = Release|Any CPU
542+
{C3CDF61C-3E28-441C-A9CE-011C89D11719}.Release|Any CPU.Build.0 = Release|Any CPU
543+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
544+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Debug|Any CPU.Build.0 = Debug|Any CPU
545+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Release|Any CPU.ActiveCfg = Release|Any CPU
546+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893}.Release|Any CPU.Build.0 = Release|Any CPU
535547
EndGlobalSection
536548
GlobalSection(SolutionProperties) = preSolution
537549
HideSolutionNode = FALSE
@@ -619,5 +631,7 @@ Global
619631
{D7DF0B26-AD43-4F8B-9BFE-C4471CCC9821} = {21B42F60-5802-404E-90F0-AEBCC56760C0}
620632
{6030B748-0000-43B5-B8A8-399AA42F5229} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
621633
{DF92E098-822C-4B94-B96B-56BFB91FBB54} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
634+
{C3CDF61C-3E28-441C-A9CE-011C89D11719} = {230B9384-90FD-4551-A5DE-1A5C197F25B6}
635+
{3A76FF7D-2F32-4EA5-8999-2FFE3C7CB893} = {6987A1CC-608E-4868-A02C-09D30C8B7B2D}
622636
EndGlobalSection
623637
EndGlobal

SentryNoMobile.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
4848
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
4949
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
50+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
5051
"src\\Sentry\\Sentry.csproj",
5152
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
5253
"test\\Sentry.AspNet.Tests\\Sentry.AspNet.Tests.csproj",
@@ -65,6 +66,7 @@
6566
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
6667
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
6768
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
69+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
6870
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
6971
"test\\Sentry.Testing\\Sentry.Testing.csproj",
7072
"test\\Sentry.Tests\\Sentry.Tests.csproj",

SentryNoSamples.slnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"src\\Sentry.OpenTelemetry\\Sentry.OpenTelemetry.csproj",
2222
"src\\Sentry.Profiling\\Sentry.Profiling.csproj",
2323
"src\\Sentry.Serilog\\Sentry.Serilog.csproj",
24+
"src\\Sentry.SourceGenerators\\Sentry.SourceGenerators.csproj",
2425
"src\\Sentry\\Sentry.csproj",
2526
"test\\Sentry.Analyzers.Tests\\Sentry.Analyzers.Tests.csproj",
2627
"test\\Sentry.Android.AssemblyReader.Tests\\Sentry.Android.AssemblyReader.Tests.csproj",
@@ -41,6 +42,7 @@
4142
"test\\Sentry.OpenTelemetry.Tests\\Sentry.OpenTelemetry.Tests.csproj",
4243
"test\\Sentry.Profiling.Tests\\Sentry.Profiling.Tests.csproj",
4344
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
45+
"test\\Sentry.SourceGenerators.Tests\\Sentry.SourceGenerators.Tests.csproj",
4446
"test\\Sentry.Testing.CrashableApp\\Sentry.Testing.CrashableApp.csproj",
4547
"test\\Sentry.Testing\\Sentry.Testing.csproj",
4648
"test\\Sentry.Tests\\Sentry.Tests.csproj"

samples/Sentry.Samples.Android/Sentry.Samples.Android.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15+
<ProjectReference Include="..\..\src\Sentry.SourceGenerators\Sentry.SourceGenerators.csproj"
16+
OutputItemType="Analyzer"
17+
ReferenceOutputAssembly="false"/>
1518
<ProjectReference Include="..\..\src\Sentry\Sentry.csproj" />
1619
<Using Include="Android.App.Activity" Alias="Activity" />
1720

@@ -40,4 +43,6 @@
4043
<AndroidLinkMode>full</AndroidLinkMode>
4144
</PropertyGroup>
4245

46+
<!--In order to test our analyzers with this project, we manually reference our targets file. User do not need to do this-->
47+
<Import Project="..\..\src\Sentry\buildTransitive\Sentry.SourceGenerators.targets" />
4348
</Project>

0 commit comments

Comments
 (0)