Skip to content

Commit d33ddb8

Browse files
committed
Flip and simplify the logic
1 parent 8ce6f25 commit d33ddb8

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

src/Sentry/Platforms/Native/SentryNative.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class SentryNative
1717
// This way, `SentryNative.IsEnabled` should be treated as a compile-time constant for trimmed apps.
1818
[FeatureSwitchDefinition(SentryNativeIsEnabledSwitchName)]
1919
#endif
20-
private static bool IsEnabled => !AppContext.TryGetSwitch(SentryNativeIsEnabledSwitchName, out var isEnabled) || isEnabled;
20+
private static bool IsEnabled => AppContext.TryGetSwitch(SentryNativeIsEnabledSwitchName, out var isEnabled) && isEnabled;
2121

2222
internal static bool IsAvailable => IsEnabled && IsAvailableCore;
2323

src/Sentry/Platforms/Native/buildTransitive/Sentry.Native.targets

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<!-- SentryNative.IsEnabled should result in compile-time constant for trimmed applications -->
1414
<!-- Effectively disabling native library -->
1515
<RuntimeHostConfigurationOption Include="Sentry.Native.IsEnabled"
16-
Value="$(_SentryNativeEnabled)"
16+
Condition="'$(FrameworkSupportsNative)' == 'true'"
1717
Trim="true" />
1818
</ItemGroup>
1919

@@ -25,32 +25,18 @@
2525
</PropertyGroup>
2626

2727
<PropertyGroup>
28+
<!-- Windows -->
29+
<FrameworkSupportsNative Condition="'$(RuntimeIdentifier)' == 'win-x64' or '$(RuntimeIdentifier)' == 'win-arm64'">true</FrameworkSupportsNative>
30+
<!-- Linux -->
31+
<FrameworkSupportsNative Condition="'$(RuntimeIdentifier)' == 'linux-x64' or '$(RuntimeIdentifier)' == 'linux-arm64' or '$(RuntimeIdentifier)' == 'linux-musl-x64'">true</FrameworkSupportsNative>
32+
<!-- macOS -->
33+
<FrameworkSupportsNative Condition="'$(RuntimeIdentifier)' == 'osx-x64' or '$(RuntimeIdentifier)' == 'osx-arm64'">true</FrameworkSupportsNative>
2834
<!-- net8.0 or greater -->
2935
<FrameworkSupportsNative Condition="'$(_SentryIsNet8OrGreater)' == 'true' and ('$(OutputType)' == 'Exe' or '$(OutputType)' == 'WinExe')">true</FrameworkSupportsNative>
3036
<!-- Make it opt-out -->
3137
<FrameworkSupportsNative Condition="'$(SentryNative)' == 'false' or '$(SentryNative)' == 'disable'">false</FrameworkSupportsNative>
3238
</PropertyGroup>
3339

34-
<!-- Whitelist supported runtimes -->
35-
<Choose>
36-
<When Condition="'$(FrameworkSupportsNative)' == 'true'">
37-
<PropertyGroup>
38-
<_SentryNativeEnabled>false</_SentryNativeEnabled>
39-
<!-- Windows -->
40-
<_SentryNativeEnabled Condition="'$(RuntimeIdentifier)' == 'win-x64' or '$(RuntimeIdentifier)' == 'win-arm64'">true</_SentryNativeEnabled>
41-
<!-- Linux -->
42-
<_SentryNativeEnabled Condition="'$(RuntimeIdentifier)' == 'linux-x64' or '$(RuntimeIdentifier)' == 'linux-arm64' or '$(RuntimeIdentifier)' == 'linux-musl-x64'">true</_SentryNativeEnabled>
43-
<!-- macOS -->
44-
<_SentryNativeEnabled Condition="'$(RuntimeIdentifier)' == 'osx-x64' or '$(RuntimeIdentifier)' == 'osx-arm64'">true</_SentryNativeEnabled>
45-
</PropertyGroup>
46-
</When>
47-
<Otherwise>
48-
<PropertyGroup>
49-
<_SentryNativeEnabled>false</_SentryNativeEnabled>
50-
</PropertyGroup>
51-
</Otherwise>
52-
</Choose>
53-
5440
<ItemGroup Condition="'$(FrameworkSupportsNative)' == 'true' and ('$(RuntimeIdentifier)' == 'win-x64' or '$(RuntimeIdentifier)' == 'win-arm64')">
5541
<DirectPInvoke Include="sentry-native" />
5642
<NativeLibrary Include="$(MSBuildThisFileDirectory)..\sentry-native\$(RuntimeIdentifier)\sentry-native.lib" />

0 commit comments

Comments
 (0)