Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixes

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

### Features

Expand Down
1 change: 1 addition & 0 deletions src/Sentry.Hangfire/Sentry.Hangfire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<PackageTags>$(PackageTags);Hangfire</PackageTags>
<TargetFrameworks>net9.0;net8.0;net462</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<SignAssembly>false</SignAssembly>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableAot)' == 'true'">
Expand Down
4 changes: 3 additions & 1 deletion src/Sentry.Hangfire/SentryServerFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public SentryServerFilter() : this(null, null)
internal SentryServerFilter(IHub? hub, IDiagnosticLogger? logger)
{
_hub = hub ?? HubAdapter.Instance;
_logger = logger ?? _hub.GetSentryOptions()?.DiagnosticLogger;
#pragma warning disable CS0618 // Type or member is obsolete
_logger = logger ?? _hub.GetInternalSentryOptions()?.DiagnosticLogger;
#pragma warning restore CS0618 // Type or member is obsolete
}

public void OnPerforming(PerformingContext context)
Expand Down
1 change: 0 additions & 1 deletion src/Sentry/Sentry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
<InternalsVisibleTo Include="Sentry.GraphQL.Client.Tests" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Google.Cloud.Functions" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Google.Cloud.Functions.Tests" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Hangfire" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Hangfire.Tests" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Log4Net" PublicKey="$(SentryPublicKey)" />
<InternalsVisibleTo Include="Sentry.Log4Net.Tests" PublicKey="$(SentryPublicKey)" />
Expand Down
14 changes: 14 additions & 0 deletions src/Sentry/SentryClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,18 @@ public static Task FlushAsync(this ISentryClient client)
HubAdapter => SentrySdk.CurrentOptions,
_ => SentryOptionsForTestingOnly
};

/// <summary>
/// <para>
/// Gets internal SentryOptions for integrations like Hangfire that don't support strong assembly names.
/// </para>
///<remarks>
/// *** This is not meant for external use !!! ***
/// </remarks>>
/// </summary>
/// <param name="clientOrHub"></param>
/// <returns></returns>
[Obsolete("This method is meant for external usage only")]
public static SentryOptions? GetInternalSentryOptions(this ISentryClient clientOrHub) =>
clientOrHub.GetSentryOptions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ namespace Sentry
public static void Flush(this Sentry.ISentryClient client) { }
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
[System.Obsolete("This method is meant for external usage only")]
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
}
public static class SentryConstants
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ namespace Sentry
public static void Flush(this Sentry.ISentryClient client) { }
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
[System.Obsolete("This method is meant for external usage only")]
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
}
public static class SentryConstants
{
Expand Down
2 changes: 2 additions & 0 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ namespace Sentry
public static void Flush(this Sentry.ISentryClient client) { }
public static void Flush(this Sentry.ISentryClient client, System.TimeSpan timeout) { }
public static System.Threading.Tasks.Task FlushAsync(this Sentry.ISentryClient client) { }
[System.Obsolete("This method is meant for external usage only")]
public static Sentry.SentryOptions? GetInternalSentryOptions(this Sentry.ISentryClient clientOrHub) { }
}
public static class SentryConstants
{
Expand Down
10 changes: 7 additions & 3 deletions test/Sentry.Tests/SentrySdkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -676,14 +676,18 @@ public void Implements_Client()
[Fact]
public void Implements_ClientExtensions()
{
var clientExtensions = typeof(SentryClientExtensions).GetMembers(BindingFlags.Public | BindingFlags.Static)
string[] excludedMembers = [nameof(SentryClientExtensions.GetSentryOptions), nameof(SentryClientExtensions.GetInternalSentryOptions)];
var clientExtensions = typeof(SentryClientExtensions)
.GetMembers(BindingFlags.Public | BindingFlags.Static)
.Where(x => !excludedMembers.Contains(x.Name))
// Remove the extension argument: Method(this ISentryClient client, ...
.Select(m => m.ToString()!
.Replace($"({typeof(ISentryClient).FullName}", "(")
.Replace("(, ", "("));
var sentrySdk = typeof(SentrySdk).GetMembers(BindingFlags.Public | BindingFlags.Static);

Assert.Empty(clientExtensions.Except(sentrySdk.Select(m => m.ToString())));
var sentrySdk = typeof(SentrySdk).GetMembers(BindingFlags.Public | BindingFlags.Static);
var values = clientExtensions.Except(sentrySdk.Select(m => m.ToString()));
Assert.Empty(values);
}

[Fact]
Expand Down
Loading