diff --git a/common/src/device/provisioning/transport/RegistrationOperationStatus.cs b/common/src/device/provisioning/transport/RegistrationOperationStatus.cs index 053c7de931..a607b82a1d 100644 --- a/common/src/device/provisioning/transport/RegistrationOperationStatus.cs +++ b/common/src/device/provisioning/transport/RegistrationOperationStatus.cs @@ -30,7 +30,7 @@ public RegistrationOperationStatus() /// Initializes a new instance of the RegistrationOperationStatus /// class. /// - /// Operation ID. + /// Operation Id. /// Device enrollment status. Possible values /// include: 'unassigned', 'assigning', 'assigned', 'failed', /// 'disabled' @@ -53,7 +53,7 @@ public RegistrationOperationStatus( partial void CustomInit(); /// - /// Gets or sets operation ID. + /// Gets or sets operation Id. /// [JsonProperty(PropertyName = "operationId")] public string OperationId { get; set; } diff --git a/common/src/service/Resources.Designer.cs b/common/src/service/Resources.Designer.cs index 2d7d47fa04..ada4cfa94c 100644 --- a/common/src/service/Resources.Designer.cs +++ b/common/src/service/Resources.Designer.cs @@ -180,7 +180,7 @@ internal static string CreditListenerAlreadyRegistered { } /// - /// Looks up a localized string similar to A device with ID '{0}' is already registered.. + /// Looks up a localized string similar to A device with Id '{0}' is already registered.. /// internal static string DeviceAlreadyExists { get { @@ -189,7 +189,7 @@ internal static string DeviceAlreadyExists { } /// - /// Looks up a localized string similar to Import error for device ID '{0}': {1}. + /// Looks up a localized string similar to Import error for device Id '{0}': {1}. /// internal static string DeviceImportError { get { @@ -216,7 +216,7 @@ internal static string DeviceNotFound { } /// - /// Looks up a localized string similar to A device with ID '{0}' is not registered.. + /// Looks up a localized string similar to A device with Id '{0}' is not registered.. /// internal static string DeviceNotRegistered { get { @@ -261,7 +261,7 @@ internal static string ErrorConvertingToChar { } /// - /// Looks up a localized string similar to ETag mismatch for device ID '{0}'. + /// Looks up a localized string similar to ETag mismatch for device Id '{0}'. /// internal static string ETagMismatch { get { diff --git a/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs b/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs index bcbb6d817a..9bddbdf035 100644 --- a/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs +++ b/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs @@ -125,7 +125,7 @@ public static string Serialize(IEnumerable> propert propertiesCount++; } - //Optimization for most common case: only correlation ID is present + //Optimization for most common case: only correlation Id is present if (propertiesCount == 1 && firstProperty.HasValue) { return firstProperty.Value.Value == null ? diff --git a/iothub/device/src/Common/WebApi/CustomHeaderConstants.cs b/iothub/device/src/Common/WebApi/CustomHeaderConstants.cs index a84ad02d28..4c6e19766c 100644 --- a/iothub/device/src/Common/WebApi/CustomHeaderConstants.cs +++ b/iothub/device/src/Common/WebApi/CustomHeaderConstants.cs @@ -3,7 +3,7 @@ namespace Microsoft.Azure.Devices.Client { - static class CustomHeaderConstants + internal static class CustomHeaderConstants { /// /// Used in message responses and feedback @@ -132,19 +132,19 @@ static class CustomHeaderConstants /// /// x-ms-client-principal-name - /// Set to the principal ID / UPN of the client JWT making the request. + /// Set to the principal Id / UPN of the client JWT making the request. /// public const string PrincipalName = "x-ms-client-principal-name"; /// /// x-ms-client-tenant-id - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientTenantId = "x-ms-client-tenant-id"; /// /// x-ms-client-audience - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientAudience = "x-ms-client-audience"; @@ -168,7 +168,7 @@ static class CustomHeaderConstants /// /// x-ms-client-request-id - /// Caller-specified request ID, in the form of a GUID with no decoration such as curly braces + /// Caller-specified request Id, in the form of a GUID with no decoration such as curly braces /// (e.g. client-request-id: 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0). /// A caller-defined value that identifies the given request. If specified, this will be /// included in response information as a way to map the request. @@ -210,7 +210,7 @@ static class CustomHeaderConstants public const string RequestId = "x-ms-request-id"; /// - /// Used to supply module ID of invoking module when used by module to invoke method on other modules/devices. + /// Used to supply module Id of invoking module when used by module to invoke method on other modules/devices. /// public const string ModuleId = "x-ms-edge-moduleId"; diff --git a/iothub/device/src/DeviceClient.cs b/iothub/device/src/DeviceClient.cs index 5be78dbfbd..43966a49c6 100644 --- a/iothub/device/src/DeviceClient.cs +++ b/iothub/device/src/DeviceClient.cs @@ -28,7 +28,7 @@ private DeviceClient(InternalClient internalClient) if (InternalClient.IotHubConnectionString?.ModuleId != null) { - throw new ArgumentException("A module ID was specified in the connection string - please use ModuleClient for modules."); + throw new ArgumentException("A module Id was specified in the connection string - please use ModuleClient for modules."); } if (Logging.IsEnabled) diff --git a/iothub/device/src/MethodRequestInternal.cs b/iothub/device/src/MethodRequestInternal.cs index bab8b721b4..b29b66ae30 100644 --- a/iothub/device/src/MethodRequestInternal.cs +++ b/iothub/device/src/MethodRequestInternal.cs @@ -48,7 +48,7 @@ internal MethodRequestInternal(string name, string requestId, Stream bodyStream, internal string Name { get; private set; } /// - /// the request ID for the transport layer + /// the request Id for the transport layer /// internal string RequestId { get; private set; } diff --git a/iothub/device/src/ModuleClient.cs b/iothub/device/src/ModuleClient.cs index 885adc7368..901a84d57e 100644 --- a/iothub/device/src/ModuleClient.cs +++ b/iothub/device/src/ModuleClient.cs @@ -40,7 +40,7 @@ internal ModuleClient(InternalClient internalClient, ICertificateValidator certV if (string.IsNullOrWhiteSpace(InternalClient.IotHubConnectionString?.ModuleId)) { - throw new ArgumentException("A valid module ID should be specified to create a ModuleClient"); + throw new ArgumentException("A valid module Id should be specified to create a ModuleClient"); } if (Logging.IsEnabled) diff --git a/iothub/device/src/Transport/Mqtt/MqttTransportHandler.cs b/iothub/device/src/Transport/Mqtt/MqttTransportHandler.cs index 4a4ee196d6..bf1e8971e7 100644 --- a/iothub/device/src/Transport/Mqtt/MqttTransportHandler.cs +++ b/iothub/device/src/Transport/Mqtt/MqttTransportHandler.cs @@ -48,8 +48,8 @@ internal sealed class MqttTransportHandler : TransportHandler, IMqttIotHubEventH // Topic names for retrieving a device's twin properties. // The client first subscribes to "$iothub/twin/res/#", to receive the operation's responses. - // It then sends an empty message to the topic "$iothub/twin/GET/?$rid={request id}, with a populated value for request ID. - // The service then sends a response message containing the device twin data on topic "$iothub/twin/res/{status}/?$rid={request id}", using the same request ID as the request. + // It then sends an empty message to the topic "$iothub/twin/GET/?$rid={request id}, with a populated value for request Id. + // The service then sends a response message containing the device twin data on topic "$iothub/twin/res/{status}/?$rid={request id}", using the same request Id as the request. private const string TwinResponseTopicFilter = "$iothub/twin/res/#"; private const string TwinResponseTopicPrefix = "$iothub/twin/res/"; @@ -58,8 +58,8 @@ internal sealed class MqttTransportHandler : TransportHandler, IMqttIotHubEventH // Topic name for updating device twin's reported properties. // The client first subscribes to "$iothub/twin/res/#", to receive the operation's responses. - // The client then sends a message containing the twin update to "$iothub/twin/PATCH/properties/reported/?$rid={request id}", with a populated value for request ID. - // The service then sends a response message containing the new ETag value for the reported properties collection on the topic "$iothub/twin/res/{status}/?$rid={request id}", using the same request ID as the request. + // The client then sends a message containing the twin update to "$iothub/twin/PATCH/properties/reported/?$rid={request id}", with a populated value for request Id. + // The service then sends a response message containing the new ETag value for the reported properties collection on the topic "$iothub/twin/res/{status}/?$rid={request id}", using the same request Id as the request. private const string TwinPatchTopic = "$iothub/twin/PATCH/properties/reported/?$rid={0}"; // Topic names for receiving twin desired property update notifications. @@ -70,7 +70,7 @@ internal sealed class MqttTransportHandler : TransportHandler, IMqttIotHubEventH // Topic name for responding to direct methods. // The client first subscribes to "$iothub/methods/POST/#". // The service sends method requests to the topic "$iothub/methods/POST/{method name}/?$rid={request id}". - // The client responds to the direct method invocation by sending a message to the topic "$iothub/methods/res/{status}/?$rid={request id}", using the same request ID as the request. + // The client responds to the direct method invocation by sending a message to the topic "$iothub/methods/res/{status}/?$rid={request id}", using the same request Id as the request. private const string MethodPostTopicFilter = "$iothub/methods/POST/#"; private const string MethodPostTopicPrefix = "$iothub/methods/POST/"; diff --git a/iothub/service/src/Common/Exceptions/JobNotFoundException.cs b/iothub/service/src/Common/Exceptions/JobNotFoundException.cs index 346f6987a8..07ed7d5212 100644 --- a/iothub/service/src/Common/Exceptions/JobNotFoundException.cs +++ b/iothub/service/src/Common/Exceptions/JobNotFoundException.cs @@ -17,7 +17,7 @@ public sealed class JobNotFoundException : IotHubException /// /// The Id of the job whose details are unavailable on IoT Hub. public JobNotFoundException(string jobId) - : base($"Job with ID '{jobId}' not found") + : base($"Job with Id '{jobId}' not found") { } diff --git a/iothub/service/src/Common/Extensions/AmqpExtensions.cs b/iothub/service/src/Common/Extensions/AmqpExtensions.cs index db3fe9818f..3fdfe4ed18 100644 --- a/iothub/service/src/Common/Extensions/AmqpExtensions.cs +++ b/iothub/service/src/Common/Extensions/AmqpExtensions.cs @@ -1,11 +1,11 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Threading.Tasks; +using Microsoft.Azure.Amqp; + namespace Microsoft.Azure.Devices.Common.Extensions { - using System.Threading.Tasks; - using Microsoft.Azure.Amqp; - /// /// Contains extension methods for amqp /// @@ -18,8 +18,7 @@ internal static class AmqpExtensions /// internal static async Task GetReceivingLinkAsync(this FaultTolerantAmqpObject faultTolerantReceivingLink) { - ReceivingAmqpLink receivingLink; - if (!faultTolerantReceivingLink.TryGetOpenedObject(out receivingLink)) + if (!faultTolerantReceivingLink.TryGetOpenedObject(out ReceivingAmqpLink receivingLink)) { receivingLink = await faultTolerantReceivingLink.GetOrCreateAsync(IotHubConnection.DefaultOpenTimeout).ConfigureAwait(false); } diff --git a/iothub/service/src/Common/Extensions/CommonExtensions.cs b/iothub/service/src/Common/Extensions/CommonExtensions.cs index 4e90431662..e649455f43 100644 --- a/iothub/service/src/Common/Extensions/CommonExtensions.cs +++ b/iothub/service/src/Common/Extensions/CommonExtensions.cs @@ -93,7 +93,7 @@ public static string EnsureStartsWith(this string value, char prefix) /// /// Gets the value of the specified key, if present /// - /// The dictionary containing the specifed key + /// The dictionary containing the specified key /// The key of the desired value /// The value, if present public static string GetValueOrDefault(this IDictionary map, string keyName) @@ -165,12 +165,10 @@ public static string GetIotHubNameFromHostName(this HttpRequestMessage requestMe // {IotHubname}.[env-specific-sub-domain.]IotHub[-int].net string[] hostNameParts = requestMessage.RequestUri.Host.Split('.'); - if (hostNameParts.Length < 3) - { - throw new ArgumentException("Invalid request URI"); - } - return hostNameParts[0]; + return hostNameParts.Length < 3 + ? throw new ArgumentException("Invalid request URI") + : hostNameParts[0]; } /// @@ -180,30 +178,29 @@ public static string GetIotHubNameFromHostName(this HttpRequestMessage requestMe /// The hub name public static string GetIotHubName(this HttpRequestMessage requestMessage) { - if (!TryGetIotHubName(requestMessage, out string iotHubName)) - { - throw new ArgumentException("Invalid request URI"); - } - - return iotHubName; + return !TryGetIotHubName(requestMessage, out string iotHubName) + ? throw new ArgumentException("Invalid request URI") + : iotHubName; } #if NET451 + /// + /// Get the masked client IP address + /// + /// The HTTP request message. + /// The masked client IP address, if hosted as on OWIN application; otherwise returns null. public static string GetMaskedClientIpAddress(this HttpRequestMessage requestMessage) { // note that this only works if we are hosted as an OWIN app if (requestMessage.Properties.ContainsKey("MS_OwinContext")) { - OwinContext owinContext = requestMessage.Properties["MS_OwinContext"] as OwinContext; - if (owinContext != null) + if (requestMessage.Properties["MS_OwinContext"] is OwinContext owinContext) { string remoteIpAddress = owinContext.Request.RemoteIpAddress; string maskedRemoteIpAddress = string.Empty; - IPAddress remoteIp = null; - - if (IPAddress.TryParse(remoteIpAddress, out remoteIp)) + if (IPAddress.TryParse(remoteIpAddress, out IPAddress remoteIp)) { byte[] addressBytes = remoteIp.GetAddressBytes(); if (remoteIp.AddressFamily == AddressFamily.InterNetwork) @@ -230,6 +227,12 @@ public static string GetMaskedClientIpAddress(this HttpRequestMessage requestMes } #endif + /// + /// Append a key value pair to a non-null . + /// + /// The StringBuilder to append the key value pair to. + /// The key to be appended to the StringBuilder. + /// The value to be appended to the StringBuilder. public static void AppendKeyValuePairIfNotEmpty(this StringBuilder builder, string name, object value) { if (value != null) diff --git a/iothub/service/src/Common/Extensions/DictionaryExtensions.cs b/iothub/service/src/Common/Extensions/DictionaryExtensions.cs index 86296df87c..119c3217c4 100644 --- a/iothub/service/src/Common/Extensions/DictionaryExtensions.cs +++ b/iothub/service/src/Common/Extensions/DictionaryExtensions.cs @@ -1,32 +1,51 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; + namespace Microsoft.Azure.Devices.Common.Extensions { - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.Diagnostics.CodeAnalysis; - + /// + /// Extension methods for class. + /// + [Obsolete("Not recommended for external use.")] public static class DictionaryExtensions { - public static TValue GetValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue = default(TValue)) + /// + /// Gets the value associated with specified key. + /// + /// The type of the key parameter. + /// The type of the value parameter. + /// The dictionary containing the specified key. + /// The key whose value to get. + /// The default value for the type of the value parameter. + /// The value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. + public static TValue GetValueOrDefault(this IDictionary dictionary, TKey key, TValue defaultValue = default) { - if (dictionary.TryGetValue(key, out TValue value)) - { - return value; - } - return defaultValue; + return dictionary.TryGetValue(key, out TValue value) + ? value + : defaultValue; } + /// + /// Gets or adds the value associated with specified key. + /// + /// The type of the key parameter. + /// The type of the value parameter. + /// The dictionary containing the specified key. + /// The key whose value to get. + /// The value provider function. + /// The value associated with the specified key, if the key is found; otherwise, it retrieves the value from the value provider function, + /// adds it to the dictionary and returns it . public static TValue GetValueOrAdd(this IDictionary dictionary, TKey key, Func valueProvider) { if (valueProvider == null) { throw new ArgumentNullException(nameof(valueProvider), "The value provider function cannot be null."); } - TValue value; - if (!dictionary.TryGetValue(key, out value)) + if (!dictionary.TryGetValue(key, out TValue value)) { value = valueProvider(key); dictionary.Add(key, value); @@ -34,6 +53,15 @@ public static TValue GetValueOrAdd(this IDictionary return value; } + /// + /// Removes the value associated with specified key. + /// + /// The type of the key parameter. + /// The type of the value parameter. + /// The dictionary containing the specified key. + /// The key whose value to get. + /// The value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. + /// True if the dictionary contains an element with the specified key; otherwise, false. public static bool TryRemove(this Dictionary dictionary, TKey key, out TValue value) { if (dictionary.TryGetValue(key, out value)) @@ -44,6 +72,15 @@ public static bool TryRemove(this Dictionary diction return false; } + /// + /// Gets or adds the value associated with specified key. + /// + /// The type of the key parameter. + /// The type of the value parameter. + /// The dictionary containing the specified key. + /// The key whose value to get. + /// The value provider function. + /// The value associated with the specified key, if the key is found; otherwise the default value for the type of the value parameter. public static TValue GetOrAddNonNull( this ConcurrentDictionary dictionary, TKey key, @@ -54,8 +91,7 @@ public static TValue GetOrAddNonNull( { throw new ArgumentNullException(nameof(valueFactory), "The value factory function cannot be null."); } - TValue value; - if (dictionary.TryGetValue(key, out value)) + if (dictionary.TryGetValue(key, out TValue value)) { return value; } diff --git a/iothub/service/src/Common/Extensions/EnumerableExtensions.cs b/iothub/service/src/Common/Extensions/EnumerableExtensions.cs index d1bee9de8d..306e2ab672 100644 --- a/iothub/service/src/Common/Extensions/EnumerableExtensions.cs +++ b/iothub/service/src/Common/Extensions/EnumerableExtensions.cs @@ -1,26 +1,22 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections; +using System.Collections.Generic; +using System.Linq; + namespace Microsoft.Azure.Devices.Common { - using System.Collections; - using System.Collections.Generic; - using System.Linq; - - static class EnumerableExtensions + internal static class EnumerableExtensions { /// /// Avoid allocating if possible (if ICollection is supported) /// public static bool AnySlim(this IEnumerable enumerable) { - var collection = enumerable as ICollection; - if (collection != null) - { - return collection.Count != 0; - } - - return enumerable.Any(); + return enumerable is ICollection collection + ? collection.Count != 0 + : enumerable.Any(); } /// @@ -28,13 +24,9 @@ public static bool AnySlim(this IEnumerable enumerable) /// public static IList ToListSlim(this IEnumerable enumerable, bool requireMutable = false) { - var list = enumerable as IList; - if (list != null && !(requireMutable && list.IsReadOnly)) - { - return list; - } - - return enumerable.ToList(); + return enumerable is IList list && !(requireMutable && list.IsReadOnly) + ? list + : enumerable.ToList(); } } } diff --git a/iothub/service/src/Common/Extensions/ExceptionExtensions.cs b/iothub/service/src/Common/Extensions/ExceptionExtensions.cs index f0802b73b4..5ff455c305 100644 --- a/iothub/service/src/Common/Extensions/ExceptionExtensions.cs +++ b/iothub/service/src/Common/Extensions/ExceptionExtensions.cs @@ -1,5 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. + using System; using System.Collections.Generic; using System.Globalization; @@ -9,16 +10,30 @@ namespace Microsoft.Azure.Devices.Common { + /// + /// Extension methods for class. + /// + [Obsolete("Not recommended for external use.")] public static class ExceptionExtensions { private const string ExceptionIdentifierName = "ExceptionId"; - private static MethodInfo prepForRemotingMethodInfo; + private static MethodInfo s_prepForRemotingMethodInfo; + /// + /// Indicates whether the exception is considered fatal. + /// + /// The exception to test. + /// True if the exception is considered fatal; otherwise, false. public static bool IsFatal(this Exception exception) { return Fx.IsFatal(exception); } + /// + /// Unwinds the inner exceptions from a given exception. + /// + /// The exception to unwind. + /// The list of inner exceptions within the specified exception. public static IEnumerable Unwind(this Exception exception) { while (exception != null) @@ -28,16 +43,33 @@ public static IEnumerable Unwind(this Exception exception) } } + /// + /// Unwinds the inner exceptions from a given exception. + /// + /// The exception to unwind. + /// The list of types that the inner exception should be an instance of. + /// The list of inner exceptions within the specified exception that are an instance of the supplied target types. public static IEnumerable Unwind(this Exception exception, params Type[] targetTypes) { return exception.Unwind().Where(e => targetTypes.Any(t => t.IsInstanceOfType(e))); } + /// + /// Unwinds the inner exceptions from a given exception. + /// + /// The type of exception that the inner exception should be an instance of. + /// The exception to unwind. + /// The list of inner exceptions within the specified exception that are an instance of the supplied target type. public static IEnumerable Unwind(this Exception exception) { return exception.Unwind().OfType(); } + /// + /// Prepares a given exception for re-throwing. + /// + /// The exception to be re-thrown. + /// The exception containing the stacktrace from where it was generated. public static Exception PrepareForRethrow(this Exception exception) { Fx.Assert(exception != null, "The specified Exception is null."); @@ -49,13 +81,12 @@ public static Exception PrepareForRethrow(this Exception exception) if (PartialTrustHelpers.UnsafeIsInFullTrust()) { - // Racing here is harmless - if (prepForRemotingMethodInfo == null) + if (s_prepForRemotingMethodInfo == null) { #if NET451 - prepForRemotingMethodInfo = + s_prepForRemotingMethodInfo = typeof(Exception).GetMethod( "PrepForRemoting", BindingFlags.Instance | BindingFlags.NonPublic, @@ -63,7 +94,7 @@ public static Exception PrepareForRethrow(this Exception exception) new Type[] { }, new ParameterModifier[] { }); #else - prepForRemotingMethodInfo = + s_prepForRemotingMethodInfo = typeof(Exception).GetMethod( "PrepForRemoting", BindingFlags.Instance | BindingFlags.NonPublic, @@ -73,15 +104,15 @@ public static Exception PrepareForRethrow(this Exception exception) #endif } - if (prepForRemotingMethodInfo != null) + if (s_prepForRemotingMethodInfo != null) { // PrepForRemoting is not thread-safe. When the same exception instance is thrown by multiple threads // the remote stack trace string may not format correctly. However, We don't lock this to protect us from it given // it is discouraged to throw the same exception instance from multiple threads and the side impact is ignorable. #if NET451 - prepForRemotingMethodInfo.Invoke(exception, new object[] { }); + s_prepForRemotingMethodInfo.Invoke(exception, new object[] { }); #else - prepForRemotingMethodInfo.Invoke(exception, Array.Empty()); + s_prepForRemotingMethodInfo.Invoke(exception, Array.Empty()); #endif } } @@ -89,12 +120,22 @@ public static Exception PrepareForRethrow(this Exception exception) return exception; } + /// + /// Mark the exception as ineligible for re-throwing. + /// + /// The exception to be marked as ineligible for re-throwing. + /// The exception which has been marked as ineligible for re-throwing. public static Exception DisablePrepareForRethrow(this Exception exception) { exception.Data[AsyncResult.DisablePrepareForRethrow] = string.Empty; return exception; } + /// + /// Stringify the exception, containing all relevant fields. + /// + /// The exception to stringify. + /// The stringified exception. public static string ToStringSlim(this Exception exception) { // exception.Data is empty collection by default. @@ -121,16 +162,16 @@ public static string ToStringSlim(this Exception exception) return exception.ToString(); } + /// + /// Gets the exception Id from the given exception. + /// + /// The exception. + /// The exception Id. public static string GetReferenceCode(this Exception exception) { - if (exception.Data != null && exception.Data.Contains(ExceptionIdentifierName)) - { - return (string)exception.Data[ExceptionIdentifierName]; - } - else - { - return null; - } + return exception.Data != null && exception.Data.Contains(ExceptionIdentifierName) + ? (string)exception.Data[ExceptionIdentifierName] + : null; } private static bool ShouldPrepareForRethrow(Exception exception) @@ -147,11 +188,17 @@ private static bool ShouldPrepareForRethrow(Exception exception) return true; } + /// + /// Indicates if the supplied exception is an IoT Hub exception and its error code belongs to the supplied error code list. + /// + /// The exception to test. + /// The list containing possible error codes. + /// True if the exception is an IoT Hub exception, and its error code is present in the supplied error code list; otherwise, false. public static bool CheckIotHubErrorCode(this Exception ex, params ErrorCode[] errorCodeList) { foreach (ErrorCode errorCode in errorCodeList) { - if (ex is IotHubException && ((IotHubException)ex).Code == errorCode) + if (ex is IotHubException exception && exception.Code == errorCode) { return true; } diff --git a/iothub/service/src/Common/Extensions/OtherExtensions.cs b/iothub/service/src/Common/Extensions/OtherExtensions.cs index da68f53287..ea9b990fbb 100644 --- a/iothub/service/src/Common/Extensions/OtherExtensions.cs +++ b/iothub/service/src/Common/Extensions/OtherExtensions.cs @@ -1,35 +1,54 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; + namespace Microsoft.Azure.Devices.Common.Extensions { - using System.Collections.Generic; - using System.Linq; - using System.Net.Http.Headers; - + /// + /// Extension helper methods. + /// + [Obsolete("Not recommended for external use.")] public static class OtherExtensions { + /// + /// Gets the value associated with specified key. + /// + /// The type of the value parameter. + /// The dictionary containing the specified key. + /// The key whose value to get. + /// The value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. public static T GetValueOrDefault(this IDictionary dictionary, string key) { - object o; - if (dictionary.TryGetValue(key, out o) && o is T) - { - return (T)o; - } - - return default(T); + return dictionary.TryGetValue(key, out object o) && o is T t + ? t + : default; } + /// + /// Gets the first value associated with the supplied header name. + /// + /// The collection of HTTP headers and their values. + /// The header name whose value to get. + /// The first value corresponding to the supplied header name, if the name is found in the collection; otherwise, an empty string. public static string GetFirstValueOrNull(this HttpHeaders headers, string name) { IEnumerable values = headers.GetValuesOrNull(name) ?? Enumerable.Empty(); return values.FirstOrDefault(); } + /// + /// Gets the values associated with the supplied header name. + /// + /// The collection of HTTP headers and their values. + /// The header name whose value to get. + /// The values corresponding to the supplied header name, if the name is found in the collection; otherwise, null. public static IEnumerable GetValuesOrNull(this HttpHeaders headers, string name) { - IEnumerable values; - headers.TryGetValues(name, out values); + headers.TryGetValues(name, out IEnumerable values); return values; } } diff --git a/iothub/service/src/Common/Resources.Designer.cs b/iothub/service/src/Common/Resources.Designer.cs index 2d7d47fa04..ada4cfa94c 100644 --- a/iothub/service/src/Common/Resources.Designer.cs +++ b/iothub/service/src/Common/Resources.Designer.cs @@ -180,7 +180,7 @@ internal static string CreditListenerAlreadyRegistered { } /// - /// Looks up a localized string similar to A device with ID '{0}' is already registered.. + /// Looks up a localized string similar to A device with Id '{0}' is already registered.. /// internal static string DeviceAlreadyExists { get { @@ -189,7 +189,7 @@ internal static string DeviceAlreadyExists { } /// - /// Looks up a localized string similar to Import error for device ID '{0}': {1}. + /// Looks up a localized string similar to Import error for device Id '{0}': {1}. /// internal static string DeviceImportError { get { @@ -216,7 +216,7 @@ internal static string DeviceNotFound { } /// - /// Looks up a localized string similar to A device with ID '{0}' is not registered.. + /// Looks up a localized string similar to A device with Id '{0}' is not registered.. /// internal static string DeviceNotRegistered { get { @@ -261,7 +261,7 @@ internal static string ErrorConvertingToChar { } /// - /// Looks up a localized string similar to ETag mismatch for device ID '{0}'. + /// Looks up a localized string similar to ETag mismatch for device Id '{0}'. /// internal static string ETagMismatch { get { diff --git a/iothub/service/src/Common/Resources.resx b/iothub/service/src/Common/Resources.resx index 09cdfe12b2..0d51e44d2c 100644 --- a/iothub/service/src/Common/Resources.resx +++ b/iothub/service/src/Common/Resources.resx @@ -241,19 +241,19 @@ Total number of messages on IotHub '{0}' exceeded the allocated quota. Max allowed message count : '{1}', current message count : '{2}'. Send and Receive operations are blocked for this hub until the next UTC day. Consider increasing the units for this hub to increase the quota. - A device with ID '{0}' is not registered. + A device with Id '{0}' is not registered. - A device with ID '{0}' is already registered. + A device with Id '{0}' is already registered. Internal server error. - Import error for device ID '{0}': {1} + Import error for device Id '{0}': {1} - ETag mismatch for device ID '{0}' + ETag mismatch for device Id '{0}' Invalid device format in line: {0} diff --git a/iothub/service/src/Common/WebApi/CustomHeaderConstants.cs b/iothub/service/src/Common/WebApi/CustomHeaderConstants.cs index 0c484c01b4..21e1d3f1c8 100644 --- a/iothub/service/src/Common/WebApi/CustomHeaderConstants.cs +++ b/iothub/service/src/Common/WebApi/CustomHeaderConstants.cs @@ -10,15 +10,15 @@ public static class CustomHeaderConstants { /// /// Used in message responses and feedback - /// Specifies the tracing correlation Id for the request; the resource provider *must* log this - /// so that end-to-end requests can be correlated across Azure. + /// Specifies the tracing correlation Id for the request; the resource provider *must* log this + /// so that end-to-end requests can be correlated across Azure. /// public const string CorrelationId = "iothub-correlationid"; /// - /// [Required for two way requests] Used to correlate two-way communication. + /// [Required for two way requests] Used to correlate two-way communication. /// Format: A case-sensitive string ( up to 128 char long) of ASCII 7-bit alphanumeric chars - /// + {'-', ':', '/', '\', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. + /// + {'-', ':', '/', '\', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. /// Non-alphanumeric characters are from URN RFC. /// public const string MessageId = "iothub-messageid"; @@ -55,29 +55,29 @@ public static class CustomHeaderConstants public const string UserId = "iothub-userid"; /// - /// [Optional] Used to specify the role of the message in the communication pattern. - /// Possible values: - /// “d2c”: telemetry message (device to cloud) - /// “c2d”: notification - /// “d2creq”: inquiry request - /// “d2cres”: inquiry response - /// “c2dreq”: command request + /// [Optional] Used to specify the role of the message in the communication pattern. + /// Possible values: + /// “d2c”: telemetry message (device to cloud) + /// “c2d”: notification + /// “d2creq”: inquiry request + /// “d2cres”: inquiry response + /// “c2dreq”: command request /// “c2dres”: command response /// public const string Operation = "iothub-operation"; /// - /// [Optional] Used to specify the feedback required for the consumption of the message by the device. - /// Possible values: - /// “none”: no feedback - /// “positive”: receive a feedback message if the message was consumed - /// “negative”: receive a feedback message if the message expired without being completed by the device + /// [Optional] Used to specify the feedback required for the consumption of the message by the device. + /// Possible values: + /// “none”: no feedback + /// “positive”: receive a feedback message if the message was consumed + /// “negative”: receive a feedback message if the message expired without being completed by the device /// “full”: both positive and negative /// public const string Ack = "iothub-ack"; /// - /// The lock token of the retrieved message + /// The lock token of the retrieved message /// public const string MessageLockToken = "iothub-messagelocktoken"; @@ -108,26 +108,26 @@ public static class CustomHeaderConstants /// /// x-ms-client-ip-address - /// Set to the client IP address used in the request; this is required since the resource provider + /// Set to the client IP address used in the request; this is required since the resource provider /// will not have access to the client IP. /// public const string ClientIpAddress = "x-ms-client-ip-address"; /// /// x-ms-client-principal-name - /// Set to the principal ID / UPN of the client JWT making the request. + /// Set to the principal Id / UPN of the client JWT making the request. /// public const string PrincipalName = "x-ms-client-principal-name"; /// /// x-ms-client-tenant-id - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientTenantId = "x-ms-client-tenant-id"; /// /// x-ms-client-audience - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientAudience = "x-ms-client-audience"; @@ -151,11 +151,11 @@ public static class CustomHeaderConstants /// /// x-ms-client-request-id - /// Caller-specified request ID, in the form of a GUID with no decoration such as curly braces - /// (e.g. client-request-id: 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0). - /// A caller-defined value that identifies the given request. If specified, this will be - /// included in response information as a way to map the request. - /// If the caller provides this header – the resource provider *must* log this with their + /// Caller-specified request Id, in the form of a GUID with no decoration such as curly braces + /// (e.g. client-request-id: 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0). + /// A caller-defined value that identifies the given request. If specified, this will be + /// included in response information as a way to map the request. + /// If the caller provides this header – the resource provider *must* log this with their /// traces to facilitate tracing a single request. /// public const string ClientRequestId = "x-ms-client-request-id"; diff --git a/iothub/service/src/Device.cs b/iothub/service/src/Device.cs index e0fa5793c2..7133b47c37 100644 --- a/iothub/service/src/Device.cs +++ b/iothub/service/src/Device.cs @@ -32,7 +32,7 @@ public Device(string id) } /// - /// Device ID + /// Device Id /// [JsonProperty(PropertyName = "deviceId")] public string Id { get; internal set; } diff --git a/iothub/service/src/DeviceJob.cs b/iothub/service/src/DeviceJob.cs index d21900d49c..578fd56c6c 100644 --- a/iothub/service/src/DeviceJob.cs +++ b/iothub/service/src/DeviceJob.cs @@ -1,20 +1,20 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace Microsoft.Azure.Devices -{ - using Newtonsoft.Json; - using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; - using System; +using System; +namespace Microsoft.Azure.Devices +{ /// /// Contains DeviceJob properties and their accessors. /// public class DeviceJob { /// - /// Device ID + /// Device Id /// [JsonProperty(PropertyName = "deviceId", NullValueHandling = NullValueHandling.Ignore)] public string DeviceId { get; set; } diff --git a/iothub/service/src/DeviceRegistryOperationError.cs b/iothub/service/src/DeviceRegistryOperationError.cs index e6154f1686..46f89227ea 100644 --- a/iothub/service/src/DeviceRegistryOperationError.cs +++ b/iothub/service/src/DeviceRegistryOperationError.cs @@ -1,19 +1,18 @@ -// --------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -// --------------------------------------------------------------- +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.Azure.Devices.Common.Exceptions; +using Newtonsoft.Json; namespace Microsoft.Azure.Devices { - using Microsoft.Azure.Devices.Common.Exceptions; - using Newtonsoft.Json; - /// /// Encapsulates device registry operation error details. /// public sealed class DeviceRegistryOperationError { /// - /// The ID of the device that indicated the error. + /// The Id of the device that indicated the error. /// [JsonProperty(PropertyName = "deviceId", NullValueHandling = NullValueHandling.Ignore)] public string DeviceId { get; set; } diff --git a/iothub/service/src/JobClient/JobClient.cs b/iothub/service/src/JobClient/JobClient.cs index fca8867005..82ffdc905d 100644 --- a/iothub/service/src/JobClient/JobClient.cs +++ b/iothub/service/src/JobClient/JobClient.cs @@ -52,7 +52,7 @@ public void Dispose() /// Releases unmanaged and - optionally - managed resources. /// /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected virtual void Dispose(bool disposing) {} + protected virtual void Dispose(bool disposing) { } /// /// Explicitly open the JobClient instance. @@ -65,21 +65,20 @@ protected virtual void Dispose(bool disposing) {} public abstract Task CloseAsync(); /// - /// Gets the job with the specified ID. + /// Gets the job with the specified Id. /// /// Id of the Job to retrieve /// The matching JobResponse object public abstract Task GetJobAsync(string jobId); /// - /// Gets the job with the specified ID. + /// Gets the job with the specified Id. /// /// Id of the job to retrieve /// Task cancellation token /// The matching JobResponse object public abstract Task GetJobAsync(string jobId, CancellationToken cancellationToken); - /// /// Get IQuery through which job responses for all job types and statuses are retrieved page by page /// @@ -112,13 +111,13 @@ protected virtual void Dispose(bool disposing) {} public abstract IQuery CreateQuery(JobType? jobType, JobStatus? jobStatus, int? pageSize); /// - /// Cancels/Deletes the job with the specified ID. + /// Cancels/Deletes the job with the specified Id. /// /// Id of the Job to cancel public abstract Task CancelJobAsync(string jobId); /// - /// Cancels/Deletes the job with the specified ID. + /// Cancels/Deletes the job with the specified Id. /// /// Id of the job to cancel /// Task cancellation token diff --git a/iothub/service/src/Module.cs b/iothub/service/src/Module.cs index 30d30fa5d5..802a977f81 100644 --- a/iothub/service/src/Module.cs +++ b/iothub/service/src/Module.cs @@ -37,19 +37,19 @@ public Module(string deviceId, string moduleId) } /// - /// Module ID + /// Module Id /// [JsonProperty(PropertyName = "moduleId")] public string Id { get; internal set; } /// - /// Device ID + /// Device Id /// [JsonProperty(PropertyName = "deviceId")] public string DeviceId { get; internal set; } /// - /// Modules's Generation ID + /// Modules's Generation Id /// [JsonProperty(PropertyName = "generationId")] public string GenerationId { get; internal set; } diff --git a/iothub/service/src/PurgeMessageQueueResult.cs b/iothub/service/src/PurgeMessageQueueResult.cs index 8ed73c9381..77854a7168 100644 --- a/iothub/service/src/PurgeMessageQueueResult.cs +++ b/iothub/service/src/PurgeMessageQueueResult.cs @@ -1,6 +1,5 @@ -// --------------------------------------------------------------- -// Copyright (c) Microsoft Corporation. All rights reserved. -// --------------------------------------------------------------- +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. using Newtonsoft.Json; @@ -12,7 +11,7 @@ namespace Microsoft.Azure.Devices public sealed class PurgeMessageQueueResult { /// - /// The ID of the device whose messages are being purged. + /// The Id of the device whose messages are being purged. /// [JsonProperty(PropertyName = "deviceId", Required = Required.Always)] public string DeviceId { get; set; } diff --git a/iothub/service/src/RegistryManager.cs b/iothub/service/src/RegistryManager.cs index 1a5e476085..be036bf286 100644 --- a/iothub/service/src/RegistryManager.cs +++ b/iothub/service/src/RegistryManager.cs @@ -84,7 +84,6 @@ protected virtual void Dispose(bool disposing) { } /// The Device object with the generated keys and ETags. public abstract Task AddDeviceAsync(Device device, CancellationToken cancellationToken); - /// /// Register a new module with device in the system /// @@ -546,14 +545,14 @@ protected virtual void Dispose(bool disposing) { } public abstract Task ImportDevicesAsync(JobProperties jobParameters, CancellationToken cancellationToken = default); /// - /// Gets the job with the specified ID. + /// Gets the job with the specified Id. /// /// Id of the Job object to retrieve. /// JobProperties of the job specified by the provided jobId. public abstract Task GetJobAsync(string jobId); /// - /// Gets the job with the specified ID. + /// Gets the job with the specified Id. /// /// Id of the Job object to retrieve. /// Task cancellation token. @@ -574,13 +573,13 @@ protected virtual void Dispose(bool disposing) { } public abstract Task> GetJobsAsync(CancellationToken cancellationToken); /// - /// Cancels/Deletes the job with the specified ID. + /// Cancels/Deletes the job with the specified Id. /// /// Id of the job to cancel. public abstract Task CancelJobAsync(string jobId); /// - /// Cancels/Deletes the job with the specified ID. + /// Cancels/Deletes the job with the specified Id. /// /// Id of the job to cancel. /// Task cancellation token. diff --git a/nuget.config b/nuget.config index b181aea9d5..59fd926945 100644 --- a/nuget.config +++ b/nuget.config @@ -9,6 +9,7 @@ - + + \ No newline at end of file diff --git a/provisioning/device/src/DeviceRegistrationResult.cs b/provisioning/device/src/DeviceRegistrationResult.cs index 310e8b0b79..b9789cad6f 100644 --- a/provisioning/device/src/DeviceRegistrationResult.cs +++ b/provisioning/device/src/DeviceRegistrationResult.cs @@ -32,22 +32,22 @@ public DeviceRegistrationResult( { } - /// - /// Used internally by the SDK to create a new instance of the DeviceRegistrationResult class. - /// This constructor is exposed to allow serialization and unit testing of applications using this SDK. - /// - public DeviceRegistrationResult( - string registrationId, - DateTime? createdDateTimeUtc, - string assignedHub, - string deviceId, - ProvisioningRegistrationStatusType status, - ProvisioningRegistrationSubstatusType substatus, - string generationId, - DateTime? lastUpdatedDateTimeUtc, - int errorCode, - string errorMessage, - string etag) + /// + /// Used internally by the SDK to create a new instance of the DeviceRegistrationResult class. + /// This constructor is exposed to allow serialization and unit testing of applications using this SDK. + /// + public DeviceRegistrationResult( + string registrationId, + DateTime? createdDateTimeUtc, + string assignedHub, + string deviceId, + ProvisioningRegistrationStatusType status, + ProvisioningRegistrationSubstatusType substatus, + string generationId, + DateTime? lastUpdatedDateTimeUtc, + int errorCode, + string errorMessage, + string etag) { RegistrationId = registrationId; CreatedDateTimeUtc = createdDateTimeUtc; @@ -62,22 +62,22 @@ public DeviceRegistrationResult( Etag = etag; } - /// - ///. Constructor to allow return data - /// - public DeviceRegistrationResult( - string registrationId, - DateTime? createdDateTimeUtc, - string assignedHub, - string deviceId, - ProvisioningRegistrationStatusType status, - ProvisioningRegistrationSubstatusType substatus, - string generationId, - DateTime? lastUpdatedDateTimeUtc, - int errorCode, - string errorMessage, - string etag, - string returnData) + /// + ///. Constructor to allow return data + /// + public DeviceRegistrationResult( + string registrationId, + DateTime? createdDateTimeUtc, + string assignedHub, + string deviceId, + ProvisioningRegistrationStatusType status, + ProvisioningRegistrationSubstatusType substatus, + string generationId, + DateTime? lastUpdatedDateTimeUtc, + int errorCode, + string errorMessage, + string etag, + string returnData) { RegistrationId = registrationId; CreatedDateTimeUtc = createdDateTimeUtc; @@ -92,6 +92,7 @@ public DeviceRegistrationResult( Etag = etag; JsonPayload = returnData; } + /// /// The registration id. /// @@ -108,7 +109,7 @@ public DeviceRegistrationResult( public string AssignedHub { get; protected set; } /// - /// The Device ID. + /// The Device Id. /// public string DeviceId { get; protected set; } @@ -123,7 +124,7 @@ public DeviceRegistrationResult( public ProvisioningRegistrationSubstatusType Substatus { get; protected set; } /// - /// The generation ID. + /// The generation Id. /// public string GenerationId { get; protected set; } diff --git a/provisioning/device/src/ProvisioningErrorDetails.cs b/provisioning/device/src/ProvisioningErrorDetails.cs index 11d305ac4a..9c61f19ac0 100644 --- a/provisioning/device/src/ProvisioningErrorDetails.cs +++ b/provisioning/device/src/ProvisioningErrorDetails.cs @@ -21,7 +21,7 @@ public class ProvisioningErrorDetails public int ErrorCode { get; set; } /// - /// Correlation ID. + /// Correlation Id. /// [JsonProperty(PropertyName = "trackingId")] public string TrackingId { get; set; } @@ -38,6 +38,7 @@ public class ProvisioningErrorDetails [JsonProperty(PropertyName = "info", NullValueHandling = NullValueHandling.Ignore)] #pragma warning disable CA2227 // Collection properties should be read only public Dictionary Info { get; set; } + #pragma warning restore CA2227 // Collection properties should be read only /// diff --git a/provisioning/device/src/ProvisioningRegistrationStatus.cs b/provisioning/device/src/ProvisioningRegistrationStatus.cs index af7e700e54..a61605e9f5 100644 --- a/provisioning/device/src/ProvisioningRegistrationStatus.cs +++ b/provisioning/device/src/ProvisioningRegistrationStatus.cs @@ -14,12 +14,12 @@ public enum ProvisioningRegistrationStatusType Unassigned = 1, /// - /// Device has connected to the DRS but IoT Hub ID has not yet been returned to the device + /// Device has connected to the DRS but IoT Hub Id has not yet been returned to the device /// Assigning = 2, /// - /// DRS successfully returned a device ID and connection string to the device + /// DRS successfully returned a device Id and connection string to the device /// Assigned = 3, diff --git a/provisioning/device/src/ProvisioningTransportException.cs b/provisioning/device/src/ProvisioningTransportException.cs index 1d27a5d048..209173fd59 100644 --- a/provisioning/device/src/ProvisioningTransportException.cs +++ b/provisioning/device/src/ProvisioningTransportException.cs @@ -19,7 +19,7 @@ public class ProvisioningTransportException : Exception public bool IsTransient { get; private set; } /// - /// Service reported Tracking ID. Use this when reporting a Service issue. + /// Service reported Tracking Id. Use this when reporting a Service issue. /// public string TrackingId { get; set; } @@ -79,7 +79,7 @@ public ProvisioningTransportException(string message, Exception innerException, /// /// The exception message. /// True if the error is transient. - /// The service tracking ID. + /// The service tracking Id. /// The inner exception. public ProvisioningTransportException(string message, Exception innerException, bool isTransient, string trackingId) : base(message, innerException) diff --git a/provisioning/service/src/Config/BulkEnrollmentOperationError.cs b/provisioning/service/src/Config/BulkEnrollmentOperationError.cs index 825d7cff31..e811d398d8 100644 --- a/provisioning/service/src/Config/BulkEnrollmentOperationError.cs +++ b/provisioning/service/src/Config/BulkEnrollmentOperationError.cs @@ -10,7 +10,7 @@ namespace Microsoft.Azure.Devices.Provisioning.Service /// Representation of a single Device Provisioning Service device registration operation error. /// /// - /// This error is returned as a result of the + /// This error is returned as a result of the /// /// as part of the . /// @@ -29,7 +29,7 @@ public class BulkEnrollmentOperationError /* SRS_BULK_ENROLLMENT_OPERATION_ERRO_21_002: [The BulkEnrollmentOperationError shall store the provided information.] */ /// - /// Registration ID. + /// Registration Id. /// /// /// A valid registration Id shall be alphanumeric, lowercase, and may contain hyphens. Max characters 128. @@ -45,11 +45,12 @@ public string RegistrationId private set { - /* SRS_BULK_ENROLLMENT_OPERATION_ERRO_21_001: [The BulkEnrollmentOperationError shall throws JsonSerializationException if the + /* SRS_BULK_ENROLLMENT_OPERATION_ERRO_21_001: [The BulkEnrollmentOperationError shall throws JsonSerializationException if the provided registrationId is null, empty, or invalid.] */ _registrationId = value; } } + private string _registrationId; /// diff --git a/provisioning/service/src/Config/DeviceRegistrationState.cs b/provisioning/service/src/Config/DeviceRegistrationState.cs index 2a8ecbf162..e4d64c83b9 100644 --- a/provisioning/service/src/Config/DeviceRegistrationState.cs +++ b/provisioning/service/src/Config/DeviceRegistrationState.cs @@ -15,14 +15,14 @@ public class DeviceRegistrationState /// /// Creates a new instance of /// - /// Registration ID + /// Registration Id public DeviceRegistrationState(string registrationId) { this.RegistrationId = registrationId; } /// - /// Registration ID. + /// Registration Id. /// [JsonProperty(PropertyName = "registrationId", DefaultValueHandling = DefaultValueHandling.Ignore)] public string RegistrationId { get; internal set; } @@ -46,7 +46,7 @@ public DeviceRegistrationState(string registrationId) public string AssignedHub { get; internal set; } /// - /// Device ID. + /// Device Id. /// [JsonProperty(PropertyName = "deviceId", DefaultValueHandling = DefaultValueHandling.Ignore)] public string DeviceId { get; internal set; } @@ -75,5 +75,4 @@ public DeviceRegistrationState(string registrationId) [JsonProperty(PropertyName = "etag", DefaultValueHandling = DefaultValueHandling.Ignore)] public string ETag { get; internal set; } } - } diff --git a/provisioning/service/src/Config/EnrollmentGroup.cs b/provisioning/service/src/Config/EnrollmentGroup.cs index 1e6ca7de73..f7445bd90c 100644 --- a/provisioning/service/src/Config/EnrollmentGroup.cs +++ b/provisioning/service/src/Config/EnrollmentGroup.cs @@ -216,7 +216,7 @@ public override string ToString() } /// - /// Enrollment Group ID. + /// Enrollment Group Id. /// /// /// A valid enrollmentGroup Id shall be alphanumeric, lowercase, and may contain hyphens. Max characters 128. diff --git a/provisioning/service/src/Config/EnrollmentStatus.cs b/provisioning/service/src/Config/EnrollmentStatus.cs index fd83efbe76..a3fe91bda5 100644 --- a/provisioning/service/src/Config/EnrollmentStatus.cs +++ b/provisioning/service/src/Config/EnrollmentStatus.cs @@ -23,13 +23,13 @@ public enum EnrollmentStatus Unassigned = 1, /// - /// Device has connected to the DRS but IoT Hub ID has not yet been returned to the device + /// Device has connected to the DRS but IoT Hub Id has not yet been returned to the device /// [EnumMember(Value = "assigning")] Assigning = 2, /// - /// DRS successfully returned a device ID and connection string to the device + /// DRS successfully returned a device Id and connection string to the device /// [EnumMember(Value = "assigned")] Assigned = 3, diff --git a/provisioning/service/src/Config/IndividualEnrollment.cs b/provisioning/service/src/Config/IndividualEnrollment.cs index 8cbcc56284..6d955e3f70 100644 --- a/provisioning/service/src/Config/IndividualEnrollment.cs +++ b/provisioning/service/src/Config/IndividualEnrollment.cs @@ -194,7 +194,7 @@ public override string ToString() } /// - /// Registration ID. + /// Registration Id. /// /// /// A valid registration Id shall be alphanumeric, lowercase, and may contain hyphens. Max characters 128. @@ -217,7 +217,7 @@ private set private string _registrationId; /// - /// Desired IoT Hub device ID (optional). + /// Desired IoT Hub device Id (optional). /// [JsonProperty(PropertyName = "deviceId", DefaultValueHandling = DefaultValueHandling.Ignore)] public string DeviceId diff --git a/provisioning/service/src/Config/ReprovisionPolicy.cs b/provisioning/service/src/Config/ReprovisionPolicy.cs index df8b3ff30a..0db016b1ef 100644 --- a/provisioning/service/src/Config/ReprovisionPolicy.cs +++ b/provisioning/service/src/Config/ReprovisionPolicy.cs @@ -19,10 +19,10 @@ public class ReprovisionPolicy public bool UpdateHubAssignment { get; set; } /// - /// When set to true (default), the Device Provisioning Service will migrate the device's data (twin, device capabilities, and device ID) from one IoT hub to another during an IoT hub assignment update. + /// When set to true (default), the Device Provisioning Service will migrate the device's data (twin, device capabilities, and device Id) from one IoT hub to another during an IoT hub assignment update. /// If set to false, the Device Provisioning Service will reset the device's data to the initial desired configuration stored in the provisioning service's enrollment list. /// [JsonProperty(PropertyName = "migrateDeviceData", DefaultValueHandling = DefaultValueHandling.Include)] public bool MigrateDeviceData { get; set; } } -} \ No newline at end of file +} diff --git a/provisioning/service/src/Contract/CustomHeaderConstants.cs b/provisioning/service/src/Contract/CustomHeaderConstants.cs index 6e8e0d300b..5b66cd0db7 100644 --- a/provisioning/service/src/Contract/CustomHeaderConstants.cs +++ b/provisioning/service/src/Contract/CustomHeaderConstants.cs @@ -7,15 +7,15 @@ internal static class CustomHeaderConstants { /// /// Used in message responses and feedback - /// Specifies the tracing correlation Id for the request; the resource provider *must* log this - /// so that end-to-end requests can be correlated across Azure. + /// Specifies the tracing correlation Id for the request; the resource provider *must* log this + /// so that end-to-end requests can be correlated across Azure. /// public const string CorrelationId = "iothub-correlationid"; /// - /// [Required for two way requests] Used to correlate two-way communication. + /// [Required for two way requests] Used to correlate two-way communication. /// Format: A case-sensitive string ( up to 128 char long) of ASCII 7-bit alphanumeric chars - /// + {'-', ':', '/', '\', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. + /// + {'-', ':', '/', '\', '.', '+', '%', '_', '#', '*', '?', '!', '(', ')', ',', '=', '@', ';', '$', '''}. /// Non-alphanumeric characters are from URN RFC. /// public const string MessageId = "iothub-messageid"; @@ -52,29 +52,29 @@ internal static class CustomHeaderConstants public const string UserId = "iothub-userid"; /// - /// [Optional] Used to specify the role of the message in the communication pattern. - /// Possible values: - /// “d2c”: telemetry message (device to cloud) - /// “c2d”: notification - /// “d2creq”: inquiry request - /// “d2cres”: inquiry response - /// “c2dreq”: command request + /// [Optional] Used to specify the role of the message in the communication pattern. + /// Possible values: + /// “d2c”: telemetry message (device to cloud) + /// “c2d”: notification + /// “d2creq”: inquiry request + /// “d2cres”: inquiry response + /// “c2dreq”: command request /// “c2dres”: command response /// public const string Operation = "iothub-operation"; /// - /// [Optional] Used to specify the feedback required for the consumption of the message by the device. - /// Possible values: - /// “none”: no feedback - /// “positive”: receive a feedback message if the message was consumed - /// “negative”: receive a feedback message if the message expired without being completed by the device + /// [Optional] Used to specify the feedback required for the consumption of the message by the device. + /// Possible values: + /// “none”: no feedback + /// “positive”: receive a feedback message if the message was consumed + /// “negative”: receive a feedback message if the message expired without being completed by the device /// “full”: both positive and negative /// public const string Ack = "iothub-ack"; /// - /// The lock token of the retrieved message + /// The lock token of the retrieved message /// public const string MessageLockToken = "iothub-messagelocktoken"; @@ -99,26 +99,26 @@ internal static class CustomHeaderConstants /// /// x-ms-client-ip-address - /// Set to the client IP address used in the request; this is required since the resource provider + /// Set to the client IP address used in the request; this is required since the resource provider /// will not have access to the client IP. /// public const string ClientIpAddress = "x-ms-client-ip-address"; /// /// x-ms-client-principal-name - /// Set to the principal ID / UPN of the client JWT making the request. + /// Set to the principal Id / UPN of the client JWT making the request. /// public const string PrincipalName = "x-ms-client-principal-name"; /// /// x-ms-client-tenant-id - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientTenantId = "x-ms-client-tenant-id"; /// /// x-ms-client-audience - /// Set to the tenant ID of the client JWT making the request. + /// Set to the tenant Id of the client JWT making the request. /// public const string ClientAudience = "x-ms-client-audience"; @@ -142,11 +142,11 @@ internal static class CustomHeaderConstants /// /// x-ms-client-request-id - /// Caller-specified request ID, in the form of a GUID with no decoration such as curly braces - /// (e.g. client-request-id: 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0). - /// A caller-defined value that identifies the given request. If specified, this will be - /// included in response information as a way to map the request. - /// If the caller provides this header – the resource provider *must* log this with their + /// Caller-specified request Id, in the form of a GUID with no decoration such as curly braces + /// (e.g. client-request-id: 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0). + /// A caller-defined value that identifies the given request. If specified, this will be + /// included in response information as a way to map the request. + /// If the caller provides this header – the resource provider *must* log this with their /// traces to facilitate tracing a single request. /// public const string ClientRequestId = "x-ms-client-request-id"; diff --git a/provisioning/service/src/ProvisioningServiceClient.cs b/provisioning/service/src/ProvisioningServiceClient.cs index 7c55088557..55d3328643 100644 --- a/provisioning/service/src/ProvisioningServiceClient.cs +++ b/provisioning/service/src/ProvisioningServiceClient.cs @@ -326,7 +326,7 @@ public Task GetIndividualEnrollmentAsync(string registrati /// /// Gets the individual enrollment object. /// - /// The registration ID. + /// The registration Id. /// The cancellation token. /// public Task GetIndividualEnrollmentAsync(string registrationId, CancellationToken cancellationToken) diff --git a/security/tpm/src/SecurityProviderTpmHsm.cs b/security/tpm/src/SecurityProviderTpmHsm.cs index 86f949eba0..5f2717a5b5 100644 --- a/security/tpm/src/SecurityProviderTpmHsm.cs +++ b/security/tpm/src/SecurityProviderTpmHsm.cs @@ -34,13 +34,13 @@ public class SecurityProviderTpmHsm : SecurityProviderTpm /// /// Initializes a new instance of the SecurityProviderTpmHsm class using the system TPM. /// - /// The Device Provisioning Service Registration ID. + /// The Device Provisioning Service Registration Id. public SecurityProviderTpmHsm(string registrationId) : this(registrationId, CreateDefaultTpm2Device()) { } /// /// Initializes a new instance of the SecurityProviderTpmHsm class using the specified TPM module. /// - /// The Device Provisioning Service Registration ID. + /// The Device Provisioning Service Registration Id. /// The TPM device. public SecurityProviderTpmHsm(string registrationId, Tpm2Device tpm) : base(registrationId) { diff --git a/shared/src/SecurityProvider.cs b/shared/src/SecurityProvider.cs index 9d4768fb14..ee4d8c3351 100644 --- a/shared/src/SecurityProvider.cs +++ b/shared/src/SecurityProvider.cs @@ -11,7 +11,7 @@ namespace Microsoft.Azure.Devices.Shared public abstract class SecurityProvider : IDisposable { /// - /// Gets the Registration ID used during device enrollment. + /// Gets the Registration Id used during device enrollment. /// public abstract string GetRegistrationID(); diff --git a/shared/src/SecurityProviderSymmetricKey.cs b/shared/src/SecurityProviderSymmetricKey.cs index 30d07ee266..8eee6f41fb 100644 --- a/shared/src/SecurityProviderSymmetricKey.cs +++ b/shared/src/SecurityProviderSymmetricKey.cs @@ -17,7 +17,7 @@ public class SecurityProviderSymmetricKey : SecurityProvider /// /// Initializes a new instance of the SecurityProviderSymmetricKey class. /// - /// The Provisioning service Registration ID for this device. + /// The Provisioning service Registration Id for this device. /// The primary key for this device. /// The secondary key for this device. public SecurityProviderSymmetricKey(string registrationId, string primaryKey, string secondaryKey) @@ -28,7 +28,7 @@ public SecurityProviderSymmetricKey(string registrationId, string primaryKey, st } /// - /// Gets the Registration ID used during device enrollment. + /// Gets the Registration Id used during device enrollment. /// public override string GetRegistrationID() { @@ -53,4 +53,4 @@ public override string GetRegistrationID() /// true to release both managed and unmanaged resources; false to releases only unmanaged resources. protected override void Dispose(bool disposing) { } } -} \ No newline at end of file +} diff --git a/shared/src/SecurityProviderTpm.cs b/shared/src/SecurityProviderTpm.cs index 8320e52683..faeebdb909 100644 --- a/shared/src/SecurityProviderTpm.cs +++ b/shared/src/SecurityProviderTpm.cs @@ -13,14 +13,14 @@ public abstract class SecurityProviderTpm : SecurityProvider /// /// Initializes a new instance of the SecurityProviderTpm class. /// - /// The Provisioning service Registration ID for this device. + /// The Provisioning service Registration Id for this device. public SecurityProviderTpm(string registrationId) { _registrationId = registrationId; } /// - /// Gets the Registration ID used during device enrollment. + /// Gets the Registration Id used during device enrollment. /// public override string GetRegistrationID() { diff --git a/shared/src/StringFormattingExtensions.cs b/shared/src/StringFormattingExtensions.cs index 1a51b77812..3d5691af9e 100644 --- a/shared/src/StringFormattingExtensions.cs +++ b/shared/src/StringFormattingExtensions.cs @@ -38,7 +38,7 @@ public static string FormatInvariant(this string format, params object[] args) /// Format string to be displayed as an error. /// /// The message. - /// The activity ID. + /// The activity Id. /// The error code. /// A copy of format in which the format item or items have been replaced by the string representation of arg0. public static string FormatErrorForUser(this string message, string activityId, int errorCode)