Skip to content

Commit 464fd4c

Browse files
Only set FrameworkSupportsAot for net8.0+ (#2889)
1 parent 9e8c58f commit 464fd4c

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

src/Directory.Build.props

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@
3535
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodeAnalysis.ruleset</CodeAnalysisRuleSet>
3636
</PropertyGroup>
3737

38-
<!-- Only compile with IsAotCompatible on .NET 6.0 and later. Our Device Tests fail for net7.0-android with this enabled as well -->
39-
<PropertyGroup Condition="'$(TargetFramework)' != 'net7.0-android' AND $([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', '^(?!net5\.|net4\d{2}|netstandard)net\d+'))">
38+
<!-- Only compile with IsAotCompatible on .NET 8.0 and later -->
39+
<PropertyGroup Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(TargetFramework)', 'net8\.|net9\.|net\d{2,}\.'))">
40+
<!-- `FrameworkSupportsAot` is a custom property we use to centralise this logic for enabling `IsAotCompatible`. As
41+
of very recently, this logic is fairly simple (net8.0 or later) but it's historically been more complex and very
42+
volatile (as we learn more about the constraints of targeting AOT compilation). We may be able to remove this custom
43+
property once we have confidence that this logic is unlikely to change again.
44+
-->
4045
<FrameworkSupportsAot>true</FrameworkSupportsAot>
4146
</PropertyGroup>
4247

src/Sentry.Extensions.Logging/Sentry.Extensions.Logging.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
55
<PackageTags>$(PackageTags);Logging;Microsoft.Extensions.Logging</PackageTags>
66
<Description>Official Microsoft.Extensions.Logging integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.</Description>
77
</PropertyGroup>
@@ -21,11 +21,16 @@
2121
</ItemGroup>
2222

2323
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
24-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
2524
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="6.0.0" />
2625
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
2726
</ItemGroup>
2827

28+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
29+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
30+
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
31+
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
32+
</ItemGroup>
33+
2934
<ItemGroup>
3035
<InternalsVisibleTo Include="Sentry.AspNetCore" PublicKey="$(SentryPublicKey)" />
3136
<InternalsVisibleTo Include="Sentry.AspNetCore.Tests" PublicKey="$(SentryPublicKey)" />

src/Sentry.Extensions.Logging/SentryLogger.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ internal SentryLogger(
2323
_hub = hub;
2424
}
2525

26+
#if NET8_0_OR_GREATER
27+
public IDisposable BeginScope<TState>(TState state) where TState : notnull
28+
=> _hub.PushScope(state);
29+
#else
2630
public IDisposable BeginScope<TState>(TState state) => _hub.PushScope(state);
31+
#endif
2732

2833
public bool IsEnabled(LogLevel logLevel)
2934
=> _hub.IsEnabled

0 commit comments

Comments
 (0)