Skip to content

Commit a21a6b4

Browse files
authored
fix: Renamed Contexts, Request, and Package (#3121)
1 parent 5d6f091 commit a21a6b4

31 files changed

+395
-388
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- To resolve conflicting types due to the SDK adding itself to the global usings:
8+
- The class `Sentry.Context` has been renamed to `Sentry.SentryContext` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))
9+
- The class `Sentry.Package` has been renamed to `Sentry.SentryPackage` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))
10+
- The class `Sentry.Request` has been renamed to `Sentry.SentryRequest` ([#3121](https://github.com/getsentry/sentry-dotnet/pull/3121))
11+
512
### Dependencies
613

714
- Bump CLI from v2.27.0 to v2.28.0 ([#3119](https://github.com/getsentry/sentry-dotnet/pull/3119))
@@ -16,8 +23,8 @@
1623
- The interface `Sentry.ISession` has been renamed to `Sentry.ISentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
1724
- The interface `Sentry.IJsonSerializable` has been renamed to `Sentry.ISentryJsonSerializable` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
1825
- The class `Sentry.Session` has been renamed to `Sentry.SentrySession` ([#3110](https://github.com/getsentry/sentry-dotnet/pull/3110))
19-
- The class `Sentry.Attachment` has been renamed to `Sentry.SentryAttachment` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
20-
- The class `Sentry.Hint` has been renamed to `Sentry.SentryHint` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
26+
- The class `Sentry.Attachment` has been renamed to `Sentry.SentryAttachment` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
27+
- The class `Sentry.Hint` has been renamed to `Sentry.SentryHint` ([#3116](https://github.com/getsentry/sentry-dotnet/pull/3116))
2128

2229
### Dependencies
2330

src/Sentry/IEventLike.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ public interface IEventLike : IHasTags, IHasExtra
3232
/// <value>
3333
/// The HTTP.
3434
/// </value>
35-
Request Request { get; set; }
35+
SentryRequest Request { get; set; }
3636

3737
/// <summary>
3838
/// Gets the structured Sentry context.
3939
/// </summary>
4040
/// <value>
4141
/// The contexts.
4242
/// </value>
43-
Contexts Contexts { get; set; }
43+
SentryContexts Contexts { get; set; }
4444

4545
/// <summary>
4646
/// Gets the user information.

src/Sentry/Internal/MainSentryEventProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public SentryEvent Process(SentryEvent @event)
158158
return @event;
159159
}
160160

161-
private static void AddMemoryInfo(Contexts contexts)
161+
private static void AddMemoryInfo(SentryContexts contexts)
162162
{
163163
#if NETCOREAPP3_0_OR_GREATER
164164
var memory = GC.GetGCMemoryInfo();
@@ -192,7 +192,7 @@ private static void AddMemoryInfo(Contexts contexts)
192192
#endif
193193
}
194194

195-
private static void AddThreadPoolInfo(Contexts contexts)
195+
private static void AddThreadPoolInfo(SentryContexts contexts)
196196
{
197197
ThreadPool.GetMinThreads(out var minWorkerThreads, out var minCompletionPortThreads);
198198
ThreadPool.GetMaxThreads(out var maxWorkerThreads, out var maxCompletionPortThreads);

src/Sentry/Internal/NoOpTransaction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ public SentryLevel? Level
3939
set { }
4040
}
4141

42-
public Request Request
42+
public SentryRequest Request
4343
{
4444
get => new();
4545
set { }
4646
}
4747

48-
public Contexts Contexts
48+
public SentryContexts Contexts
4949
{
5050
get => new();
5151
set { }

src/Sentry/Platforms/Cocoa/CocoaEventProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public SentryEvent Process(SentryEvent @event)
1616
if (json != null)
1717
{
1818
var jsonDoc = JsonDocument.Parse(json);
19-
var contexts = Contexts.FromJson(jsonDoc.RootElement);
19+
var contexts = SentryContexts.FromJson(jsonDoc.RootElement);
2020
contexts.CopyTo(@event.Contexts);
2121
}
2222

src/Sentry/Protocol/ProfileInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ internal sealed class ProfileInfo : ISentryJsonSerializable
1515

1616
public DebugMeta DebugMeta { get; set; } = new() { Images = new() };
1717

18-
private readonly Contexts _contexts = new();
18+
private readonly SentryContexts _contexts = new();
1919

2020
/// <inheritdoc />
21-
public Contexts Contexts
21+
public SentryContexts Contexts
2222
{
2323
get => _contexts;
2424
set => _contexts.ReplaceWith(value);

src/Sentry/Scope.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ internal SentryId LastEventId
8585
/// <inheritdoc />
8686
public SentryLevel? Level { get; set; }
8787

88-
private Request? _request;
88+
private SentryRequest? _request;
8989

9090
/// <inheritdoc />
91-
public Request Request
91+
public SentryRequest Request
9292
{
93-
get => _request ??= new Request();
93+
get => _request ??= new SentryRequest();
9494
set => _request = value;
9595
}
9696

97-
private readonly Contexts _contexts = new();
97+
private readonly SentryContexts _contexts = new();
9898

9999
/// <inheritdoc />
100-
public Contexts Contexts
100+
public SentryContexts Contexts
101101
{
102102
get => _contexts;
103103
set => _contexts.ReplaceWith(value);

src/Sentry/SdkVersion.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ public sealed class SdkVersion : ISentryJsonSerializable
1919

2020
internal static SdkVersion Instance => InstanceLazy.Value;
2121

22-
internal ConcurrentBag<Package> InternalPackages { get; set; } = new();
22+
internal ConcurrentBag<SentryPackage> InternalPackages { get; set; } = new();
2323
internal ConcurrentBag<string> Integrations { get; set; } = new();
2424

2525
/// <summary>
2626
/// SDK packages.
2727
/// </summary>
2828
/// <remarks>This property is not required.</remarks>
29-
public IEnumerable<Package> Packages => InternalPackages;
29+
public IEnumerable<SentryPackage> Packages => InternalPackages;
3030

3131
/// <summary>
3232
/// SDK name.
@@ -56,9 +56,9 @@ public string? Version
5656
/// <param name="name">The package name.</param>
5757
/// <param name="version">The package version.</param>
5858
public void AddPackage(string name, string version)
59-
=> AddPackage(new Package(name, version));
59+
=> AddPackage(new SentryPackage(name, version));
6060

61-
internal void AddPackage(Package package)
61+
internal void AddPackage(SentryPackage package)
6262
=> InternalPackages.Add(package);
6363

6464
/// <summary>
@@ -88,8 +88,8 @@ public static SdkVersion FromJson(JsonElement json)
8888
{
8989
// Packages
9090
var packages =
91-
json.GetPropertyOrNull("packages")?.EnumerateArray().Select(Package.FromJson).ToArray()
92-
?? Array.Empty<Package>();
91+
json.GetPropertyOrNull("packages")?.EnumerateArray().Select(SentryPackage.FromJson).ToArray()
92+
?? Array.Empty<SentryPackage>();
9393

9494
// Integrations
9595
var integrations =
@@ -104,7 +104,7 @@ public static SdkVersion FromJson(JsonElement json)
104104

105105
return new SdkVersion
106106
{
107-
InternalPackages = new ConcurrentBag<Package>(packages),
107+
InternalPackages = new ConcurrentBag<SentryPackage>(packages),
108108
Integrations = new ConcurrentBag<string>(integrations),
109109
Name = name,
110110
Version = version

src/Sentry/Contexts.cs renamed to src/Sentry/SentryContexts.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Sentry;
1111
/// Represents Sentry's structured Context.
1212
/// </summary>
1313
/// <seealso href="https://develop.sentry.dev/sdk/event-payloads/contexts/" />
14-
public sealed class Contexts : IDictionary<string, object>, ISentryJsonSerializable
14+
public sealed class SentryContexts : IDictionary<string, object>, ISentryJsonSerializable
1515
{
1616
private readonly ConcurrentDictionary<string, object> _innerDictionary = new(StringComparer.Ordinal);
1717

@@ -59,16 +59,16 @@ public sealed class Contexts : IDictionary<string, object>, ISentryJsonSerializa
5959
public Trace Trace => _innerDictionary.GetOrCreate<Trace>(Trace.Type);
6060

6161
/// <summary>
62-
/// Initializes an instance of <see cref="Contexts"/>.
62+
/// Initializes an instance of <see cref="SentryContexts"/>.
6363
/// </summary>
64-
public Contexts() { }
64+
public SentryContexts() { }
6565

6666
/// <summary>
6767
/// Creates a deep clone of this context.
6868
/// </summary>
69-
internal Contexts Clone()
69+
internal SentryContexts Clone()
7070
{
71-
var context = new Contexts();
71+
var context = new SentryContexts();
7272

7373
CopyTo(context);
7474

@@ -78,7 +78,7 @@ internal Contexts Clone()
7878
/// <summary>
7979
/// Copies the items of the context while cloning the known types.
8080
/// </summary>
81-
internal void CopyTo(Contexts to)
81+
internal void CopyTo(SentryContexts to)
8282
{
8383
foreach (var kv in this)
8484
{
@@ -126,9 +126,9 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger)
126126
/// <summary>
127127
/// Parses from JSON.
128128
/// </summary>
129-
public static Contexts FromJson(JsonElement json)
129+
public static SentryContexts FromJson(JsonElement json)
130130
{
131-
var result = new Contexts();
131+
var result = new SentryContexts();
132132

133133
foreach (var (name, value) in json.EnumerateObject())
134134
{
@@ -181,7 +181,7 @@ public static Contexts FromJson(JsonElement json)
181181
return result;
182182
}
183183

184-
internal void ReplaceWith(Contexts? contexts)
184+
internal void ReplaceWith(SentryContexts? contexts)
185185
{
186186
Clear();
187187

@@ -196,7 +196,7 @@ internal void ReplaceWith(Contexts? contexts)
196196
}
197197
}
198198

199-
internal Contexts? NullIfEmpty() => _innerDictionary.IsEmpty ? null : this;
199+
internal SentryContexts? NullIfEmpty() => _innerDictionary.IsEmpty ? null : this;
200200

201201
/// <inheritdoc/>
202202
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _innerDictionary.GetEnumerator();

src/Sentry/SentryEvent.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,19 @@ public List<DebugImage>? DebugImages
120120
/// <inheritdoc />
121121
public string? TransactionName { get; set; }
122122

123-
private Request? _request;
123+
private SentryRequest? _request;
124124

125125
/// <inheritdoc />
126-
public Request Request
126+
public SentryRequest Request
127127
{
128-
get => _request ??= new Request();
128+
get => _request ??= new SentryRequest();
129129
set => _request = value;
130130
}
131131

132-
private readonly Contexts _contexts = new();
132+
private readonly SentryContexts _contexts = new();
133133

134134
/// <inheritdoc />
135-
public Contexts Contexts
135+
public SentryContexts Contexts
136136
{
137137
get => _contexts;
138138
set => _contexts.ReplaceWith(value);
@@ -301,8 +301,8 @@ internal static SentryEvent FromJson(JsonElement json, Exception? exception)
301301
var threadValues = json.GetPropertyOrNull("threads")?.GetPropertyOrNull("values")?.EnumerateArray().Select(SentryThread.FromJson).ToList().Pipe(v => new SentryValues<SentryThread>(v));
302302
var level = json.GetPropertyOrNull("level")?.GetString()?.ParseEnum<SentryLevel>();
303303
var transaction = json.GetPropertyOrNull("transaction")?.GetString();
304-
var request = json.GetPropertyOrNull("request")?.Pipe(Request.FromJson);
305-
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(Contexts.FromJson);
304+
var request = json.GetPropertyOrNull("request")?.Pipe(SentryRequest.FromJson);
305+
var contexts = json.GetPropertyOrNull("contexts")?.Pipe(SentryContexts.FromJson);
306306
var user = json.GetPropertyOrNull("user")?.Pipe(SentryUser.FromJson);
307307
var environment = json.GetPropertyOrNull("environment")?.GetString();
308308
var sdk = json.GetPropertyOrNull("sdk")?.Pipe(SdkVersion.FromJson) ?? new SdkVersion();

0 commit comments

Comments
 (0)