From 4433dbc2ac7a52162626048194f0620c66805bbc Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Mon, 26 Aug 2019 23:48:06 +0200 Subject: [PATCH] fix: First arg of AOORE is param name (#194) * fix: First arg of AOORE is param name * fix: ArgumentOutOfRangeException first arg is param name --- .../Context/Propagation/TraceContextFormat.cs | 2 +- .../Trace/Config/TraceParamsBuilder.cs | 2 +- src/OpenTelemetry/Internal/VarInt.cs | 4 ++-- src/OpenTelemetry/Stats/Aggregations/DistributionData.cs | 2 +- src/OpenTelemetry/Stats/BucketBoundaries.cs | 2 +- src/OpenTelemetry/Stats/Measures/MeasureDouble.cs | 6 ++---- src/OpenTelemetry/Stats/Measures/MeasureLong.cs | 6 ++---- src/OpenTelemetry/Stats/ViewName.cs | 6 ++---- src/OpenTelemetry/Trace/Internal/EvictingQueue.cs | 2 +- src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs | 2 +- 10 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/OpenTelemetry.Abstractions/Context/Propagation/TraceContextFormat.cs b/src/OpenTelemetry.Abstractions/Context/Propagation/TraceContextFormat.cs index ee43407447e..88eff6648ea 100644 --- a/src/OpenTelemetry.Abstractions/Context/Propagation/TraceContextFormat.cs +++ b/src/OpenTelemetry.Abstractions/Context/Propagation/TraceContextFormat.cs @@ -213,7 +213,7 @@ private byte HexCharToByte(char c) return (byte)(c - 'A' + 10); } - throw new ArgumentOutOfRangeException("Invalid character: " + c); + throw new ArgumentOutOfRangeException(nameof(c), $"Invalid character: {c}."); } private bool TryExtractTracestate(string[] tracestateCollection, out Tracestate tracestateResult) diff --git a/src/OpenTelemetry.Abstractions/Trace/Config/TraceParamsBuilder.cs b/src/OpenTelemetry.Abstractions/Trace/Config/TraceParamsBuilder.cs index a94d75efb73..14c95375ada 100644 --- a/src/OpenTelemetry.Abstractions/Trace/Config/TraceParamsBuilder.cs +++ b/src/OpenTelemetry.Abstractions/Trace/Config/TraceParamsBuilder.cs @@ -128,7 +128,7 @@ public TraceParams Build() if (!string.IsNullOrEmpty(missing)) { - throw new ArgumentOutOfRangeException("Missing required properties:" + missing); + throw new ArgumentOutOfRangeException(nameof(missing), $"Missing required properties: {missing}."); } return new TraceParams( diff --git a/src/OpenTelemetry/Internal/VarInt.cs b/src/OpenTelemetry/Internal/VarInt.cs index 70fb59afc09..04353a57de6 100644 --- a/src/OpenTelemetry/Internal/VarInt.cs +++ b/src/OpenTelemetry/Internal/VarInt.cs @@ -54,7 +54,7 @@ public static int GetVarInt(byte[] src, int offset, int[] dst) if (shift >= 32) { // Out of range - throw new ArgumentOutOfRangeException("varint too long"); + throw new ArgumentOutOfRangeException(nameof(src), "varint too long."); } // Get 7 bits from next byte @@ -104,7 +104,7 @@ public static int GetVarInt(Stream inputStream) if (shift >= 32) { // Out of range - throw new ArgumentOutOfRangeException("varint too long"); + throw new ArgumentOutOfRangeException(nameof(inputStream), "varint too long."); } // Get 7 bits from next byte diff --git a/src/OpenTelemetry/Stats/Aggregations/DistributionData.cs b/src/OpenTelemetry/Stats/Aggregations/DistributionData.cs index f6eb6957f36..151095f543a 100644 --- a/src/OpenTelemetry/Stats/Aggregations/DistributionData.cs +++ b/src/OpenTelemetry/Stats/Aggregations/DistributionData.cs @@ -53,7 +53,7 @@ public static IDistributionData Create(double mean, long count, double min, doub { if (!(min <= max)) { - throw new ArgumentOutOfRangeException("max should be greater or equal to min."); + throw new ArgumentOutOfRangeException(nameof(max), "max should be greater or equal to min."); } } diff --git a/src/OpenTelemetry/Stats/BucketBoundaries.cs b/src/OpenTelemetry/Stats/BucketBoundaries.cs index 0fcc241cfff..ccbfbbcfe9a 100644 --- a/src/OpenTelemetry/Stats/BucketBoundaries.cs +++ b/src/OpenTelemetry/Stats/BucketBoundaries.cs @@ -47,7 +47,7 @@ public static IBucketBoundaries Create(IEnumerable bucketBoundaries) var next = bucketBoundariesCopy[i]; if (!(lower < next)) { - throw new ArgumentOutOfRangeException("Bucket boundaries not sorted."); + throw new ArgumentOutOfRangeException(nameof(bucketBoundaries), "Bucket boundaries not sorted."); } lower = next; diff --git a/src/OpenTelemetry/Stats/Measures/MeasureDouble.cs b/src/OpenTelemetry/Stats/Measures/MeasureDouble.cs index 2ef5d905072..a71832ff326 100644 --- a/src/OpenTelemetry/Stats/Measures/MeasureDouble.cs +++ b/src/OpenTelemetry/Stats/Measures/MeasureDouble.cs @@ -40,10 +40,8 @@ public static IMeasureDouble Create(string name, string description, string unit { if (!(StringUtil.IsPrintableString(name) && name.Length <= NameMaxLength)) { - throw new ArgumentOutOfRangeException( - "Name should be a ASCII string with a length no greater than " - + NameMaxLength - + " characters."); + throw new ArgumentOutOfRangeException(nameof(name), + $"Name should be a ASCII string with a length no greater than {NameMaxLength} characters."); } return new MeasureDouble(name, description, unit); diff --git a/src/OpenTelemetry/Stats/Measures/MeasureLong.cs b/src/OpenTelemetry/Stats/Measures/MeasureLong.cs index 0e6ad6a69d3..72c5dfb58a4 100644 --- a/src/OpenTelemetry/Stats/Measures/MeasureLong.cs +++ b/src/OpenTelemetry/Stats/Measures/MeasureLong.cs @@ -40,10 +40,8 @@ public static IMeasureLong Create(string name, string description, string unit) { if (!(StringUtil.IsPrintableString(name) && name.Length <= NameMaxLength)) { - throw new ArgumentOutOfRangeException( - "Name should be a ASCII string with a length no greater than " - + NameMaxLength - + " characters."); + throw new ArgumentOutOfRangeException(nameof(name), + $"Name should be a ASCII string with a length no greater than {NameMaxLength} characters."); } return new MeasureLong(name, description, unit); diff --git a/src/OpenTelemetry/Stats/ViewName.cs b/src/OpenTelemetry/Stats/ViewName.cs index 9f0e72918ee..de6aad04a64 100644 --- a/src/OpenTelemetry/Stats/ViewName.cs +++ b/src/OpenTelemetry/Stats/ViewName.cs @@ -39,10 +39,8 @@ public static IViewName Create(string name) if (!(StringUtil.IsPrintableString(name) && name.Length <= NameMaxLength)) { - throw new ArgumentOutOfRangeException( - "Name should be a ASCII string with a length no greater than " - + NameMaxLength - + " characters."); + throw new ArgumentOutOfRangeException(nameof(name), + $"Name should be a ASCII string with a length no greater than {NameMaxLength} characters."); } return new ViewName(name); diff --git a/src/OpenTelemetry/Trace/Internal/EvictingQueue.cs b/src/OpenTelemetry/Trace/Internal/EvictingQueue.cs index 40713757ee9..3646efbba03 100644 --- a/src/OpenTelemetry/Trace/Internal/EvictingQueue.cs +++ b/src/OpenTelemetry/Trace/Internal/EvictingQueue.cs @@ -29,7 +29,7 @@ public EvictingQueue(int maxNumEvents) { if (maxNumEvents < 0) { - throw new ArgumentOutOfRangeException($"{nameof(maxNumEvents)} must be >= 0"); + throw new ArgumentOutOfRangeException(nameof(maxNumEvents), $"{nameof(maxNumEvents)} must be >= 0."); } this.maxNumEvents = maxNumEvents; diff --git a/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs b/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs index 11ffbd1ce52..b6e3c1cfc44 100644 --- a/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs +++ b/src/OpenTelemetry/Trace/Sampler/ProbabilitySampler.cs @@ -41,7 +41,7 @@ public static ProbabilitySampler Create(double probability) { if (probability < 0.0 || probability > 1.0) { - throw new ArgumentOutOfRangeException("probability must be in range [0.0, 1.0]"); + throw new ArgumentOutOfRangeException(nameof(probability), "probability must be in range [0.0, 1.0]"); } long idUpperBound;