Skip to content

Commit 2c9c6d0

Browse files
authored
ref: Support Unity as a platfom (#4322)
1 parent 9521bd1 commit 2c9c6d0

File tree

4 files changed

+43
-14
lines changed

4 files changed

+43
-14
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
5+
<!-- To be able to make the internals visible, since we're not signing the assembly for Unity -->
6+
<SignAssembly>false</SignAssembly>
7+
<DefineConstants>$(DefineConstants);SENTRY_UNITY</DefineConstants>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<InternalsVisibleTo Include="Sentry.Unity" />
12+
<InternalsVisibleTo Include="Sentry.Unity.Tests" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#if SENTRY_UNITY
2+
3+
namespace Sentry;
4+
5+
/// <summary>
6+
/// Internal Sentry SDK entrypoint.
7+
/// </summary>
8+
/// <remarks>
9+
/// This class is now internal. Use <c>Sentry.Unity.SentrySdk</c> instead.
10+
/// <para>
11+
/// To migrate your code:
12+
/// <list type="number">
13+
/// <item>Change <c>using Sentry;</c> to <c>using Sentry.Unity;</c></item>
14+
/// <item>Keep using the <c>SentrySdk</c> API itself - no changes needed to method calls</item>
15+
/// <item>Add <c>using Sentry;</c> if you need access to types like <c>SentryId</c>, <c>SentryLevel</c>, etc.</item>
16+
/// </list>
17+
/// </para>
18+
/// </remarks>
19+
internal static partial class SentrySdk;
20+
21+
#endif

src/Sentry/Sentry.csproj

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,19 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
</PropertyGroup>
99

10-
<PropertyGroup Condition="'$(SolutionName)' != 'Sentry.Unity'">
10+
<PropertyGroup>
1111
<TargetFrameworks>net9.0;net8.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
1212
<TargetFrameworks Condition="'$(NO_ANDROID)' == ''">$(TargetFrameworks);net9.0-android35.0;net8.0-android34.0</TargetFrameworks>
1313
<TargetFrameworks Condition="'$(NO_IOS)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net9.0-ios18.0;net8.0-ios17.0</TargetFrameworks>
1414
<TargetFrameworks Condition="'$(NO_MACCATALYST)' == '' And $([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net9.0-maccatalyst18.0;net8.0-maccatalyst17.0</TargetFrameworks>
1515
</PropertyGroup>
16-
17-
<PropertyGroup Condition="'$(SolutionName)' == 'Sentry.Unity'">
18-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
19-
<!-- To be able to make the internals visible, since we're not signing the assembly for Unity -->
20-
<SignAssembly>false</SignAssembly>
21-
</PropertyGroup>
22-
23-
<ItemGroup Condition="'$(SolutionName)' == 'Sentry.Unity'">
24-
<InternalsVisibleTo Include="Sentry.Unity" />
25-
<InternalsVisibleTo Include="Sentry.Unity.Tests" />
26-
</ItemGroup>
27-
16+
2817
<!-- Platform-specific props included here -->
2918
<Import Project="Platforms\Android\Sentry.Android.props" Condition="'$(TargetPlatformIdentifier)' == 'android'" />
3019
<Import Project="Platforms\Cocoa\Sentry.Cocoa.props" Condition="'$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst'" />
3120
<Import Project="Platforms\Native\Sentry.Native.targets"
3221
Condition="'$(TargetPlatformIdentifier)' != 'android' and '$(TargetPlatformIdentifier)' != 'ios' and '$(TargetPlatformIdentifier)' != 'maccatalyst'"/>
22+
<Import Project="Platforms\Unity\Sentry.Unity.props" Condition="'$(SolutionName)' == 'Sentry.Unity'"/>
3323

3424
<PropertyGroup Condition="'$(EnableAot)' == 'true'">
3525
<IsAotCompatible>true</IsAotCompatible>

src/Sentry/SentrySdk.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Sentry;
88

9+
#if !SENTRY_UNITY
910
/// <summary>
1011
/// Sentry SDK entrypoint.
1112
/// </summary>
@@ -14,7 +15,9 @@ namespace Sentry;
1415
/// It allows safe static access to a client and scope management.
1516
/// When the SDK is uninitialized, calls to this class result in no-op so no callbacks are invoked.
1617
/// </remarks>
17-
public static partial class SentrySdk
18+
public
19+
#endif
20+
static partial class SentrySdk
1821
{
1922
internal static IHub CurrentHub = DisabledHub.Instance;
2023

0 commit comments

Comments
 (0)