From c60dc3697c6e8df703e9a11728e3377f1eaca000 Mon Sep 17 00:00:00 2001 From: Michael Maxwell Date: Mon, 27 Sep 2021 13:07:46 -0400 Subject: [PATCH] Delete unused `using` statements (#2411) --- .editorconfig | 3 +++ build/Common.props | 1 + .../ConsoleMetricExporter.cs | 1 - .../OtlpMetricsExporter.cs | 4 ---- .../PrometheusExporter.cs | 1 - .../PrometheusExporterMiddleware.cs | 4 ++-- .../ActivityHelper.cs | 2 -- .../ScopeManagerShim.cs | 14 ++++++++------ src/OpenTelemetry/Metrics/BatchMetricPoint.cs | 1 - src/OpenTelemetry/Metrics/CompositeMetricReader.cs | 1 - .../Metrics/MeterProviderExtensions.cs | 2 -- src/OpenTelemetry/Metrics/MeterProviderSdk.cs | 1 - src/OpenTelemetry/ProviderExtensions.cs | 1 - .../ActivityHelperTest.cs | 1 - .../MetricTests.cs | 1 - test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs | 2 -- .../Metrics/MetricExporterTests.cs | 2 -- 17 files changed, 14 insertions(+), 28 deletions(-) diff --git a/.editorconfig b/.editorconfig index f5544116c07..b7f6aea985a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -63,6 +63,9 @@ dotnet_naming_symbols.constant_fields.required_modifiers = const [*.cs] dotnet_diagnostic.CA1031.severity = none dotnet_diagnostic.CA1303.severity = none +dotnet_diagnostic.IDE0001.severity = warning +dotnet_diagnostic.IDE0002.severity = warning +dotnet_diagnostic.IDE0005.severity = warning # var preferences csharp_style_var_for_built_in_types = true:silent csharp_style_var_when_type_is_apparent = true:silent diff --git a/build/Common.props b/build/Common.props index b5496a87eef..35a98ded9e9 100644 --- a/build/Common.props +++ b/build/Common.props @@ -5,6 +5,7 @@ $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName) $(MSBuildThisFileDirectory)debug.snk $(DefineConstants);SIGNED + true diff --git a/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs b/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs index cf818e040c8..3b8169dc237 100644 --- a/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs +++ b/src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs @@ -16,7 +16,6 @@ using System; using System.Globalization; -using System.Linq; using System.Text; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricsExporter.cs b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricsExporter.cs index 0048524be07..120acf1ad07 100644 --- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricsExporter.cs +++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpMetricsExporter.cs @@ -17,14 +17,10 @@ using System; using System.Threading.Tasks; using Grpc.Core; -#if NETSTANDARD2_1 -using Grpc.Net.Client; -#endif using OpenTelemetry.Exporter.OpenTelemetryProtocol; using OpenTelemetry.Exporter.OpenTelemetryProtocol.Implementation; using OpenTelemetry.Metrics; using OtlpCollector = Opentelemetry.Proto.Collector.Metrics.V1; -using OtlpResource = Opentelemetry.Proto.Resource.V1; namespace OpenTelemetry.Exporter { diff --git a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs index 4a21d78bc67..d3b8c625632 100644 --- a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs +++ b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporter.cs @@ -15,7 +15,6 @@ // using System; -using System.Collections.Generic; using OpenTelemetry.Metrics; namespace OpenTelemetry.Exporter diff --git a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMiddleware.cs b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMiddleware.cs index 10cb608ee31..c692bc8509e 100644 --- a/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMiddleware.cs +++ b/src/OpenTelemetry.Exporter.Prometheus/PrometheusExporterMiddleware.cs @@ -14,10 +14,10 @@ // limitations under the License. // +#if NETSTANDARD2_0 + using System; using System.Threading.Tasks; - -#if NETSTANDARD2_0 using Microsoft.AspNetCore.Http; namespace OpenTelemetry.Exporter diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs index 984f89dc21b..62bdd71d030 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs @@ -15,11 +15,9 @@ // using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Threading; using System.Web; using OpenTelemetry.Context; using OpenTelemetry.Context.Propagation; diff --git a/src/OpenTelemetry.Shims.OpenTracing/ScopeManagerShim.cs b/src/OpenTelemetry.Shims.OpenTracing/ScopeManagerShim.cs index 507e89a6e29..46673a96b95 100644 --- a/src/OpenTelemetry.Shims.OpenTracing/ScopeManagerShim.cs +++ b/src/OpenTelemetry.Shims.OpenTracing/ScopeManagerShim.cs @@ -16,15 +16,17 @@ using System; using System.Runtime.CompilerServices; +#if DEBUG using System.Threading; -using global::OpenTracing; +#endif using OpenTelemetry.Trace; +using OpenTracing; namespace OpenTelemetry.Shims.OpenTracing { internal sealed class ScopeManagerShim : IScopeManager { - private static readonly ConditionalWeakTable SpanScopeTable = new ConditionalWeakTable(); + private static readonly ConditionalWeakTable SpanScopeTable = new ConditionalWeakTable(); private readonly Tracer tracer; @@ -32,7 +34,7 @@ internal sealed class ScopeManagerShim : IScopeManager private int spanScopeTableCount; #endif - public ScopeManagerShim(Trace.Tracer tracer) + public ScopeManagerShim(Tracer tracer) { this.tracer = tracer ?? throw new ArgumentNullException(nameof(tracer)); } @@ -42,7 +44,7 @@ public ScopeManagerShim(Trace.Tracer tracer) #endif /// - public global::OpenTracing.IScope Active + public IScope Active { get { @@ -62,7 +64,7 @@ public ScopeManagerShim(Trace.Tracer tracer) } /// - public global::OpenTracing.IScope Activate(ISpan span, bool finishSpanOnDispose) + public IScope Activate(ISpan span, bool finishSpanOnDispose) { if (!(span is SpanShim shim)) { @@ -93,7 +95,7 @@ public ScopeManagerShim(Trace.Tracer tracer) return instrumentation; } - private class ScopeInstrumentation : global::OpenTracing.IScope + private class ScopeInstrumentation : IScope { private readonly Action disposeAction; diff --git a/src/OpenTelemetry/Metrics/BatchMetricPoint.cs b/src/OpenTelemetry/Metrics/BatchMetricPoint.cs index 9223d0f49a3..b17f5000ec5 100644 --- a/src/OpenTelemetry/Metrics/BatchMetricPoint.cs +++ b/src/OpenTelemetry/Metrics/BatchMetricPoint.cs @@ -16,7 +16,6 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; namespace OpenTelemetry.Metrics diff --git a/src/OpenTelemetry/Metrics/CompositeMetricReader.cs b/src/OpenTelemetry/Metrics/CompositeMetricReader.cs index f422095e84b..c889bdec0b5 100644 --- a/src/OpenTelemetry/Metrics/CompositeMetricReader.cs +++ b/src/OpenTelemetry/Metrics/CompositeMetricReader.cs @@ -18,7 +18,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Threading; -using OpenTelemetry.Internal; namespace OpenTelemetry.Metrics { diff --git a/src/OpenTelemetry/Metrics/MeterProviderExtensions.cs b/src/OpenTelemetry/Metrics/MeterProviderExtensions.cs index be45f12f7ff..416c611976d 100644 --- a/src/OpenTelemetry/Metrics/MeterProviderExtensions.cs +++ b/src/OpenTelemetry/Metrics/MeterProviderExtensions.cs @@ -15,9 +15,7 @@ // using System; -using System.Diagnostics; using System.Threading; -using OpenTelemetry.Internal; namespace OpenTelemetry.Metrics { diff --git a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs index 88957422a64..6c268b32c0a 100644 --- a/src/OpenTelemetry/Metrics/MeterProviderSdk.cs +++ b/src/OpenTelemetry/Metrics/MeterProviderSdk.cs @@ -15,7 +15,6 @@ // using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics.Metrics; using System.Linq; diff --git a/src/OpenTelemetry/ProviderExtensions.cs b/src/OpenTelemetry/ProviderExtensions.cs index 0b02d42ef7c..fa27126e252 100644 --- a/src/OpenTelemetry/ProviderExtensions.cs +++ b/src/OpenTelemetry/ProviderExtensions.cs @@ -15,7 +15,6 @@ // using System; -using System.Collections.Generic; using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs index c7bb268b80b..5252a04dea6 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs @@ -24,7 +24,6 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests using System.Threading; using System.Threading.Tasks; using System.Web; - using OpenTelemetry.Context; using OpenTelemetry.Context.Propagation; using Xunit; diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs index b71a74b3f78..9f76fe4e6df 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Testing; using OpenTelemetry.Metrics; diff --git a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs b/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs index 7a12642368a..5d615b60311 100644 --- a/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs +++ b/test/OpenTelemetry.Tests/Metrics/AggregatorTest.cs @@ -15,8 +15,6 @@ // using System; -using System.Collections.Generic; -using System.Diagnostics.Metrics; using Xunit; namespace OpenTelemetry.Metrics.Tests diff --git a/test/OpenTelemetry.Tests/Metrics/MetricExporterTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricExporterTests.cs index 8047b0acb73..a1aaf603fec 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricExporterTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricExporterTests.cs @@ -15,8 +15,6 @@ // using System; -using System.Collections.Generic; -using System.Diagnostics.Metrics; using Xunit; namespace OpenTelemetry.Metrics.Tests