Skip to content

Commit 125de43

Browse files
committed
code fix: don't throw inside AggressiveInlining
1 parent 6f80b2e commit 125de43

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

tracer/src/Datadog.Trace/Ci/Coverage/CoverageReporter.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ internal static CoverageEventHandler Handler
2929
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3030
get => _handler;
3131
[MethodImpl(MethodImplOptions.AggressiveInlining)]
32-
set => _handler = value ?? throw new ArgumentNullException(nameof(value));
32+
set
33+
{
34+
if (value == null!)
35+
{
36+
ThrowHelper.ThrowArgumentNullException(nameof(value));
37+
}
38+
39+
_handler = value;
40+
}
3341
}
3442

3543
internal static CoverageContextContainer? Container => _handler.Container;

tracer/src/Datadog.Trace/Debugger/ExceptionAutoInstrumentation/ExceptionNormalizer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ internal int NormalizeAndHashException(string exceptionString, string outerExcep
3030
{
3131
if (string.IsNullOrEmpty(exceptionString))
3232
{
33-
throw new ArgumentException(@"Exception string cannot be null or empty", nameof(exceptionString));
33+
ThrowHelper.ThrowArgumentException(@"Exception string cannot be null or empty", nameof(exceptionString));
34+
return 0; // code never reached
3435
}
3536

3637
var fnvHashCode = HashLine(outerExceptionType.AsSpan(), Fnv1aHash.FnvOffsetBias);
@@ -104,7 +105,8 @@ internal List<string> ParseFrames(string exceptionString)
104105
{
105106
if (string.IsNullOrEmpty(exceptionString))
106107
{
107-
throw new ArgumentException(@"Exception string cannot be null or empty", nameof(exceptionString));
108+
ThrowHelper.ThrowArgumentException(@"Exception string cannot be null or empty", nameof(exceptionString));
109+
return null; // code never reached
108110
}
109111

110112
var results = new List<string>();

tracer/src/Datadog.Trace/Util/FixedSizeArrayPool.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
using System;
88
using System.Collections.Concurrent;
9-
using System.Diagnostics;
109
using System.Runtime.CompilerServices;
1110
using System.Threading;
1211

@@ -115,7 +114,7 @@ public T[] Array
115114
#if DEBUG
116115
if (_array is null)
117116
{
118-
throw new ObjectDisposedException(nameof(ArrayPoolItem));
117+
ThrowHelper.ThrowObjectDisposedException(nameof(ArrayPoolItem));
119118
}
120119
#endif
121120
return _array ?? [];

tracer/src/Datadog.Trace/Util/SpanCharSplitter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ internal readonly ref struct SpanCharSplitter
1919
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2020
public SpanCharSplitter(string source, char separator, int count)
2121
{
22-
_source = source ?? throw new ArgumentNullException(nameof(source));
22+
if (source == null!)
23+
{
24+
ThrowHelper.ThrowArgumentNullException(nameof(source));
25+
}
26+
27+
_source = source;
2328
_separator = separator;
2429
_count = count;
2530
}

0 commit comments

Comments
 (0)