diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs
index d130fc818631..c9f4e005822d 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmResponse.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
+using System;
+
namespace Azure.ResourceManager.Core
{
///
@@ -14,8 +16,12 @@ public sealed class ArmResponse : ArmResponse
/// Initializes a new instance of the class.
///
/// The azure response object to wrap.
+ /// If is null.
public ArmResponse(Response response)
{
+ if (response is null)
+ throw new ArgumentNullException(nameof(response));
+
_response = response;
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs
index bbab26ea2456..f0d24e3e714e 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ArmVoidOperation.cs
@@ -21,6 +21,9 @@ public sealed class ArmVoidOperation : ArmOperation
public ArmVoidOperation(Operation other)
: base(null)
{
+ if (other is null)
+ throw new ArgumentNullException(nameof(other));
+
_wrapped = other;
}
@@ -31,6 +34,8 @@ public ArmVoidOperation(Operation other)
public ArmVoidOperation(Response other)
: base(other)
{
+ if (other is null)
+ throw new ArgumentNullException(nameof(other));
}
///
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs
index e5db0c8bee2e..2772642ffc63 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClient.cs
@@ -28,12 +28,13 @@ public class AzureResourceManagerClient
/// Initializes a new instance of the class for mocking.
///
protected AzureResourceManagerClient()
- : this(null, null, new DefaultAzureCredential(), new AzureResourceManagerClientOptions())
+ : this(null, null, new DefaultAzureCredential(), null)
{
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class
+ /// with as credential.
///
/// The client parameters to use in these operations.
public AzureResourceManagerClient(AzureResourceManagerClientOptions options = default)
@@ -46,6 +47,7 @@ public AzureResourceManagerClient(AzureResourceManagerClientOptions options = de
///
/// A credential used to authenticate to an Azure Service.
/// The client parameters to use in these operations.
+ /// If is null.
public AzureResourceManagerClient(TokenCredential credential, AzureResourceManagerClientOptions options = default)
: this(null, null, credential, options)
{
@@ -57,7 +59,11 @@ public AzureResourceManagerClient(TokenCredential credential, AzureResourceManag
/// The id of the default Azure subscription.
/// A credential used to authenticate to an Azure Service.
/// The client parameters to use in these operations.
- public AzureResourceManagerClient(string defaultSubscriptionId, TokenCredential credential, AzureResourceManagerClientOptions options = default)
+ /// If is null.
+ public AzureResourceManagerClient(
+ string defaultSubscriptionId,
+ TokenCredential credential,
+ AzureResourceManagerClientOptions options = default)
: this(defaultSubscriptionId, null, credential, options)
{
}
@@ -65,10 +71,14 @@ public AzureResourceManagerClient(string defaultSubscriptionId, TokenCredential
///
/// Initializes a new instance of the class.
///
- /// The base URI of the service.
+ /// The base URI of the Azure management endpoint.
/// A credential used to authenticate to an Azure Service.
/// The client parameters to use in these operations.
- public AzureResourceManagerClient(Uri baseUri, TokenCredential credential, AzureResourceManagerClientOptions options = default)
+ /// If is null.
+ public AzureResourceManagerClient(
+ Uri baseUri,
+ TokenCredential credential,
+ AzureResourceManagerClientOptions options = default)
: this(null, baseUri, credential, options)
{
}
@@ -80,20 +90,22 @@ public AzureResourceManagerClient(Uri baseUri, TokenCredential credential, Azure
/// The base URI of the service.
/// A credential used to authenticate to an Azure Service.
/// The client parameters to use in these operations.
- private AzureResourceManagerClient(string defaultSubscriptionId, Uri baseUri, TokenCredential credential, AzureResourceManagerClientOptions options = default)
+ private AzureResourceManagerClient(
+ string defaultSubscriptionId,
+ Uri baseUri,
+ TokenCredential credential,
+ AzureResourceManagerClientOptions options)
{
+ if (credential is null)
+ throw new ArgumentNullException(nameof(credential));
+
_credentials = credential;
_baseUri = baseUri;
ClientOptions = options ?? new AzureResourceManagerClientOptions();
- if (string.IsNullOrWhiteSpace(defaultSubscriptionId))
- {
- DefaultSubscription = GetDefaultSubscription();
- }
- else
- {
- DefaultSubscription = GetSubscriptionOperations(defaultSubscriptionId).Get().Value;
- }
+ DefaultSubscription = string.IsNullOrWhiteSpace(defaultSubscriptionId)
+ ? GetDefaultSubscription()
+ : GetSubscriptionOperations(defaultSubscriptionId).Get().Value;
ApiVersionOverrides = new Dictionary();
}
diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClientOptions.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClientOptions.cs
index 2b6e0a8a2753..ba82c50013e5 100644
--- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClientOptions.cs
+++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/AzureResourceManagerClientOptions.cs
@@ -4,6 +4,7 @@
using Azure.Core;
using Azure.Core.Pipeline;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
@@ -14,9 +15,7 @@ namespace Azure.ResourceManager.Core
///
public sealed class AzureResourceManagerClientOptions : ClientOptions
{
- private static readonly object _overridesLock = new object();
-
- private Dictionary _overrides = new Dictionary();
+ private readonly ConcurrentDictionary _overrides = new ConcurrentDictionary();
///
/// Initializes a new instance of the class.
@@ -40,8 +39,12 @@ public AzureResourceManagerClientOptions(LocationData defaultLocation)
///
/// The default location to use if can't be inherited from parent.
/// The client parameters to use in these operations.
+ /// If is null.
internal AzureResourceManagerClientOptions(LocationData defaultLocation, AzureResourceManagerClientOptions other = null)
{
+ if (defaultLocation is null)
+ throw new ArgumentNullException(nameof(defaultLocation));
+
// Will go away when moved into core since we will have directy acces the policies and transport, so just need to set those
if (!ReferenceEquals(other, null))
Copy(other);
@@ -93,9 +96,13 @@ public T Convert()
///
/// The http call policy in the pipeline.
/// The position of the http call policy in the pipeline.
+ /// If is null.
public new void AddPolicy(HttpPipelinePolicy policy, HttpPipelinePosition position)
{
- // TODO policy lists are internal hence we don't have acces to them by inheriting ClientOptions in this Asembly, this is a wrapper for now to convert to the concrete
+ if (policy is null)
+ throw new ArgumentNullException(nameof(policy));
+
+ // TODO policy lists are internal hence we don't have access to them by inheriting ClientOptions in this Assembly, this is a wrapper for now to convert to the concrete
// policy options.
switch (position)
{
@@ -116,26 +123,15 @@ public T Convert()
/// Gets override object.
///
/// The type of the underlying model this class wraps.
- /// A function which returns an object.
+ /// A function used to construct a new object if none was found.
/// The override object.
[EditorBrowsable(EditorBrowsableState.Never)]
- public object GetOverrideObject(Func