Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[repo] ProviderBuilderExtensions.Tests - AnalysisLevel latest-all #6156

Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ dotnet_diagnostic.IDE0005.severity = warning
# RS0041: Public members should not use oblivious types
dotnet_diagnostic.RS0041.severity = suggestion

[*Tests.cs]
# CA1515: Disable making types internal for Tests classes. It is required by xunit
dotnet_diagnostic.CA1515.severity = none

[**/obj/**.cs]
generated_code = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OpenTelemetry.Api.ProviderBuilderExtensions.Tests;

public sealed class TestMeterProviderBuilder : MeterProviderBuilder, IMeterProviderBuilder, IDisposable
internal sealed class TestMeterProviderBuilder : MeterProviderBuilder, IMeterProviderBuilder, IDisposable
{
public TestMeterProviderBuilder()
{
Expand All @@ -17,9 +17,9 @@ public TestMeterProviderBuilder()

public ServiceProvider? ServiceProvider { get; private set; }

public List<string> Meters { get; } = new();
public List<string> Meters { get; } = [];

public List<object> Instrumentation { get; } = new();
public List<object> Instrumentation { get; } = [];

public MeterProvider? Provider { get; private set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Unit test project for OpenTelemetry .NET dependency injection extensions</Description>
<TargetFrameworks>$(TargetFrameworksForTests)</TargetFrameworks>
<AnalysisLevel>latest-all</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ConfigureOpenTelemetryTracerProvider(int numberOfCalls)

using var serviceProvider = services.BuildServiceProvider();

var registrations = serviceProvider.GetServices<IConfigureTracerProviderBuilder>();
var registrations = serviceProvider.GetServices<IConfigureTracerProviderBuilder>().ToArray();

Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(0, afterServiceProviderInvocations);
Expand All @@ -43,7 +43,7 @@ public void ConfigureOpenTelemetryTracerProvider(int numberOfCalls)
Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(numberOfCalls, afterServiceProviderInvocations);

Assert.Equal(numberOfCalls * 2, registrations.Count());
Assert.Equal(numberOfCalls * 2, registrations.Length);
}

[Theory]
Expand All @@ -65,7 +65,7 @@ public void ConfigureOpenTelemetryMeterProvider(int numberOfCalls)

using var serviceProvider = services.BuildServiceProvider();

var registrations = serviceProvider.GetServices<IConfigureMeterProviderBuilder>();
var registrations = serviceProvider.GetServices<IConfigureMeterProviderBuilder>().ToArray();

Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(0, afterServiceProviderInvocations);
Expand All @@ -78,7 +78,7 @@ public void ConfigureOpenTelemetryMeterProvider(int numberOfCalls)
Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(numberOfCalls, afterServiceProviderInvocations);

Assert.Equal(numberOfCalls * 2, registrations.Count());
Assert.Equal(numberOfCalls * 2, registrations.Length);
}

[Theory]
Expand All @@ -100,7 +100,7 @@ public void ConfigureOpenTelemetryLoggerProvider(int numberOfCalls)

using var serviceProvider = services.BuildServiceProvider();

var registrations = serviceProvider.GetServices<IConfigureLoggerProviderBuilder>();
var registrations = serviceProvider.GetServices<IConfigureLoggerProviderBuilder>().ToArray();

Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(0, afterServiceProviderInvocations);
Expand All @@ -113,6 +113,6 @@ public void ConfigureOpenTelemetryLoggerProvider(int numberOfCalls)
Assert.Equal(numberOfCalls, beforeServiceProviderInvocations);
Assert.Equal(numberOfCalls, afterServiceProviderInvocations);

Assert.Equal(numberOfCalls * 2, registrations.Count());
Assert.Equal(numberOfCalls * 2, registrations.Length);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace OpenTelemetry.Api.ProviderBuilderExtensions.Tests;

public sealed class TestTracerProviderBuilder : TracerProviderBuilder, ITracerProviderBuilder, IDisposable
internal sealed class TestTracerProviderBuilder : TracerProviderBuilder, ITracerProviderBuilder, IDisposable
{
public TestTracerProviderBuilder()
{
Expand All @@ -17,11 +17,11 @@ public TestTracerProviderBuilder()

public ServiceProvider? ServiceProvider { get; private set; }

public List<string> Sources { get; } = new();
public List<string> Sources { get; } = [];

public List<string> LegacySources { get; } = new();
public List<string> LegacySources { get; } = [];

public List<object> Instrumentation { get; } = new();
public List<object> Instrumentation { get; } = [];

public TracerProvider? Provider { get; private set; }

Expand Down
Loading