From e613ba6980cfe380510f085190949ac46e9e4b15 Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Wed, 30 Oct 2019 09:13:04 +0000 Subject: [PATCH] Add braces around single-statement if/foreach --- csharp/src/Google.Protobuf/ExtensionRegistry.cs | 6 ++++++ .../src/Google.Protobuf/Reflection/ExtensionCollection.cs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/csharp/src/Google.Protobuf/ExtensionRegistry.cs b/csharp/src/Google.Protobuf/ExtensionRegistry.cs index b8eee24176..2318e449e6 100644 --- a/csharp/src/Google.Protobuf/ExtensionRegistry.cs +++ b/csharp/src/Google.Protobuf/ExtensionRegistry.cs @@ -90,7 +90,9 @@ namespace Google.Protobuf ProtoPreconditions.CheckNotNull(extensions, nameof(extensions)); foreach (var extension in extensions) + { Add(extension); + } } /// @@ -120,9 +122,13 @@ namespace Google.Protobuf { ProtoPreconditions.CheckNotNull(array, nameof(array)); if (arrayIndex < 0 || arrayIndex >= array.Length) + { throw new ArgumentOutOfRangeException(nameof(arrayIndex)); + } if (array.Length - arrayIndex < Count) + { throw new ArgumentException("The provided array is shorter than the number of elements in the registry"); + } for (int i = 0; i < array.Length; i++) { diff --git a/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs b/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs index 1b09bdde7f..38e33d7ff2 100644 --- a/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs +++ b/csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs @@ -109,7 +109,9 @@ namespace Google.Protobuf.Reflection IList _; if (!declarationOrder.TryGetValue(descriptor.ExtendeeType, out _)) + { declarationOrder.Add(descriptor.ExtendeeType, new List()); + } declarationOrder[descriptor.ExtendeeType].Add(descriptor); }