Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Rename IJsonSerializable, Hint, and Attachment #3116

Merged
merged 8 commits into from
Feb 5, 2024
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
### Fixes

- To resolve conflicting types due to the SDK adding itself to the global usings:
- The interface `Sentry.ISession` has been renamed to `Sentry.ISentrySession`
- The interface `Sentry.ISession` has been renamed to `Sentry.ISentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
- The interface `Sentry.IJsonSerializable` has been renamed to `Sentry.ISentryJsonSerializable` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Session` has been renamed to `Sentry.SentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
- The class `Sentry.Attachment` has been renamed to `Sentry.SentryAttachment` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
- The class `Sentry.Hint` has been renamed to `Sentry.SentryHint` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))

### Dependencies

Expand Down
2 changes: 1 addition & 1 deletion samples/Sentry.Samples.Console.Customized/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ await SentrySdk.ConfigureScopeAsync(async scope =>

SentrySdk.AddBreadcrumb(
new Breadcrumb("A breadcrumb that will be replaced by the 'BeforeBreadcrumb callback because of the hint", null),
new Hint("don't trust this breadcrumb", "trust this instead")
new SentryHint("don't trust this breadcrumb", "trust this instead")
);

// Data added to the root scope (no PushScope called up to this point)
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Maui/Internal/ScreenshotAttachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Sentry.Maui.Internal;

internal class ScreenshotAttachment : Attachment
internal class ScreenshotAttachment : SentryAttachment
{
public ScreenshotAttachment(SentryMauiOptions options)
: this(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SentryMauiScreenshotProcessor(SentryMauiOptions options)
return @event;
}

public SentryEvent? Process(SentryEvent @event, Hint hint)
public SentryEvent? Process(SentryEvent @event, SentryHint hint)
{
hint.Attachments.Add(new ScreenshotAttachment(_options));
return @event;
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Breadcrumb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Sentry;
/// Series of application events.
/// </summary>
[DebuggerDisplay("Message: {" + nameof(Message) + "}, Type: {" + nameof(Type) + "}")]
public sealed class Breadcrumb : IJsonSerializable
public sealed class Breadcrumb : ISentryJsonSerializable
{
private readonly IReadOnlyDictionary<string, string>? _data;
private readonly string? _message;
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Contexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Sentry;
/// Represents Sentry's structured Context.
/// </summary>
/// <seealso href="https://develop.sentry.dev/sdk/event-payloads/contexts/" />
public sealed class Contexts : IDictionary<string, object>, IJsonSerializable
public sealed class Contexts : IDictionary<string, object>, ISentryJsonSerializable
{
private readonly ConcurrentDictionary<string, object> _innerDictionary = new(StringComparer.Ordinal);

Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/Extensibility/DisabledHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public bool CaptureEnvelope(Envelope envelope)
/// <summary>
/// No-Op.
/// </summary>
public SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, Hint? hint = null) => SentryId.Empty;
public SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, SentryHint? hint = null) => SentryId.Empty;

/// <summary>
/// No-Op.
Expand All @@ -157,7 +157,7 @@ public bool CaptureEnvelope(Envelope envelope)
/// <summary>
/// No-Op.
/// </summary>
public SentryId CaptureEvent(SentryEvent evt, Hint? hint, Action<Scope> configureScope) => SentryId.Empty;
public SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Action<Scope> configureScope) => SentryId.Empty;

/// <summary>
/// No-Op.
Expand All @@ -169,7 +169,7 @@ public void CaptureTransaction(SentryTransaction transaction)
/// <summary>
/// No-Op.
/// </summary>
public void CaptureTransaction(SentryTransaction transaction, Scope? scope, Hint? hint)
public void CaptureTransaction(SentryTransaction transaction, Scope? scope, SentryHint? hint)
{
}

Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/Extensibility/HubAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope)
/// </summary>
[DebuggerStepThrough]
[EditorBrowsable(EditorBrowsableState.Never)]
public SentryId CaptureEvent(SentryEvent evt, Scope? scope, Hint? hint = null)
public SentryId CaptureEvent(SentryEvent evt, Scope? scope, SentryHint? hint = null)
=> SentrySdk.CaptureEvent(evt, scope, hint);

/// <summary>
Expand All @@ -233,7 +233,7 @@ public SentryId CaptureEvent(SentryEvent evt, Action<Scope> configureScope)
/// <summary>
/// Forwards the call to <see cref="SentrySdk"/>.
/// </summary>
public SentryId CaptureEvent(SentryEvent evt, Hint? hint, Action<Scope> configureScope)
public SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Action<Scope> configureScope)
=> SentrySdk.CaptureEvent(evt, hint, configureScope);

/// <summary>
Expand All @@ -256,7 +256,7 @@ public void CaptureTransaction(SentryTransaction transaction)
/// </summary>
[DebuggerStepThrough]
[EditorBrowsable(EditorBrowsableState.Never)]
public void CaptureTransaction(SentryTransaction transaction, Scope? scope, Hint? hint)
public void CaptureTransaction(SentryTransaction transaction, Scope? scope, SentryHint? hint)
=> SentrySdk.CaptureTransaction(transaction, scope, hint);

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Extensibility/ISentryEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public interface ISentryEventProcessor

internal static class ISentryEventProcessorExtensions
{
internal static SentryEvent? DoProcessEvent(this ISentryEventProcessor processor, SentryEvent @event, Hint hint)
internal static SentryEvent? DoProcessEvent(this ISentryEventProcessor processor, SentryEvent @event, SentryHint hint)
{
return (processor is ISentryEventProcessorWithHint contextualProcessor)
? contextualProcessor.Process(@event, hint)
Expand Down
4 changes: 2 additions & 2 deletions src/Sentry/Extensibility/ISentryEventProcessorWithHint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public interface ISentryEventProcessorWithHint : ISentryEventProcessor
/// Process the <see cref="SentryEvent"/>
/// </summary>
/// <param name="event">The event to process</param>
/// <param name="hint">A <see cref="Hint"/> with context that may be useful prior to sending the event</param>
/// <param name="hint">A <see cref="SentryHint"/> with context that may be useful prior to sending the event</param>
/// <return>The processed event or <c>null</c> if the event was dropped.</return>
/// <remarks>
/// The event returned can be the same instance received or a new one.
/// Returning null will stop the processing pipeline so that the event will neither be processed by
/// additional event processors or sent to Sentry.
/// </remarks>
SentryEvent? Process(SentryEvent @event, Hint hint);
SentryEvent? Process(SentryEvent @event, SentryHint hint);
}

2 changes: 1 addition & 1 deletion src/Sentry/Extensibility/ISentryTransactionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface ISentryTransactionProcessor

internal static class ISentryTransactionProcessorExtensions
{
internal static SentryTransaction? DoProcessTransaction(this ISentryTransactionProcessor processor, SentryTransaction transaction, Hint hint)
internal static SentryTransaction? DoProcessTransaction(this ISentryTransactionProcessor processor, SentryTransaction transaction, SentryHint hint)
{
return (processor is ISentryTransactionProcessorWithHint contextualProcessor)
? contextualProcessor.Process(transaction, hint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public interface ISentryTransactionProcessorWithHint : ISentryTransactionProcess
/// Process the <see cref="SentryTransaction"/>
/// </summary>
/// <param name="transaction">The Transaction to process</param>
/// <param name="hint">A <see cref="Hint"/> with context that may be useful prior to sending the transaction</param>
/// <param name="hint">A <see cref="SentryHint"/> with context that may be useful prior to sending the transaction</param>
/// <remarks>
/// The transaction returned can be the same instance received or a new one.
/// Returning null will stop the processing pipeline.
/// Meaning the transaction should no longer be processed nor send.
/// </remarks>
SentryTransaction? Process(SentryTransaction transaction, Hint hint);
SentryTransaction? Process(SentryTransaction transaction, SentryHint hint);
}
4 changes: 2 additions & 2 deletions src/Sentry/HubExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static void AddBreadcrumb(
public static void AddBreadcrumb(
this IHub hub,
Breadcrumb breadcrumb,
Hint? hint = null
SentryHint? hint = null
)
{
// Not to throw on code that ignores nullability warnings.
Expand All @@ -145,7 +145,7 @@ public static void AddBreadcrumb(
}

hub.ConfigureScope(
s => s.AddBreadcrumb(breadcrumb, hint ?? new Hint())
s => s.AddBreadcrumb(breadcrumb, hint ?? new SentryHint())
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/IHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ TransactionContext ContinueTrace(
/// <param name="hint">An optional hint to be provided with the event</param>
/// <param name="configureScope">The callback to configure the scope.</param>
/// <returns></returns>
public SentryId CaptureEvent(SentryEvent evt, Hint? hint, Action<Scope> configureScope);
public SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Action<Scope> configureScope);
}
4 changes: 2 additions & 2 deletions src/Sentry/ISentryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface ISentryClient
/// <param name="scope">An optional scope to be applied to the event.</param>
/// <param name="hint">An optional hint providing high level context for the source of the event</param>
/// <returns>The Id of the event.</returns>
SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, Hint? hint = null);
SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, SentryHint? hint = null);

/// <summary>
/// Captures a user feedback.
Expand Down Expand Up @@ -60,7 +60,7 @@ public interface ISentryClient
/// This will be available in callbacks prior to processing the transaction.
/// </param>
[EditorBrowsable(EditorBrowsableState.Never)]
void CaptureTransaction(SentryTransaction transaction, Scope? scope, Hint? hint);
void CaptureTransaction(SentryTransaction transaction, Scope? scope, SentryHint? hint);

/// <summary>
/// Captures a session update.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Sentry;
/// <summary>
/// Sentry JsonSerializable.
/// </summary>
public interface IJsonSerializable
public interface ISentryJsonSerializable
{
/// <summary>
/// Writes the object as JSON.
Expand All @@ -19,7 +19,7 @@ public interface IJsonSerializable

internal static class JsonSerializableExtensions
{
public static void WriteToFile(this IJsonSerializable serializable, string filePath, IDiagnosticLogger? logger)
public static void WriteToFile(this ISentryJsonSerializable serializable, string filePath, IDiagnosticLogger? logger)
{
using var file = File.Create(filePath);
using var writer = new Utf8JsonWriter(file);
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Internal/ClientReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Sentry.Internal;

internal class ClientReport : IJsonSerializable
internal class ClientReport : ISentryJsonSerializable
{
public DateTimeOffset Timestamp { get; }
public IReadOnlyDictionary<DiscardReasonWithCategory, int> DiscardedEvents { get; }
Expand Down
16 changes: 8 additions & 8 deletions src/Sentry/Internal/Extensions/JsonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static void Deconstruct(this JsonProperty jsonProperty, out string name,
public static Dictionary<string, TValue>? GetDictionaryOrNull<TValue>(
this JsonElement json,
Func<JsonElement, TValue> factory)
where TValue : IJsonSerializable?
where TValue : ISentryJsonSerializable?
{
if (json.ValueKind != JsonValueKind.Object)
{
Expand Down Expand Up @@ -283,7 +283,7 @@ public static void WriteDictionaryValue<TValue>(
IEnumerable<KeyValuePair<string, TValue>>? dic,
IDiagnosticLogger? logger,
bool includeNullValues = true)
where TValue : IJsonSerializable?
where TValue : ISentryJsonSerializable?
{
if (dic is not null)
{
Expand Down Expand Up @@ -345,7 +345,7 @@ public static void WriteDictionary<TValue>(
string propertyName,
IEnumerable<KeyValuePair<string, TValue>>? dic,
IDiagnosticLogger? logger)
where TValue : IJsonSerializable?
where TValue : ISentryJsonSerializable?
{
writer.WritePropertyName(propertyName);
writer.WriteDictionaryValue(dic, logger);
Expand Down Expand Up @@ -424,7 +424,7 @@ public static void WriteStringArray(

public static void WriteSerializableValue(
this Utf8JsonWriter writer,
IJsonSerializable value,
ISentryJsonSerializable value,
IDiagnosticLogger? logger)
{
value.WriteTo(writer, logger);
Expand All @@ -433,7 +433,7 @@ public static void WriteSerializableValue(
public static void WriteSerializable(
this Utf8JsonWriter writer,
string propertyName,
IJsonSerializable value,
ISentryJsonSerializable value,
IDiagnosticLogger? logger)
{
writer.WritePropertyName(propertyName);
Expand All @@ -449,7 +449,7 @@ public static void WriteDynamicValue(
{
writer.WriteNullValue();
}
else if (value is IJsonSerializable serializable)
else if (value is ISentryJsonSerializable serializable)
{
writer.WriteSerializableValue(serializable, logger);
}
Expand Down Expand Up @@ -784,7 +784,7 @@ public static void WriteStringIfNotNull(
public static void WriteSerializableIfNotNull(
this Utf8JsonWriter writer,
string propertyName,
IJsonSerializable? value,
ISentryJsonSerializable? value,
IDiagnosticLogger? logger)
{
if (value is not null)
Expand All @@ -811,7 +811,7 @@ public static void WriteDictionaryIfNotEmpty<TValue>(
string propertyName,
IEnumerable<KeyValuePair<string, TValue>>? dic,
IDiagnosticLogger? logger)
where TValue : IJsonSerializable?
where TValue : ISentryJsonSerializable?
{
var dictionary = dic as IReadOnlyDictionary<string, TValue> ?? dic?.ToDict();
if (dictionary is not null && dictionary.Count > 0)
Expand Down
6 changes: 3 additions & 3 deletions src/Sentry/Internal/Hub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void ApplyTraceContextToEvent(SentryEvent evt, SentryPropagationContext
public SentryId CaptureEvent(SentryEvent evt, Action<Scope> configureScope)
=> CaptureEvent(evt, null, configureScope);

public SentryId CaptureEvent(SentryEvent evt, Hint? hint, Action<Scope> configureScope)
public SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Action<Scope> configureScope)
{
if (!IsEnabled)
{
Expand All @@ -405,7 +405,7 @@ public SentryId CaptureEvent(SentryEvent evt, Hint? hint, Action<Scope> configur

public bool CaptureEnvelope(Envelope envelope) => _ownedClient.CaptureEnvelope(envelope);

public SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, Hint? hint = null)
public SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, SentryHint? hint = null)
{
if (!IsEnabled)
{
Expand Down Expand Up @@ -473,7 +473,7 @@ public void CaptureUserFeedback(UserFeedback userFeedback)

public void CaptureTransaction(SentryTransaction transaction) => CaptureTransaction(transaction, null, null);

public void CaptureTransaction(SentryTransaction transaction, Scope? scope, Hint? hint)
public void CaptureTransaction(SentryTransaction transaction, Scope? scope, SentryHint? hint)
{
// Note: The hub should capture transactions even if it is disabled.
// This allows transactions to be reported as failed when they encountered an unhandled exception,
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Internal/MemoryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Sentry.Internal;

internal sealed class MemoryInfo : IJsonSerializable
internal sealed class MemoryInfo : ISentryJsonSerializable
{
public long AllocatedBytes { get; }
public long FragmentedBytes { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Internal/ThreadPoolInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Sentry.Internal;

internal sealed class ThreadPoolInfo : IJsonSerializable
internal sealed class ThreadPoolInfo : ISentryJsonSerializable
{
public ThreadPoolInfo(
int minWorkerThreads,
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Sentry;
/// <summary>
/// Represents a package used to compose the SDK.
/// </summary>
public sealed class Package : IJsonSerializable
public sealed class Package : ISentryJsonSerializable
{
/// <summary>
/// The name of the package.
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry/PersistedSessionUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Sentry;

internal class PersistedSessionUpdate : IJsonSerializable
internal class PersistedSessionUpdate : ISentryJsonSerializable
{
public SessionUpdate Update { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ namespace Sentry.Android.Callbacks;

internal class BeforeBreadcrumbCallback : JavaObject, JavaSdk.SentryOptions.IBeforeBreadcrumbCallback
{
private readonly Func<Breadcrumb, Hint, Breadcrumb?> _beforeBreadcrumb;
private readonly Func<Breadcrumb, SentryHint, Breadcrumb?> _beforeBreadcrumb;

public BeforeBreadcrumbCallback(Func<Breadcrumb, Hint, Breadcrumb?> beforeBreadcrumb)
public BeforeBreadcrumbCallback(Func<Breadcrumb, SentryHint, Breadcrumb?> beforeBreadcrumb)
{
_beforeBreadcrumb = beforeBreadcrumb;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ namespace Sentry.Android.Callbacks;

internal class BeforeSendCallback : JavaObject, JavaSdk.SentryOptions.IBeforeSendCallback
{
private readonly Func<SentryEvent, Hint, SentryEvent?> _beforeSend;
private readonly Func<SentryEvent, SentryHint, SentryEvent?> _beforeSend;
private readonly SentryOptions _options;
private readonly JavaSdk.SentryOptions _javaOptions;

public BeforeSendCallback(
Func<SentryEvent, Hint, SentryEvent?> beforeSend,
Func<SentryEvent, SentryHint, SentryEvent?> beforeSend,
SentryOptions options,
JavaSdk.SentryOptions javaOptions)
{
Expand Down
Loading
Loading