From 71e6cb49aa9bcf99baaf53064e00fe55d1a88660 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Wed, 26 Feb 2025 05:00:09 +1100 Subject: [PATCH] use some collection expressions (#6106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Piotr Kiełkowicz Co-authored-by: Rajkumar Rangaraj --- docs/metrics/customizing-the-sdk/Program.cs | 6 +- .../Controllers/WeatherForecastController.cs | 8 +- examples/Console/TestPrometheusExporter.cs | 2 +- .../Context/Propagation/B3Propagator.cs | 2 +- .../Context/Propagation/BaggagePropagator.cs | 4 +- .../Logs/LogRecordSeverityExtensions.cs | 8 +- .../OtlpExporterOptionsExtensions.cs | 6 +- .../PrometheusHttpListenerOptions.cs | 2 +- .../ZipkinExporterHelperExtensions.cs | 2 +- .../B3Propagator.cs | 2 +- .../JaegerPropagator.cs | 2 +- .../TracerShim.cs | 2 +- src/Shared/MathHelper.cs | 8 +- src/Shared/Shims/NullableAttributes.cs | 2 +- test/Benchmarks/Metrics/ExemplarBenchmarks.cs | 4 +- .../Benchmarks/Metrics/HistogramBenchmarks.cs | 2 +- .../Metrics/MetricCollectBenchmarks.cs | 2 +- test/Benchmarks/Metrics/MetricsBenchmarks.cs | 2 +- .../Metrics/MetricsViewBenchmarks.cs | 6 +- .../Propagation/CompositePropagatorTest.cs | 2 +- .../Trace/SpanAttributesTest.cs | 8 +- .../ConsoleActivityExporterTest.cs | 2 +- .../OtlpLogExporterTests.cs | 4 +- .../PrometheusHttpListenerTests.cs | 8 +- ...nTelemetryMetricsBuilderExtensionsTests.cs | 4 +- .../JaegerPropagatorTest.cs | 4 +- .../Program.cs | 6 +- test/OpenTelemetry.Tests.Stress/StressTest.cs | 2 +- .../Metrics/MetricExemplarTests.cs | 12 +-- .../Metrics/MetricTestData.cs | 4 +- .../Metrics/MetricViewTests.cs | 28 +++---- .../Trace/CompositeActivityProcessorTests.cs | 12 +-- test/OpenTelemetry.Tests/Trace/LinkTest.cs | 8 +- .../Propagation/TraceContextPropagatorTest.cs | 18 ++--- .../Trace/TraceIdRatioBasedSamplerTest.cs | 74 +++++++++---------- .../Controllers/ValuesController.cs | 2 +- 36 files changed, 134 insertions(+), 136 deletions(-) diff --git a/docs/metrics/customizing-the-sdk/Program.cs b/docs/metrics/customizing-the-sdk/Program.cs index bbfd4bea9..9d6fb7e54 100644 --- a/docs/metrics/customizing-the-sdk/Program.cs +++ b/docs/metrics/customizing-the-sdk/Program.cs @@ -29,19 +29,19 @@ public class Program .AddView(instrumentName: "MyCounter", name: "MyCounterRenamed") // Change Histogram boundaries using the Explicit Bucket Histogram aggregation. - .AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } }) + .AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] }) // Change Histogram to use the Base2 Exponential Bucket Histogram aggregation. .AddView(instrumentName: "MyExponentialBucketHistogram", new Base2ExponentialBucketHistogramConfiguration()) // For the instrument "MyCounterCustomTags", aggregate with only the keys "tag1", "tag2". - .AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = new string[] { "tag1", "tag2" } }) + .AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = ["tag1", "tag2"] }) // Drop the instrument "MyCounterDrop". .AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop) // Configure the Explicit Bucket Histogram aggregation with custom boundaries and new name. - .AddView(instrumentName: "histogramWithMultipleAggregations", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 }, Name = "MyHistogramWithExplicitHistogram" }) + .AddView(instrumentName: "histogramWithMultipleAggregations", new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], Name = "MyHistogramWithExplicitHistogram" }) // Use Base2 Exponential Bucket Histogram aggregation and new name. .AddView(instrumentName: "histogramWithMultipleAggregations", new Base2ExponentialBucketHistogramConfiguration() { Name = "MyHistogramWithBase2ExponentialBucketHistogram" }) diff --git a/examples/AspNetCore/Controllers/WeatherForecastController.cs b/examples/AspNetCore/Controllers/WeatherForecastController.cs index 3d09fe9ed..44b8b30cb 100644 --- a/examples/AspNetCore/Controllers/WeatherForecastController.cs +++ b/examples/AspNetCore/Controllers/WeatherForecastController.cs @@ -12,10 +12,10 @@ using Microsoft.AspNetCore.Mvc; [Route("[controller]")] public class WeatherForecastController : ControllerBase { - private static readonly string[] Summaries = new[] - { - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching", - }; + private static readonly string[] Summaries = + [ + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + ]; private static readonly HttpClient HttpClient = new(); diff --git a/examples/Console/TestPrometheusExporter.cs b/examples/Console/TestPrometheusExporter.cs index a6bc1888f..02a313005 100644 --- a/examples/Console/TestPrometheusExporter.cs +++ b/examples/Console/TestPrometheusExporter.cs @@ -35,7 +35,7 @@ internal class TestPrometheusExporter .AddMeter(MyMeter.Name) .AddMeter(MyMeter2.Name) .AddPrometheusHttpListener( - o => o.UriPrefixes = new string[] { $"http://localhost:{options.Port}/" }) + o => o.UriPrefixes = [$"http://localhost:{options.Port}/"]) .Build(); var process = Process.GetCurrentProcess(); diff --git a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs index 182761721..6e3ac7450 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs @@ -35,7 +35,7 @@ public sealed class B3Propagator : TextMapPropagator // "Debug" sampled value. internal const string FlagsValue = "1"; - private static readonly HashSet AllFields = new() { XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags }; + private static readonly HashSet AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags]; private static readonly HashSet SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue }; diff --git a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs index 938980931..927ee78b6 100644 --- a/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs +++ b/src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs @@ -20,8 +20,8 @@ public class BaggagePropagator : TextMapPropagator private const int MaxBaggageLength = 8192; private const int MaxBaggageItems = 180; - private static readonly char[] EqualSignSeparator = new[] { '=' }; - private static readonly char[] CommaSignSeparator = new[] { ',' }; + private static readonly char[] EqualSignSeparator = ['=']; + private static readonly char[] CommaSignSeparator = [',']; /// public override ISet Fields => new HashSet { BaggageHeaderName }; diff --git a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs index 81453d030..6ca5e1bc2 100644 --- a/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs +++ b/src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs @@ -57,8 +57,8 @@ internal internal const string Fatal3ShortName = FatalShortName + "3"; internal const string Fatal4ShortName = FatalShortName + "4"; - private static readonly string[] LogRecordSeverityShortNames = new string[] - { + private static readonly string[] LogRecordSeverityShortNames = + [ UnspecifiedShortName, TraceShortName, @@ -89,8 +89,8 @@ internal FatalShortName, Fatal2ShortName, Fatal3ShortName, - Fatal4ShortName, - }; + Fatal4ShortName + ]; /// /// Returns the OpenTelemetry Specification short name for the uriPrefixes = new[] { "http://localhost:9464/" }; + private IReadOnlyCollection uriPrefixes = ["http://localhost:9464/"]; /// /// Gets or sets the path to use for the scraping endpoint. Default value: "/metrics". diff --git a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterHelperExtensions.cs b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterHelperExtensions.cs index b7142b985..f29315a3f 100644 --- a/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterHelperExtensions.cs +++ b/src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterHelperExtensions.cs @@ -91,7 +91,7 @@ public static class ZipkinExporterHelperExtensions "CreateClient", BindingFlags.Public | BindingFlags.Instance, binder: null, - new Type[] { typeof(string) }, + [typeof(string)], modifiers: null); if (createClientMethod != null) { diff --git a/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs b/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs index 837b83dab..d90d3d369 100644 --- a/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs +++ b/src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs @@ -35,7 +35,7 @@ public sealed class B3Propagator : TextMapPropagator // "Debug" sampled value. internal const string FlagsValue = "1"; - private static readonly HashSet AllFields = new() { XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags }; + private static readonly HashSet AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags]; private static readonly HashSet SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue }; diff --git a/src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs b/src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs index 15ff69ce1..492c016b2 100644 --- a/src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs +++ b/src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs @@ -17,7 +17,7 @@ public class JaegerPropagator : TextMapPropagator internal const string JaegerDelimiterEncoded = "%3A"; // while the spec defines the delimiter as a ':', some clients will url encode headers. internal const string SampledValue = "1"; - internal static readonly string[] JaegerDelimiters = { JaegerDelimiter, JaegerDelimiterEncoded }; + internal static readonly string[] JaegerDelimiters = [JaegerDelimiter, JaegerDelimiterEncoded]; private static readonly int TraceId128BitLength = "0af7651916cd43dd8448eb211c80319c".Length; private static readonly int SpanIdLength = "00f067aa0ba902b7".Length; diff --git a/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs b/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs index 504b28c5a..cbdbd9dfc 100644 --- a/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs +++ b/src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs @@ -76,7 +76,7 @@ public class TracerShim : global::OpenTracing.ITracer foreach (var entry in textMapCarrier) { - carrierMap.Add(entry.Key, new[] { entry.Value }); + carrierMap.Add(entry.Key, [entry.Value]); } static IEnumerable? GetCarrierKeyValue(Dictionary> source, string key) diff --git a/src/Shared/MathHelper.cs b/src/Shared/MathHelper.cs index 21367918d..bb6edaa00 100644 --- a/src/Shared/MathHelper.cs +++ b/src/Shared/MathHelper.cs @@ -12,8 +12,8 @@ namespace OpenTelemetry.Internal; internal static class MathHelper { // https://en.wikipedia.org/wiki/Leading_zero - private static readonly byte[] LeadingZeroLookupTable = new byte[] - { + private static readonly byte[] LeadingZeroLookupTable = + [ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -29,8 +29,8 @@ internal static class MathHelper 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - }; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ]; [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int LeadingZero8(byte value) diff --git a/src/Shared/Shims/NullableAttributes.cs b/src/Shared/Shims/NullableAttributes.cs index 3126b5576..a5f776258 100644 --- a/src/Shared/Shims/NullableAttributes.cs +++ b/src/Shared/Shims/NullableAttributes.cs @@ -51,7 +51,7 @@ namespace System.Diagnostics.CodeAnalysis public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; - Members = new[] { member }; + Members = [member]; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) diff --git a/test/Benchmarks/Metrics/ExemplarBenchmarks.cs b/test/Benchmarks/Metrics/ExemplarBenchmarks.cs index d9369d26e..08592d5bc 100644 --- a/test/Benchmarks/Metrics/ExemplarBenchmarks.cs +++ b/test/Benchmarks/Metrics/ExemplarBenchmarks.cs @@ -41,7 +41,7 @@ namespace Benchmarks.Metrics; public class ExemplarBenchmarks { private static readonly ThreadLocal ThreadLocalRandom = new(() => new Random()); - private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" }; + private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"]; private Histogram? histogramWithoutTagReduction; private Histogram? histogramWithTagReduction; private Counter? counterWithoutTagReduction; @@ -86,7 +86,7 @@ public class ExemplarBenchmarks { return new MetricStreamConfiguration() { - TagKeys = new string[] { "DimName1", "DimName2", "DimName3" }, + TagKeys = ["DimName1", "DimName2", "DimName3"], ExemplarReservoirFactory = CreateExemplarReservoir, }; } diff --git a/test/Benchmarks/Metrics/HistogramBenchmarks.cs b/test/Benchmarks/Metrics/HistogramBenchmarks.cs index e30ae2ffa..acfca3e03 100644 --- a/test/Benchmarks/Metrics/HistogramBenchmarks.cs +++ b/test/Benchmarks/Metrics/HistogramBenchmarks.cs @@ -46,7 +46,7 @@ public class HistogramBenchmarks { private const int MaxValue = 10000; private readonly Random random = new(); - private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" }; + private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"]; private Histogram? histogram; private MeterProvider? meterProvider; private Meter? meter; diff --git a/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs b/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs index ac3f0cf20..2f236e509 100644 --- a/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricCollectBenchmarks.cs @@ -25,7 +25,7 @@ namespace Benchmarks.Metrics; public class MetricCollectBenchmarks { - private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" }; + private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"]; // TODO: Confirm if this needs to be thread-safe private readonly Random random = new(); diff --git a/test/Benchmarks/Metrics/MetricsBenchmarks.cs b/test/Benchmarks/Metrics/MetricsBenchmarks.cs index 117bf59a5..f745a7e34 100644 --- a/test/Benchmarks/Metrics/MetricsBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsBenchmarks.cs @@ -59,7 +59,7 @@ namespace Benchmarks.Metrics; public class MetricsBenchmarks { private readonly Random random = new(); - private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" }; + private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"]; private Counter? counter; private MeterProvider? meterProvider; private Meter? meter; diff --git a/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs b/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs index ce9cb40b6..9d40078d9 100644 --- a/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs +++ b/test/Benchmarks/Metrics/MetricsViewBenchmarks.cs @@ -30,7 +30,7 @@ namespace Benchmarks.Metrics; public class MetricsViewBenchmarks { private static readonly ThreadLocal ThreadLocalRandom = new(() => new Random()); - private static readonly string[] DimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" }; + private static readonly string[] DimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"]; private static readonly int DimensionsValuesLength = DimensionValues.Length; private List? metrics; private Counter? counter; @@ -96,7 +96,7 @@ public class MetricsViewBenchmarks { this.meterProvider = Sdk.CreateMeterProviderBuilder() .AddMeter(this.meter.Name) - .AddView("nomatch", new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } }) + .AddView("nomatch", new MetricStreamConfiguration() { TagKeys = ["DimName1", "DimName2", "DimName3"] }) .AddInMemoryExporter(this.metrics) .Build(); } @@ -104,7 +104,7 @@ public class MetricsViewBenchmarks { this.meterProvider = Sdk.CreateMeterProviderBuilder() .AddMeter(this.meter.Name) - .AddView(this.counter.Name, new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } }) + .AddView(this.counter.Name, new MetricStreamConfiguration() { TagKeys = ["DimName1", "DimName2", "DimName3"] }) .AddInMemoryExporter(this.metrics) .Build(); } diff --git a/test/OpenTelemetry.Api.Tests/Context/Propagation/CompositePropagatorTest.cs b/test/OpenTelemetry.Api.Tests/Context/Propagation/CompositePropagatorTest.cs index b70565aff..4c3e64c37 100644 --- a/test/OpenTelemetry.Api.Tests/Context/Propagation/CompositePropagatorTest.cs +++ b/test/OpenTelemetry.Api.Tests/Context/Propagation/CompositePropagatorTest.cs @@ -14,7 +14,7 @@ public class CompositePropagatorTest count++; if (headers.TryGetValue(name, out var value)) { - return new[] { value }; + return [value]; } return Empty; diff --git a/test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs b/test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs index abf35e393..3e327551b 100644 --- a/test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs +++ b/test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs @@ -19,16 +19,16 @@ public class SpanAttributesTest { var spanAttribute = new SpanAttributes(); spanAttribute.Add("key_string", "string"); - spanAttribute.Add("key_a_string", new string[] { "string" }); + spanAttribute.Add("key_a_string", ["string"]); spanAttribute.Add("key_double", 1.01); - spanAttribute.Add("key_a_double", new double[] { 1.01 }); + spanAttribute.Add("key_a_double", [1.01]); spanAttribute.Add("key_bool", true); - spanAttribute.Add("key_a_bool", new bool[] { true }); + spanAttribute.Add("key_a_bool", [true]); spanAttribute.Add("key_long", 1); - spanAttribute.Add("key_a_long", new long[] { 1 }); + spanAttribute.Add("key_a_long", [1L]); Assert.Equal(8, spanAttribute.Attributes.Count); } diff --git a/test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs b/test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs index e3305513d..205b98d57 100644 --- a/test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs +++ b/test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs @@ -43,6 +43,6 @@ public class ConsoleActivityExporterTest // Test that the ConsoleExporter correctly handles an Activity without Tags. using var consoleExporter = new ConsoleActivityExporter(new ConsoleExporterOptions()); - Assert.Equal(ExportResult.Success, consoleExporter.Export(new Batch(new[] { activity }, 1))); + Assert.Equal(ExportResult.Success, consoleExporter.Export(new Batch([activity], 1))); } } diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs index 9d14aafef..368ddbf1e 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpLogExporterTests.cs @@ -1449,7 +1449,7 @@ public class OtlpLogExporterTests Assert.Single(logRecords); - var batch = new Batch(new[] { logRecords[0] }, 1); + var batch = new Batch([logRecords[0]], 1); OtlpCollector.ExportLogsServiceRequest request = CreateLogsExportRequest(DefaultSdkLimitOptions, new ExperimentalOptions(), batch, ResourceBuilder.CreateEmpty().Build()); Assert.NotNull(request); @@ -1480,7 +1480,7 @@ public class OtlpLogExporterTests Assert.Single(logRecords); - var batch = new Batch(new[] { logRecords[0] }, 1); + var batch = new Batch([logRecords[0]], 1); var buffer = new byte[50]; var writePosition = ProtobufOtlpLogSerializer.WriteLogsData(ref buffer, 0, DefaultSdkLimitOptions, new(), ResourceBuilder.CreateEmpty().Build(), batch); diff --git a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs index b9b620118..0ac04d2f2 100644 --- a/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs +++ b/test/OpenTelemetry.Exporter.Prometheus.HttpListener.Tests/PrometheusHttpListenerTests.cs @@ -56,7 +56,7 @@ public class PrometheusHttpListenerTests { Assert.Throws(() => { - TestPrometheusHttpListenerUriPrefixOptions(new string[] { "ftp://example.com" }); + TestPrometheusHttpListenerUriPrefixOptions(["ftp://example.com"]); }); } @@ -132,7 +132,7 @@ public class PrometheusHttpListenerTests exporter, new() { - UriPrefixes = new string[] { address }, + UriPrefixes = [address], }); listener.Start(); @@ -158,7 +158,7 @@ public class PrometheusHttpListenerTests exporter, new() { - UriPrefixes = new string[] { address! }, + UriPrefixes = [address!], }); listener.Start(); @@ -238,7 +238,7 @@ public class PrometheusHttpListenerTests .ConfigureResource(x => x.Clear().AddService("my_service", serviceInstanceId: "id1").AddAttributes(attributes)) .AddPrometheusHttpListener(options => { - options.UriPrefixes = new string[] { generatedAddress }; + options.UriPrefixes = [generatedAddress]; }) .Build(); diff --git a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryMetricsBuilderExtensionsTests.cs b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryMetricsBuilderExtensionsTests.cs index d34dc060f..74fe338a8 100644 --- a/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryMetricsBuilderExtensionsTests.cs +++ b/test/OpenTelemetry.Extensions.Hosting.Tests/OpenTelemetryMetricsBuilderExtensionsTests.cs @@ -75,7 +75,7 @@ public class OpenTelemetryMetricsBuilderExtensionsTests var source = new MemoryConfigurationSource(); var memory = new MemoryConfigurationProvider(source); - var configuration = new ConfigurationRoot(new[] { memory }); + var configuration = new ConfigurationRoot([memory]); using var host = MetricTestsBase.BuildHost( useWithMetricsStyle, @@ -167,7 +167,7 @@ public class OpenTelemetryMetricsBuilderExtensionsTests var source = new MemoryConfigurationSource(); var memory = new MemoryConfigurationProvider(source); memory.Set($"Metrics:EnabledMetrics:{meter.Name}:Default", "true"); - var configuration = new ConfigurationRoot(new[] { memory }); + var configuration = new ConfigurationRoot([memory]); using var host = MetricTestsBase.BuildHost( useWithMetricsStyle, diff --git a/test/OpenTelemetry.Extensions.Propagators.Tests/JaegerPropagatorTest.cs b/test/OpenTelemetry.Extensions.Propagators.Tests/JaegerPropagatorTest.cs index 4e2b0486f..79a7b90af 100644 --- a/test/OpenTelemetry.Extensions.Propagators.Tests/JaegerPropagatorTest.cs +++ b/test/OpenTelemetry.Extensions.Propagators.Tests/JaegerPropagatorTest.cs @@ -104,7 +104,7 @@ public class JaegerPropagatorTest parentSpanId, flags); - var headers = new Dictionary { { JaegerHeader, new[] { formattedHeader } } }; + var headers = new Dictionary { { JaegerHeader, [formattedHeader] } }; // act var result = new JaegerPropagator().Extract(propagationContext, headers, Getter); @@ -128,7 +128,7 @@ public class JaegerPropagatorTest parentSpanId, flags); - var headers = new Dictionary { { JaegerHeader, new[] { formattedHeader } } }; + var headers = new Dictionary { { JaegerHeader, [formattedHeader] } }; // act var result = new JaegerPropagator().Extract(propagationContext, headers, Getter); diff --git a/test/OpenTelemetry.Tests.Stress.Metrics/Program.cs b/test/OpenTelemetry.Tests.Stress.Metrics/Program.cs index 132993b04..bcf698f72 100644 --- a/test/OpenTelemetry.Tests.Stress.Metrics/Program.cs +++ b/test/OpenTelemetry.Tests.Stress.Metrics/Program.cs @@ -51,7 +51,7 @@ public static class Program if (options.PrometheusTestMetricsPort != 0) { - builder.AddPrometheusHttpListener(o => o.UriPrefixes = new string[] { $"http://localhost:{options.PrometheusTestMetricsPort}/" }); + builder.AddPrometheusHttpListener(o => o.UriPrefixes = [$"http://localhost:{options.PrometheusTestMetricsPort}/"]); } if (options.EnableExemplars) @@ -62,8 +62,8 @@ public static class Program if (options.AddViewToFilterTags) { builder - .AddView("TestCounter", new MetricStreamConfiguration { TagKeys = new string[] { "DimName1" } }) - .AddView("TestHistogram", new MetricStreamConfiguration { TagKeys = new string[] { "DimName1" } }); + .AddView("TestCounter", new MetricStreamConfiguration { TagKeys = ["DimName1"] }) + .AddView("TestHistogram", new MetricStreamConfiguration { TagKeys = ["DimName1"] }); } if (options.AddOtlpExporter) diff --git a/test/OpenTelemetry.Tests.Stress/StressTest.cs b/test/OpenTelemetry.Tests.Stress/StressTest.cs index 036627d21..01e679a3e 100644 --- a/test/OpenTelemetry.Tests.Stress/StressTest.cs +++ b/test/OpenTelemetry.Tests.Stress/StressTest.cs @@ -69,7 +69,7 @@ public abstract class StressTest : IDisposable using var meterProvider = options.PrometheusInternalMetricsPort != 0 ? Sdk.CreateMeterProviderBuilder() .AddMeter(meter.Name) .AddRuntimeInstrumentation() - .AddPrometheusHttpListener(o => o.UriPrefixes = new string[] { $"http://localhost:{options.PrometheusInternalMetricsPort}/" }) + .AddPrometheusHttpListener(o => o.UriPrefixes = [$"http://localhost:{options.PrometheusInternalMetricsPort}/"]) .Build() : null; var statistics = new MeasurementData[options.Concurrency]; diff --git a/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs index b6122c970..5dff417c2 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs @@ -184,11 +184,11 @@ public class MetricExemplarTests : MetricTestsBase DateTime testStartTime = DateTime.UtcNow; var exportedItems = new List(); - (double Value, bool ExpectTraceId)[] measurementValues = new (double Value, bool ExpectTraceId)[] - { + (double Value, bool ExpectTraceId)[] measurementValues = + [ (18D, false), - (19D, false), - }; + (19D, false) + ]; int measurementIndex = 0; @@ -329,7 +329,7 @@ public class MetricExemplarTests : MetricTestsBase var measurementValues = buckets /* 2000 is here to test overflow measurement */ - .Concat(new double[] { 2000 }) + .Concat([2000.0]) .Select(b => (Value: b, ExpectTraceId: false)) .ToArray(); foreach (var value in measurementValues) @@ -734,7 +734,7 @@ public class MetricExemplarTests : MetricTestsBase histogram.Name, new MetricStreamConfiguration() { - TagKeys = enableTagFiltering ? new string[] { "key1" } : null, + TagKeys = enableTagFiltering ? ["key1"] : null, ExemplarReservoirFactory = () => { if (testExemplarReservoir != null) diff --git a/test/OpenTelemetry.Tests/Metrics/MetricTestData.cs b/test/OpenTelemetry.Tests/Metrics/MetricTestData.cs index 669212a10..76084371c 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricTestData.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricTestData.cs @@ -45,7 +45,7 @@ public class MetricTestData new object[] { new double[] { double.NegativeInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.NegativeInfinity }, new object[] { new double[] { double.NegativeInfinity, 0, double.PositiveInfinity }, new HistogramConfiguration(), double.NegativeInfinity, double.PositiveInfinity }, new object[] { new double[] { 1 }, new HistogramConfiguration(), 1, 1 }, - new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } }, -2, 101 }, + new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] }, -2, 101 }, new object[] { new double[] { 5, 100, 4, 101, -2, 97 }, new Base2ExponentialBucketHistogramConfiguration(), 4, 101 }, }; @@ -53,7 +53,7 @@ public class MetricTestData => new List { new object[] { new double[] { 1 }, new HistogramConfiguration() { RecordMinMax = false } }, - new object[] { new double[] { 1 }, new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 }, RecordMinMax = false } }, + new object[] { new double[] { 1 }, new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], RecordMinMax = false } }, new object[] { new double[] { 1 }, new Base2ExponentialBucketHistogramConfiguration() { RecordMinMax = false } }, }; } diff --git a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs index 109c68ace..26506edf9 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs @@ -559,7 +559,7 @@ public class MetricViewTests : MetricTestsBase index = 0; actualCount = 0; - expectedBucketCounts = new long[] { 5, 2, 0 }; + expectedBucketCounts = [5, 2, 0]; foreach (var histogramMeasurement in histogramPoint.GetHistogramBuckets()) { Assert.Equal(expectedBucketCounts[index], histogramMeasurement.BucketCount); @@ -652,7 +652,7 @@ public class MetricViewTests : MetricTestsBase var index = 0; var actualCount = 0; - long[] expectedBucketCounts = new long[] { 2, 1, 0 }; + long[] expectedBucketCounts = [2, 1, 0]; foreach (var histogramMeasurement in histogramPoint.GetHistogramBuckets()) { @@ -673,7 +673,7 @@ public class MetricViewTests : MetricTestsBase using var meter = new Meter(Utils.GetCurrentMethodName()); var exportedItems = new List(); IReadOnlyList adviceBoundaries = new List() { 5, 10, 20 }; - double[] viewBoundaries = new double[] { 10, 20 }; + double[] viewBoundaries = [10, 20]; using var container = this.BuildMeterProvider(out var meterProvider, builder => { @@ -729,7 +729,7 @@ public class MetricViewTests : MetricTestsBase var index = 0; var actualCount = 0; - long[] expectedBucketCounts = useViewToOverride ? new long[] { 5, 2, 1 } : new long[] { 3, 2, 2, 1 }; + long[] expectedBucketCounts = useViewToOverride ? [5, 2, 1] : [3, 2, 2, 1]; foreach (var histogramMeasurement in histogramPoint.GetHistogramBuckets()) { @@ -867,12 +867,12 @@ public class MetricViewTests : MetricTestsBase .AddMeter(meter.Name) .AddView("FruitCounter", new MetricStreamConfiguration() { - TagKeys = new string[] { "name" }, + TagKeys = ["name"], Name = "NameOnly", }) .AddView("FruitCounter", new MetricStreamConfiguration() { - TagKeys = new string[] { "size" }, + TagKeys = ["size"], Name = "SizeOnly", }) .AddView("FruitCounter", new MetricStreamConfiguration() @@ -1222,11 +1222,11 @@ public class MetricViewTests : MetricTestsBase .AddMeter(meter.Name) .AddView((instrument) => { - return new MetricStreamConfiguration { TagKeys = new[] { "key1" } }; + return new MetricStreamConfiguration { TagKeys = ["key1"] }; }) .AddView((instrument) => { - return new MetricStreamConfiguration { TagKeys = new[] { "key2" } }; + return new MetricStreamConfiguration { TagKeys = ["key2"] }; }) .AddInMemoryExporter(exportedItems)); @@ -1269,11 +1269,11 @@ public class MetricViewTests : MetricTestsBase .AddMeter(meter.Name) .AddView((instrument) => { - return new MetricStreamConfiguration { TagKeys = new[] { "key1" } }; + return new MetricStreamConfiguration { TagKeys = ["key1"] }; }) .AddView((instrument) => { - return new MetricStreamConfiguration { TagKeys = new[] { "key1" } }; + return new MetricStreamConfiguration { TagKeys = ["key1"] }; }) .AddInMemoryExporter(exportedItems)); @@ -1317,11 +1317,11 @@ public class MetricViewTests : MetricTestsBase .AddMeter(meter.Name) .AddView((instrument) => { - return new ExplicitBucketHistogramConfiguration { Boundaries = new[] { 5.0, 10.0 } }; + return new ExplicitBucketHistogramConfiguration { Boundaries = [5.0, 10.0] }; }) .AddView((instrument) => { - return new ExplicitBucketHistogramConfiguration { Boundaries = new[] { 10.0, 20.0 } }; + return new ExplicitBucketHistogramConfiguration { Boundaries = [10.0, 20.0] }; }) .AddInMemoryExporter(exportedItems)); @@ -1374,7 +1374,7 @@ public class MetricViewTests : MetricTestsBase index = 0; actualCount = 0; - expectedBucketCounts = new long[] { 0, 2, 0 }; + expectedBucketCounts = [0, 2, 0]; foreach (var histogramMeasurement in metricPoint.GetHistogramBuckets()) { Assert.Equal(expectedBucketCounts[index], histogramMeasurement.BucketCount); @@ -1396,7 +1396,7 @@ public class MetricViewTests : MetricTestsBase { if (instrument.Name == "name") { - return new MetricStreamConfiguration { Name = "othername", TagKeys = new[] { "key1" } }; + return new MetricStreamConfiguration { Name = "othername", TagKeys = ["key1"] }; } else { diff --git a/test/OpenTelemetry.Tests/Trace/CompositeActivityProcessorTests.cs b/test/OpenTelemetry.Tests/Trace/CompositeActivityProcessorTests.cs index 343bfa6ee..78f53a267 100644 --- a/test/OpenTelemetry.Tests/Trace/CompositeActivityProcessorTests.cs +++ b/test/OpenTelemetry.Tests/Trace/CompositeActivityProcessorTests.cs @@ -16,7 +16,7 @@ public class CompositeActivityProcessorTests Assert.Throws(() => new CompositeProcessor(Array.Empty>())); using var p1 = new TestActivityProcessor(null, null); - using var processor = new CompositeProcessor(new[] { p1 }); + using var processor = new CompositeProcessor([p1]); Assert.Throws(() => processor.AddProcessor(null!)); } @@ -34,7 +34,7 @@ public class CompositeActivityProcessorTests using var activity = new Activity("test"); - using (var processor = new CompositeProcessor(new[] { p1, p2 })) + using (var processor = new CompositeProcessor([p1, p2])) { processor.OnStart(activity); processor.OnEnd(activity); @@ -52,7 +52,7 @@ public class CompositeActivityProcessorTests using var activity = new Activity("test"); - using var processor = new CompositeProcessor(new[] { p1 }); + using var processor = new CompositeProcessor([p1]); Assert.Throws(() => { processor.OnStart(activity); }); Assert.Throws(() => { processor.OnEnd(activity); }); } @@ -63,7 +63,7 @@ public class CompositeActivityProcessorTests using var p1 = new TestActivityProcessor(null, null); using var p2 = new TestActivityProcessor(null, null); - using var processor = new CompositeProcessor(new[] { p1, p2 }); + using var processor = new CompositeProcessor([p1, p2]); processor.Shutdown(); Assert.True(p1.ShutdownCalled); Assert.True(p2.ShutdownCalled); @@ -78,7 +78,7 @@ public class CompositeActivityProcessorTests using var p1 = new TestActivityProcessor(null, null); using var p2 = new TestActivityProcessor(null, null); - using var processor = new CompositeProcessor(new[] { p1, p2 }); + using var processor = new CompositeProcessor([p1, p2]); processor.ForceFlush(timeout); Assert.True(p1.ForceFlushCalled); @@ -93,7 +93,7 @@ public class CompositeActivityProcessorTests using var p1 = new TestActivityProcessor(null, null); using var p2 = new TestActivityProcessor(null, null); - using var processor = new CompositeProcessor(new[] { p1, p2 }); + using var processor = new CompositeProcessor([p1, p2]); Assert.Null(processor.ParentProvider); Assert.Null(p1.ParentProvider); diff --git a/test/OpenTelemetry.Tests/Trace/LinkTest.cs b/test/OpenTelemetry.Tests/Trace/LinkTest.cs index b0a647935..e327f2a85 100644 --- a/test/OpenTelemetry.Tests/Trace/LinkTest.cs +++ b/test/OpenTelemetry.Tests/Trace/LinkTest.cs @@ -29,10 +29,10 @@ public class LinkTest : IDisposable this.tags.Add("MyAttributeKey1", 10L); this.tags.Add("MyAttributeKey2", true); this.tags.Add("MyAttributeKey3", 0.005); - this.tags.Add("MyAttributeKey4", new long[] { 1, 2 }); - this.tags.Add("MyAttributeKey5", new string[] { "a", "b" }); - this.tags.Add("MyAttributeKey6", new bool[] { true, false }); - this.tags.Add("MyAttributeKey7", new double[] { 0.1, -0.1 }); + this.tags.Add("MyAttributeKey4", [1L, 2L]); + this.tags.Add("MyAttributeKey5", ["a", "b"]); + this.tags.Add("MyAttributeKey6", [true, false]); + this.tags.Add("MyAttributeKey7", [0.1, -0.1]); } [Fact] diff --git a/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTest.cs b/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTest.cs index 9c3f566b3..a1d36aa2c 100644 --- a/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTest.cs +++ b/test/OpenTelemetry.Tests/Trace/Propagation/TraceContextPropagatorTest.cs @@ -220,13 +220,13 @@ public class TraceContextPropagatorTest public void MemberCountLimit() { // test_tracestate_member_count_limit - var output1 = CallTraceContextPropagator(new string[] - { + var output1 = CallTraceContextPropagator( + [ "bar01=01,bar02=02,bar03=03,bar04=04,bar05=05,bar06=06,bar07=07,bar08=08,bar09=09,bar10=10", "bar11=11,bar12=12,bar13=13,bar14=14,bar15=15,bar16=16,bar17=17,bar18=18,bar19=19,bar20=20", "bar21=21,bar22=22,bar23=23,bar24=24,bar25=25,bar26=26,bar27=27,bar28=28,bar29=29,bar30=30", - "bar31=31,bar32=32", - }); + "bar31=31,bar32=32" + ]); var expected = "bar01=01,bar02=02,bar03=03,bar04=04,bar05=05,bar06=06,bar07=07,bar08=08,bar09=09,bar10=10" + "," + "bar11=11,bar12=12,bar13=13,bar14=14,bar15=15,bar16=16,bar17=17,bar18=18,bar19=19,bar20=20" + "," + @@ -234,13 +234,13 @@ public class TraceContextPropagatorTest "bar31=31,bar32=32"; Assert.Equal(expected, output1); - var output2 = CallTraceContextPropagator(new string[] - { + var output2 = CallTraceContextPropagator( + [ "bar01=01,bar02=02,bar03=03,bar04=04,bar05=05,bar06=06,bar07=07,bar08=08,bar09=09,bar10=10", "bar11=11,bar12=12,bar13=13,bar14=14,bar15=15,bar16=16,bar17=17,bar18=18,bar19=19,bar20=20", "bar21=21,bar22=22,bar23=23,bar24=24,bar25=25,bar26=26,bar27=27,bar28=28,bar29=29,bar30=30", - "bar31=31,bar32=32,bar33=33", - }); + "bar31=31,bar32=32,bar33=33" + ]); Assert.Empty(output2); } @@ -323,7 +323,7 @@ public class TraceContextPropagatorTest { var headers = new Dictionary { - { TraceParent, new[] { $"00-{TraceId}-{SpanId}-01" } }, + { TraceParent, [$"00-{TraceId}-{SpanId}-01"] }, { TraceState, tracestate }, }; var f = new TraceContextPropagator(); diff --git a/test/OpenTelemetry.Tests/Trace/TraceIdRatioBasedSamplerTest.cs b/test/OpenTelemetry.Tests/Trace/TraceIdRatioBasedSamplerTest.cs index bfcdb21a3..f0d9d0344 100644 --- a/test/OpenTelemetry.Tests/Trace/TraceIdRatioBasedSamplerTest.cs +++ b/test/OpenTelemetry.Tests/Trace/TraceIdRatioBasedSamplerTest.cs @@ -32,25 +32,24 @@ public class TraceIdRatioBasedSamplerTest // is not less than probability * Long.MAX_VALUE; var notSampledtraceId = ActivityTraceId.CreateFromBytes( - new byte[] - { - 0x8F, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }); + [ + 0x8F, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]); Assert.Equal( SamplingDecision.Drop, defaultProbability.ShouldSample(new SamplingParameters(default, notSampledtraceId, ActivityDisplayName, ActivityKindServer, null, null)).Decision); @@ -59,25 +58,24 @@ public class TraceIdRatioBasedSamplerTest // is less than probability * Long.MAX_VALUE; var sampledtraceId = ActivityTraceId.CreateFromBytes( - new byte[] - { - 0x00, - 0x00, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0xFF, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - }); + [ + 0x00, + 0x00, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0xFF, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]); Assert.Equal( SamplingDecision.RecordAndSample, defaultProbability.ShouldSample(new SamplingParameters(default, sampledtraceId, ActivityDisplayName, ActivityKindServer, null, null)).Decision); diff --git a/test/TestApp.AspNetCore/Controllers/ValuesController.cs b/test/TestApp.AspNetCore/Controllers/ValuesController.cs index 27a9ab0d2..4c8a59198 100644 --- a/test/TestApp.AspNetCore/Controllers/ValuesController.cs +++ b/test/TestApp.AspNetCore/Controllers/ValuesController.cs @@ -12,7 +12,7 @@ public class ValuesController : Controller [HttpGet] public IEnumerable Get() { - return new string[] { "value1", "value2" }; + return ["value1", "value2"]; } // GET api/values/5