From 9dde00691219e03b72f3230205aa99bf268d0e43 Mon Sep 17 00:00:00 2001 From: "David R. Williamson" Date: Mon, 9 Aug 2021 14:49:32 -0700 Subject: [PATCH] refactor(iot-device, prov-mqtt): Target new DotNetty version when not net451 (#2129) --- .../src/Microsoft.Azure.Devices.Client.csproj | 6 +- ...icrosoft.Azure.Devices.Client.Tests.csproj | 20 +++---- .../src/Config/IndividualEnrollment.cs | 55 +++---------------- ...Devices.Provisioning.Transport.Mqtt.csproj | 4 +- 4 files changed, 22 insertions(+), 63 deletions(-) diff --git a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj index c16021849f..4d593866d8 100644 --- a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj +++ b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj @@ -68,6 +68,8 @@ + + @@ -75,6 +77,8 @@ + + @@ -82,8 +86,6 @@ - - diff --git a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj index 3928ef3cfa..ea152b0a59 100644 --- a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj +++ b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj @@ -14,13 +14,17 @@ HsmAuthentication/**;$(DefaultItemExcludes) - - + + + + + + @@ -30,20 +34,12 @@ + + - - - - - - - - - - diff --git a/provisioning/service/src/Config/IndividualEnrollment.cs b/provisioning/service/src/Config/IndividualEnrollment.cs index 6d955e3f70..a45455a655 100644 --- a/provisioning/service/src/Config/IndividualEnrollment.cs +++ b/provisioning/service/src/Config/IndividualEnrollment.cs @@ -156,8 +156,6 @@ internal IndividualEnrollment( string eTag, DeviceCapabilities capabilities) { - /* SRS_INDIVIDUAL_ENROLLMENT_21_003: [The constructor shall throws ProvisioningServiceClientException if one of the - provided parameters in JSON is not valid.] */ if (attestation == null) { throw new ProvisioningServiceClientException("Service respond an individualEnrollment without attestation."); @@ -189,8 +187,7 @@ provided parameters in JSON is not valid.] */ /// The string with the content of this class in a pretty print format. public override string ToString() { - string jsonPrettyPrint = Newtonsoft.Json.JsonConvert.SerializeObject(this, Formatting.Indented); - return jsonPrettyPrint; + return JsonConvert.SerializeObject(this, Formatting.Indented); } /// @@ -201,46 +198,13 @@ public override string ToString() /// /// if the provided string does not fit the registration Id requirements [JsonProperty(PropertyName = "registrationId")] - public string RegistrationId - { - get - { - return _registrationId; - } - - private set - { - _registrationId = value; - } - } - - private string _registrationId; + public string RegistrationId { get; private set; } /// /// Desired IoT Hub device Id (optional). /// [JsonProperty(PropertyName = "deviceId", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string DeviceId - { - get - { - return _deviceId; - } - - set - { - if (value == null) - { - _deviceId = null; - } - else - { - _deviceId = value; - } - } - } - - private string _deviceId; + public string DeviceId { get; set; } /// /// Current registration state. @@ -260,19 +224,16 @@ public string DeviceId [JsonIgnore] public Attestation Attestation { - get - { - return _attestation.GetAttestation(); - } + get => _attestation.GetAttestation(); set { - if (value is X509Attestation) + if (value is X509Attestation attestation) { - if ((((X509Attestation)value ?? throw new ArgumentNullException(nameof(value))).ClientCertificates == null) && - (((X509Attestation)value).CAReferences == null)) + if ((attestation ?? throw new ArgumentNullException(nameof(value))).ClientCertificates == null + && attestation.CAReferences == null) { - throw new ArgumentNullException($"{nameof(value)} do not contains client certificate or CA reference."); + throw new ArgumentNullException(nameof(value), $"Value does not contain client certificate or CA reference."); } } diff --git a/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj b/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj index c252253120..7bd8a388f6 100644 --- a/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj +++ b/provisioning/transport/mqtt/src/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.csproj @@ -97,8 +97,8 @@ - - + +