Skip to content

Commit df30f77

Browse files
Remove Library Signing from Sentry.Hangfire (#4099)
--------- Co-authored-by: James Crosswell <[email protected]>
1 parent 4a764c9 commit df30f77

9 files changed

+32
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Redact Authorization headers before sending events to Sentry ([#4164](https://github.com/getsentry/sentry-dotnet/pull/4164))
8+
- Remove Strong Naming from Sentry.Hangfire ([#4099](https://github.com/getsentry/sentry-dotnet/pull/4099))
89

910
### Features
1011

src/Sentry.Hangfire/Sentry.Hangfire.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<PackageTags>$(PackageTags);Hangfire</PackageTags>
66
<TargetFrameworks>net9.0;net8.0;net462</TargetFrameworks>
77
<ImplicitUsings>enable</ImplicitUsings>
8+
<SignAssembly>false</SignAssembly>
89
</PropertyGroup>
910

1011
<PropertyGroup Condition="'$(EnableAot)' == 'true'">

src/Sentry.Hangfire/SentryServerFilter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public SentryServerFilter() : this(null, null)
1717
internal SentryServerFilter(IHub? hub, IDiagnosticLogger? logger)
1818
{
1919
_hub = hub ?? HubAdapter.Instance;
20-
_logger = logger ?? _hub.GetSentryOptions()?.DiagnosticLogger;
20+
#pragma warning disable CS0618 // Type or member is obsolete
21+
_logger = logger ?? _hub.GetInternalSentryOptions()?.DiagnosticLogger;
22+
#pragma warning restore CS0618 // Type or member is obsolete
2123
}
2224

2325
public void OnPerforming(PerformingContext context)

src/Sentry/Sentry.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@
173173
<InternalsVisibleTo Include="Sentry.GraphQL.Client.Tests" PublicKey="$(SentryPublicKey)" />
174174
<InternalsVisibleTo Include="Sentry.Google.Cloud.Functions" PublicKey="$(SentryPublicKey)" />
175175
<InternalsVisibleTo Include="Sentry.Google.Cloud.Functions.Tests" PublicKey="$(SentryPublicKey)" />
176-
<InternalsVisibleTo Include="Sentry.Hangfire" PublicKey="$(SentryPublicKey)" />
177176
<InternalsVisibleTo Include="Sentry.Hangfire.Tests" PublicKey="$(SentryPublicKey)" />
178177
<InternalsVisibleTo Include="Sentry.Log4Net" PublicKey="$(SentryPublicKey)" />
179178
<InternalsVisibleTo Include="Sentry.Log4Net.Tests" PublicKey="$(SentryPublicKey)" />

src/Sentry/SentryClientExtensions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,18 @@ public static Task FlushAsync(this ISentryClient client)
114114
HubAdapter => SentrySdk.CurrentOptions,
115115
_ => SentryOptionsForTestingOnly
116116
};
117+
118+
/// <summary>
119+
/// <para>
120+
/// Gets internal SentryOptions for integrations like Hangfire that don't support strong assembly names.
121+
/// </para>
122+
///<remarks>
123+
/// *** This is not meant for external use !!! ***
124+
/// </remarks>>
125+
/// </summary>
126+
/// <param name="clientOrHub"></param>
127+
/// <returns></returns>
128+
[Obsolete("This method is meant for external usage only")]
129+
public static SentryOptions? GetInternalSentryOptions(this ISentryClient clientOrHub) =>
130+
clientOrHub.GetSentryOptions();
117131
}

test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ namespace Sentry
484484
public static void Flush(this Sentry.ISentryClient client) { }
485485
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
486486
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
487+
[System.Obsolete("This method is meant for external usage only")]
488+
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
487489
}
488490
public static class SentryConstants
489491
{

test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ namespace Sentry
484484
public static void Flush(this Sentry.ISentryClient client) { }
485485
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
486486
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
487+
[System.Obsolete("This method is meant for external usage only")]
488+
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
487489
}
488490
public static class SentryConstants
489491
{

test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,8 @@ namespace Sentry
472472
public static void Flush(this Sentry.ISentryClient client) { }
473473
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
474474
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
475+
[System.Obsolete("This method is meant for external usage only")]
476+
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
475477
}
476478
public static class SentryConstants
477479
{

test/Sentry.Tests/SentrySdkTests.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -676,14 +676,18 @@ public void Implements_Client()
676676
[Fact]
677677
public void Implements_ClientExtensions()
678678
{
679-
var clientExtensions = typeof(SentryClientExtensions).GetMembers(BindingFlags.Public | BindingFlags.Static)
679+
string[] excludedMembers = [nameof(SentryClientExtensions.GetSentryOptions), nameof(SentryClientExtensions.GetInternalSentryOptions)];
680+
var clientExtensions = typeof(SentryClientExtensions)
681+
.GetMembers(BindingFlags.Public | BindingFlags.Static)
682+
.Where(x => !excludedMembers.Contains(x.Name))
680683
// Remove the extension argument: Method(this ISentryClient client, ...
681684
.Select(m => m.ToString()!
682685
.Replace($"({typeof(ISentryClient).FullName}", "(")
683686
.Replace("(, ", "("));
684-
var sentrySdk = typeof(SentrySdk).GetMembers(BindingFlags.Public | BindingFlags.Static);
685687

686-
Assert.Empty(clientExtensions.Except(sentrySdk.Select(m => m.ToString())));
688+
var sentrySdk = typeof(SentrySdk).GetMembers(BindingFlags.Public | BindingFlags.Static);
689+
var values = clientExtensions.Except(sentrySdk.Select(m => m.ToString()));
690+
Assert.Empty(values);
687691
}
688692

689693
[Fact]

0 commit comments

Comments
 (0)