Skip to content

Commit a98a7c9

Browse files
committed
backporting 2.1.8 changes
1 parent 27267e6 commit a98a7c9

File tree

6 files changed

+29
-13
lines changed

6 files changed

+29
-13
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## vNext
4+
5+
* Add SentryScopeProcessor #603
6+
37
## 3.0.0-alpha.5
48

59
* Replaced `BaseScope` with `IScope`. (#590) @Tyrrrz

samples/Sentry.Samples.Console.Customized/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ private class MyCustomerScopeStateProcessor : ISentryScopeStateProcessor
273273
{
274274
private readonly ISentryScopeStateProcessor _fallback = new DefaultSentryScopeStateProcessor();
275275

276-
public void Apply(BaseScope scope, object state)
276+
public void Apply(IScope scope, object state)
277277
{
278278
if (state is SpecialContextObject specialState)
279279
{

src/Sentry.Protocol/ISentryScopeProcessor.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/Sentry.Protocol/DefaultSentryScopeProcessor.cs renamed to src/Sentry/Protocol/DefaultSentryScopeStateProcessor.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44

55
namespace Sentry.Protocol
66
{
7-
public class DefaultSentryScopeProcessor : ISentryScopeProcessor
7+
/// <summary>
8+
/// Defines the logic for applying state onto a scope.
9+
/// </summary>
10+
public class DefaultSentryScopeStateProcessor : ISentryScopeStateProcessor
811
{
9-
public void Apply(BaseScope scope, object state)
12+
/// <summary>
13+
/// Applies state onto a scope.
14+
/// </summary>
15+
public void Apply(IScope scope, object state)
1016
{
1117
switch (state)
1218
{
@@ -23,7 +29,7 @@ public void Apply(BaseScope scope, object state)
2329
scope.SetTags(keyValStringObject
2430
.Select(k => new KeyValuePair<string, string>(
2531
k.Key,
26-
k.Value?.ToString()))
32+
k.Value?.ToString()!))
2733
.Where(kv => !string.IsNullOrEmpty(kv.Value)));
2834

2935
break;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Sentry.Protocol
2+
{
3+
/// <summary>
4+
/// Defines the logic for applying state onto a scope.
5+
/// </summary>
6+
public interface ISentryScopeStateProcessor
7+
{
8+
/// <summary>
9+
/// Applies state onto a scope.
10+
/// </summary>
11+
void Apply(IScope scope, object state);
12+
}
13+
}

src/Sentry/ScopeExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
using System.Collections.Concurrent;
33
using System.Collections.Generic;
44
using System.ComponentModel;
5-
using System.Linq;
65
using Sentry.Extensibility;
6+
using System.Linq;
77
using Sentry.Internal;
88
using Sentry.Protocol;
99
using Constants = Sentry.Protocol.Constants;
@@ -354,7 +354,7 @@ public static void Apply(this IScope from, IScope to)
354354
/// <param name="state">The state object to apply.</param>
355355
public static void Apply(this IScope scope, object state)
356356
{
357-
var processor = scope.ScopeOptions.SentryScopeProcessor ?? new DefaultSentryScopeProcessor();
357+
var processor = scope.ScopeOptions?.SentryScopeStateProcessor ?? new DefaultSentryScopeStateProcessor();
358358
processor.Apply(scope, state);
359359
}
360360

0 commit comments

Comments
 (0)