Skip to content

Commit 70d5b44

Browse files
committed
Merge branch 'main' into NetFX-Stack-Capture
2 parents cd82beb + bae2663 commit 70d5b44

23 files changed

+59
-55
lines changed

src/OpenTelemetry.AutoInstrumentation/CallTarget/CallTargetInvoker.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ public static CallTargetReturn EndMethod<TIntegration, TTarget>(TTarget instance
318318
[MethodImpl(MethodImplOptions.AggressiveInlining)]
319319
public static void LogException<TIntegration, TTarget>(Exception exception)
320320
{
321+
#pragma warning disable CA1062 // Validate arguments of public methods. The method in intended to use only with our internal code.
321322
IntegrationOptions<TIntegration, TTarget>.LogException(exception);
323+
#pragma warning restore CA1062 // Validate arguments of public methods. The method in intended to use only with our internal code.
322324
}
323325

324326
/// <summary>

src/OpenTelemetry.AutoInstrumentation/CallTarget/CallTargetReturn.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public CallTargetReturn(T returnValue)
3131
/// <returns>Default call target return value</returns>
3232
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3333
#pragma warning disable CA1024 // Use properties where appropriate
34+
#pragma warning disable CA1000 // Do not declare static members on generic types, needed for bytecode instrumentation
3435
public static CallTargetReturn<T> GetDefault()
36+
#pragma warning restore CA1000 // Do not declare static members on generic types, needed for bytecode instrumentation
3537
#pragma warning restore CA1024 // Use properties where appropriate
3638
{
3739
return default;

src/OpenTelemetry.AutoInstrumentation/CallTarget/Handlers/Continuations/ContinuationsHelper.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ internal static TTo Convert<TFrom, TTo>(TFrom value)
3838

3939
private static class Converter<TFrom, TTo>
4040
{
41-
private static readonly ConvertDelegate _converter;
41+
private static readonly ConvertDelegate Instance = CreateConverter();
4242

43-
static Converter()
43+
private delegate TTo ConvertDelegate(TFrom value);
44+
45+
public static TTo Convert(TFrom value)
46+
{
47+
return Instance(value);
48+
}
49+
50+
private static ConvertDelegate CreateConverter()
4451
{
4552
var dMethod = new DynamicMethod($"Converter<{typeof(TFrom).Name},{typeof(TTo).Name}>", typeof(TTo), [typeof(TFrom)], typeof(ConvertDelegate).Module, true);
4653
var il = dMethod.GetILGenerator();
4754
il.Emit(OpCodes.Ldarg_0);
4855
il.Emit(OpCodes.Ret);
49-
_converter = (ConvertDelegate)dMethod.CreateDelegate(typeof(ConvertDelegate));
50-
}
51-
52-
private delegate TTo ConvertDelegate(TFrom value);
53-
54-
public static TTo Convert(TFrom value)
55-
{
56-
return _converter(value);
56+
return (ConvertDelegate)dMethod.CreateDelegate(typeof(ConvertDelegate));
5757
}
5858
}
5959
#endif

src/OpenTelemetry.AutoInstrumentation/CallTarget/Handlers/Continuations/TaskContinuationGenerator`1.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ static TaskContinuationGenerator()
6060

6161
if (previousTask.Status == TaskStatus.RanToCompletion)
6262
{
63+
#pragma warning disable CA1849 // 'Task<TResult>.Result' synchronously blocks. Use await instead. It is fine, as we already checked the task is completed.
6364
taskResult = previousTask.Result;
65+
#pragma warning restore CA1849 // 'Task<TResult>.Result' synchronously blocks. Use await instead. It is fine, as we already checked the task is completed.
6466
}
6567
else if (previousTask.Status == TaskStatus.Faulted)
6668
{

src/OpenTelemetry.AutoInstrumentation/CallTarget/Handlers/Continuations/ValueTaskContinuationGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ static ValueTaskContinuationGenerator()
3535
}
3636

3737
var previousValueTask = FromTReturn<ValueTask>(returnValue);
38-
39-
return ToTReturn(InnerSetValueTaskContinuation(instance, previousValueTask, state));
38+
var continuationValueTask = InnerSetValueTaskContinuation(instance, previousValueTask, state);
39+
return ToTReturn(continuationValueTask);
4040

4141
static async ValueTask InnerSetValueTaskContinuation(TTarget instance, ValueTask previousValueTask, CallTargetState state)
4242
{

src/OpenTelemetry.AutoInstrumentation/CallTarget/Handlers/Continuations/ValueTaskContinuationGenerator`1.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ static ValueTaskContinuationGenerator()
3737
}
3838

3939
var previousValueTask = FromTReturn<ValueTask<TResult>>(returnValue);
40-
return ToTReturn(InnerSetValueTaskContinuation(instance, previousValueTask, state));
40+
var continuationValueTask = InnerSetValueTaskContinuation(instance, previousValueTask, state);
41+
return ToTReturn(continuationValueTask);
4142

4243
static async ValueTask<TResult?> InnerSetValueTaskContinuation(TTarget instance, ValueTask<TResult> previousValueTask, CallTargetState state)
4344
{

src/OpenTelemetry.AutoInstrumentation/CallTarget/Handlers/IntegrationMapper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ internal class IntegrationMapper
180180
}
181181

182182
// Call method
183-
onMethodBeginMethodInfo = onMethodBeginMethodInfo.MakeGenericMethod(callGenericTypes.ToArray());
183+
onMethodBeginMethodInfo = onMethodBeginMethodInfo.MakeGenericMethod([.. callGenericTypes]);
184184
ilWriter.EmitCall(OpCodes.Call, onMethodBeginMethodInfo, null);
185185
ilWriter.Emit(OpCodes.Ret);
186186

@@ -307,7 +307,7 @@ internal class IntegrationMapper
307307
}
308308

