Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
update extension methods
  • Loading branch information
rainsxng committed Oct 22, 2025
commit fa5a9b66f661dad48dc6066a58859d26d39f9f48
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
{
try
{
if (requestMessage?.RequestUri == null)
if (requestMessage.RequestUri == null)

Check failure on line 66 in src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs#L66

src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs(66,17): error CA1062: (NETCORE_ENGINEERING_TELEMETRY=Build) In externally visible method 'RequestMetadata? HttpDependencyMetadataResolver.GetRequestMetadata(HttpRequestMessage requestMessage)', validate parameter 'requestMessage' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)

Check failure on line 66 in src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs#L66

src/Libraries/Microsoft.Extensions.Http.Diagnostics/Http/HttpDependencyMetadataResolver.cs(66,17): error CA1062: (NETCORE_ENGINEERING_TELEMETRY=Build) In externally visible method 'RequestMetadata? HttpDependencyMetadataResolver.GetRequestMetadata(HttpRequestMessage requestMessage)', validate parameter 'requestMessage' is non-null before using it. If appropriate, throw an 'ArgumentNullException' when the argument is 'null'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1062)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ public static class HttpDiagnosticsServiceCollectionExtensions
public static IServiceCollection AddDownstreamDependencyMetadata(this IServiceCollection services, IDownstreamDependencyMetadata downstreamDependencyMetadata)
{
_ = Throw.IfNull(services);
_ = Throw.IfNull(downstreamDependencyMetadata);

services.TryAddEnumerable(ServiceDescriptor.Singleton<IDownstreamDependencyMetadata>(downstreamDependencyMetadata));
services.TryAddSingleton<HttpDependencyMetadataResolver, DefaultHttpDependencyMetadataResolver>();
_ = services.AddSingleton(downstreamDependencyMetadata);

return services;
}

Expand All @@ -40,8 +39,8 @@ public static IServiceCollection AddDownstreamDependencyMetadata(this IServiceCo
where T : class, IDownstreamDependencyMetadata
{
_ = Throw.IfNull(services);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IDownstreamDependencyMetadata, T>());
services.TryAddSingleton<HttpDependencyMetadataResolver, DefaultHttpDependencyMetadataResolver>();
_ = services.AddSingleton<IDownstreamDependencyMetadata, T>();
return services;
}

Expand Down
Loading