From 295c12445e6528353952745ff10a2ce10b7086ad Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 14 Nov 2023 12:54:16 +0000 Subject: [PATCH] chore: Fix editorconfig-based warnings (It can be hard to get these to show up without opening the code file itself. I've opened all files within VS, so we *should* be "clean" now.) Signed-off-by: Jon Skeet --- samples/HttpSend/Program.cs | 6 +++--- src/CloudNative.CloudEvents/CloudEventAttribute.cs | 4 ++-- src/CloudNative.CloudEvents/CloudEventAttributeType.cs | 8 ++++---- src/CloudNative.CloudEvents/CloudEventsSpecVersion.cs | 4 ++-- src/CloudNative.CloudEvents/Core/BinaryDataUtilities.cs | 4 ++-- .../Http/HttpListenerExtensions.cs | 8 ++++---- .../ConformanceTestData/SampleBatches.cs | 4 ++-- .../ConformanceTestData/SampleEvents.cs | 6 +++--- test/CloudNative.CloudEvents.UnitTests/TimestampsTest.cs | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/samples/HttpSend/Program.cs b/samples/HttpSend/Program.cs index 91a81ec..7532aac 100644 --- a/samples/HttpSend/Program.cs +++ b/samples/HttpSend/Program.cs @@ -1,4 +1,4 @@ -// Copyright (c) Cloud Native Foundation. +// Copyright (c) Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -17,7 +17,7 @@ namespace HttpSend { // This application uses the McMaster.Extensions.CommandLineUtils library for parsing the command // line and calling the application code. The [Option] attributes designate the parameters. - class Program + internal class Program { [Option(Description = "CloudEvents 'source' (default: urn:example-com:mysource:abc)", LongName = "source", ShortName = "s")] private string Source { get; } = "urn:example-com:mysource:abc"; @@ -52,4 +52,4 @@ private async Task OnExecuteAsync() Console.WriteLine(result.StatusCode); } } -} \ No newline at end of file +} diff --git a/src/CloudNative.CloudEvents/CloudEventAttribute.cs b/src/CloudNative.CloudEvents/CloudEventAttribute.cs index 15a6573..8e451f0 100644 --- a/src/CloudNative.CloudEvents/CloudEventAttribute.cs +++ b/src/CloudNative.CloudEvents/CloudEventAttribute.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -44,7 +44,7 @@ public class CloudEventAttribute /// public bool IsExtension { get; } - private Action? validator; + private readonly Action? validator; // TODO: Have a "mode" of Required/Optional/Extension? diff --git a/src/CloudNative.CloudEvents/CloudEventAttributeType.cs b/src/CloudNative.CloudEvents/CloudEventAttributeType.cs index ebe9bd7..917eaaa 100644 --- a/src/CloudNative.CloudEvents/CloudEventAttributeType.cs +++ b/src/CloudNative.CloudEvents/CloudEventAttributeType.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -105,16 +105,16 @@ protected GenericCloudEventsAttributeType(string name, CloudEventAttributeTypeOr { } - public override sealed object Parse(string value) => ParseImpl(Validation.CheckNotNull(value, nameof(value))); + public sealed override object Parse(string value) => ParseImpl(Validation.CheckNotNull(value, nameof(value))); - public override sealed string Format(object value) + public sealed override string Format(object value) { Validate(value); // TODO: Avoid the double cast. return FormatImpl((T) value); } - public override sealed void Validate(object value) + public sealed override void Validate(object value) { Validation.CheckNotNull(value, nameof(value)); if (!ClrType.IsInstanceOfType(value)) diff --git a/src/CloudNative.CloudEvents/CloudEventsSpecVersion.cs b/src/CloudNative.CloudEvents/CloudEventsSpecVersion.cs index 8a9081c..7b07361 100644 --- a/src/CloudNative.CloudEvents/CloudEventsSpecVersion.cs +++ b/src/CloudNative.CloudEvents/CloudEventsSpecVersion.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -89,7 +89,7 @@ public sealed class CloudEventsSpecVersion /// public CloudEventAttribute TypeAttribute { get; } - private Dictionary attributesByName; + private readonly Dictionary attributesByName; // TODO: What's the compatibility story? What might be in 1.1, and how would we handle that in 1.0? diff --git a/src/CloudNative.CloudEvents/Core/BinaryDataUtilities.cs b/src/CloudNative.CloudEvents/Core/BinaryDataUtilities.cs index c77acf9..29dfa1d 100644 --- a/src/CloudNative.CloudEvents/Core/BinaryDataUtilities.cs +++ b/src/CloudNative.CloudEvents/Core/BinaryDataUtilities.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -22,7 +22,7 @@ public static class BinaryDataUtilities /// /// The stream to read from. Must not be null. /// The content of the stream (from its original position), as a read-only memory segment. - public async static Task> ToReadOnlyMemoryAsync(Stream stream) + public static async Task> ToReadOnlyMemoryAsync(Stream stream) { Validation.CheckNotNull(stream, nameof(stream)); // TODO: Optimize if it's already a MemoryStream? Will only work in some cases, diff --git a/src/CloudNative.CloudEvents/Http/HttpListenerExtensions.cs b/src/CloudNative.CloudEvents/Http/HttpListenerExtensions.cs index 29ee181..1fce6ba 100644 --- a/src/CloudNative.CloudEvents/Http/HttpListenerExtensions.cs +++ b/src/CloudNative.CloudEvents/Http/HttpListenerExtensions.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -138,7 +138,7 @@ public static Task ToCloudEventAsync(this HttpListenerRequest httpLi /// The event formatter to use to parse the CloudEvent. Must not be null. /// The extension attributes to use when parsing the CloudEvent. May be null. /// A reference to a validated CloudEvent instance. - public async static Task ToCloudEventAsync(this HttpListenerRequest httpListenerRequest, + public static async Task ToCloudEventAsync(this HttpListenerRequest httpListenerRequest, CloudEventFormatter formatter, IEnumerable? extensionAttributes) => await ToCloudEventAsyncImpl(httpListenerRequest, formatter, extensionAttributes, async: true).ConfigureAwait(false); @@ -164,7 +164,7 @@ public static CloudEvent ToCloudEvent(this HttpListenerRequest httpListenerReque CloudEventFormatter formatter, IEnumerable? extensionAttributes) => ToCloudEventAsyncImpl(httpListenerRequest, formatter, extensionAttributes, async: false).GetAwaiter().GetResult(); - private async static Task ToCloudEventAsyncImpl(HttpListenerRequest httpListenerRequest, + private static async Task ToCloudEventAsyncImpl(HttpListenerRequest httpListenerRequest, CloudEventFormatter formatter, IEnumerable? extensionAttributes, bool async) { Validation.CheckNotNull(httpListenerRequest, nameof(httpListenerRequest)); @@ -264,7 +264,7 @@ public static IReadOnlyList ToCloudEventBatch( IEnumerable? extensionAttributes) => ToCloudEventBatchInternalAsync(httpListenerRequest, formatter, extensionAttributes, async: false).GetAwaiter().GetResult(); - private async static Task> ToCloudEventBatchInternalAsync(HttpListenerRequest httpListenerRequest, + private static async Task> ToCloudEventBatchInternalAsync(HttpListenerRequest httpListenerRequest, CloudEventFormatter formatter, IEnumerable? extensionAttributes, bool async) { Validation.CheckNotNull(httpListenerRequest, nameof(httpListenerRequest)); diff --git a/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleBatches.cs b/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleBatches.cs index 5903f2c..8bb21fb 100644 --- a/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleBatches.cs +++ b/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleBatches.cs @@ -1,4 +1,4 @@ -// Copyright 2023 Cloud Native Foundation. +// Copyright 2023 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -11,7 +11,7 @@ namespace CloudNative.CloudEvents.UnitTests.ConformanceTestData; public static class SampleBatches { - private static ConcurrentDictionary> batchesById = new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> batchesById = new ConcurrentDictionary>(); private static readonly IReadOnlyList empty = Register("empty"); private static readonly IReadOnlyList minimal = Register("minimal", SampleEvents.Minimal); diff --git a/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleEvents.cs b/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleEvents.cs index 406056d..7a1577d 100644 --- a/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleEvents.cs +++ b/test/CloudNative.CloudEvents.UnitTests/ConformanceTestData/SampleEvents.cs @@ -1,4 +1,4 @@ -// Copyright 2023 Cloud Native Foundation. +// Copyright 2023 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -10,9 +10,9 @@ namespace CloudNative.CloudEvents.UnitTests.ConformanceTestData; internal static class SampleEvents { - private static ConcurrentDictionary eventsById = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary eventsById = new ConcurrentDictionary(); - private static IReadOnlyList allExtensionAttributes = new List() + private static readonly IReadOnlyList allExtensionAttributes = new List() { CloudEventAttribute.CreateExtension("extinteger", CloudEventAttributeType.Integer), CloudEventAttribute.CreateExtension("extboolean", CloudEventAttributeType.Boolean), diff --git a/test/CloudNative.CloudEvents.UnitTests/TimestampsTest.cs b/test/CloudNative.CloudEvents.UnitTests/TimestampsTest.cs index 61d9d78..fb7afde 100644 --- a/test/CloudNative.CloudEvents.UnitTests/TimestampsTest.cs +++ b/test/CloudNative.CloudEvents.UnitTests/TimestampsTest.cs @@ -1,4 +1,4 @@ -// Copyright 2021 Cloud Native Foundation. +// Copyright 2021 Cloud Native Foundation. // Licensed under the Apache 2.0 license. // See LICENSE file in the project root for full license information. @@ -79,7 +79,7 @@ public void Parse_Success_VaryingUtcOffset(string offsetPart, int expectedOffset AssertParseSuccess(expected, text); } - static void AssertParseSuccess(DateTimeOffset expected, string text) + private static void AssertParseSuccess(DateTimeOffset expected, string text) { var parsed = Timestamps.Parse(text); AssertTimestampsEqual(expected, parsed);