309309
// Call method
310-
onMethodBeginMethodInfo = onMethodBeginMethodInfo.MakeGenericMethod(callGenericTypes.ToArray());
310+
onMethodBeginMethodInfo = onMethodBeginMethodInfo.MakeGenericMethod([.. callGenericTypes]);
311311
ilWriter.EmitCall(OpCodes.Call, onMethodBeginMethodInfo, null);
312312
ilWriter.Emit(OpCodes.Ret);
313313

@@ -421,7 +421,7 @@ internal class IntegrationMapper
421421
}
422422

423423
// Call Method
424-
onMethodEndMethodInfo = onMethodEndMethodInfo.MakeGenericMethod(callGenericTypes.ToArray());
424+
onMethodEndMethodInfo = onMethodEndMethodInfo.MakeGenericMethod([.. callGenericTypes]);
425425
ilWriter.EmitCall(OpCodes.Call, onMethodEndMethodInfo, null);
426426

427427
ilWriter.Emit(OpCodes.Ret);
@@ -572,7 +572,7 @@ internal class IntegrationMapper
572572
}
573573

574574
// Call Method
575-
onMethodEndMethodInfo = onMethodEndMethodInfo.MakeGenericMethod(callGenericTypes.ToArray());
575+
onMethodEndMethodInfo = onMethodEndMethodInfo.MakeGenericMethod([.. callGenericTypes]);
576576
ilWriter.EmitCall(OpCodes.Call, onMethodEndMethodInfo, null);
577577

578578
// Unwrap return value proxy
@@ -737,7 +737,7 @@ internal static CreateAsyncEndMethodResult CreateAsyncEndMethodDelegate(Type int
737737
}
738738

739739
// Call Method
740-
onAsyncMethodEndMethodInfo = onAsyncMethodEndMethodInfo.MakeGenericMethod(callGenericTypes.ToArray());
740+
onAsyncMethodEndMethodInfo = onAsyncMethodEndMethodInfo.MakeGenericMethod([.. callGenericTypes]);
741741
ilWriter.EmitCall(OpCodes.Call, onAsyncMethodEndMethodInfo, null);
742742

743743
// Unwrap return value proxy

src/OpenTelemetry.AutoInstrumentation/Configurations/EnvironmentConfigurationMetricHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static MeterProviderBuilder UseEnvironmentVariables(
6767
// Should be called later if dependency listeners are already setup.
6868
builder
6969
.SetExporter(settings, pluginManager)
70-
.AddMeter(settings.Meters.ToArray());
70+
.AddMeter([.. settings.Meters]);
7171

7272
return builder;
7373
}

src/OpenTelemetry.AutoInstrumentation/Configurations/EnvironmentConfigurationSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public EnvironmentConfigurationSource(bool failFast)
2020
{
2121
return Environment.GetEnvironmentVariable(key);
2222
}
23-
catch
23+
catch (Exception)
2424
{
2525
// We should not add a dependency from the Configuration system to the Logger system,
2626
// so do nothing

src/OpenTelemetry.AutoInstrumentation/Configurations/EnvironmentConfigurationTracerHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static TracerProviderBuilder UseEnvironmentVariables(
7373
builder = builder.SetSampler(settings.Sampler);
7474
}
7575

76-
builder = builder.AddSource(settings.ActivitySources.ToArray());
76+
builder = builder.AddSource([.. settings.ActivitySources]);
7777

7878
foreach (var legacySource in settings.AdditionalLegacySources)
7979
{

0 commit comments

Comments
 (0)