From 96a1b3e2d8b382080ca760fc64bc537919952dc3 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Wed, 20 Nov 2024 20:44:29 -0800 Subject: [PATCH 01/10] feat(iot-serv): Add ability to send custom authentication scopes for RBAC auth Previously, the SDK hardcoded just "https://iothubs.azure.net/.default" as the only supported scope, but this does not work for non-public clouds --- .../IotHubTokenCredentialProperties.cs | 13 +++++++-- .../DigitalTwinTokenCredential.cs | 11 ++++++- .../src/DigitalTwin/DigitalTwinClient.cs | 27 +++++++++++++++++ iothub/service/src/Jobs/JobClient.cs | 25 +++++++++++++++- iothub/service/src/Messaging/ServiceClient.cs | 29 ++++++++++++++++++- .../service/src/Registry/RegistryManager.cs | 25 +++++++++++++++- 6 files changed, 124 insertions(+), 6 deletions(-) diff --git a/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs b/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs index 1efa16ecf2..20d1a9323c 100644 --- a/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs +++ b/iothub/service/src/Authentication/IotHubTokenCredentialProperties.cs @@ -26,6 +26,8 @@ internal class IotHubTokenCrendentialProperties private readonly TokenCredential _credential; private readonly object _tokenLock = new object(); private AccessToken? _cachedAccessToken; + private string[] _scopes; + #endif #if NET451 @@ -39,6 +41,13 @@ public IotHubTokenCrendentialProperties() public IotHubTokenCrendentialProperties(string hostName, TokenCredential credential) : base(hostName) { _credential = credential; + _scopes = CommonConstants.IotHubAadTokenScopes; + } + + public IotHubTokenCrendentialProperties(string hostName, TokenCredential credential, string[] scopes) : base(hostName) + { + _credential = credential; + _scopes = scopes; } #endif @@ -57,7 +66,7 @@ public override string GetAuthorizationHeader() || TokenHelper.IsCloseToExpiry(_cachedAccessToken.Value.ExpiresOn)) { _cachedAccessToken = _credential.GetToken( - new TokenRequestContext(CommonConstants.IotHubAadTokenScopes), + new TokenRequestContext(_scopes), new CancellationToken()); } } @@ -69,7 +78,7 @@ public override string GetAuthorizationHeader() #pragma warning disable CS1998 // Disabled as we need to throw exception for NET 451. // The AMQP protocol uses this method to get a CBS token for authentication. - public async override Task GetTokenAsync(Uri namespaceAddress, string appliesTo, string[] requiredClaims) + public override async Task GetTokenAsync(Uri namespaceAddress, string appliesTo, string[] requiredClaims) { #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously #if NET451 diff --git a/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs b/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs index 51a816e4b4..adaaa75157 100644 --- a/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs +++ b/iothub/service/src/DigitalTwin/Authentication/DigitalTwinTokenCredential.cs @@ -1,6 +1,7 @@ // 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.Threading; using Azure.Core; using Microsoft.Azure.Devices.Authentication; @@ -18,10 +19,18 @@ internal class DigitalTwinTokenCredential : DigitalTwinServiceClientCredentials private readonly object _tokenLock = new object(); private AccessToken? _cachedAccessToken; private readonly TokenCredential _credential; + private string[] _scopes; public DigitalTwinTokenCredential(TokenCredential credential) { _credential = credential; + _scopes = CommonConstants.IotHubAadTokenScopes; + } + + public DigitalTwinTokenCredential(TokenCredential credential, string[] scopes) + { + _credential = credential; + _scopes = scopes; } public override string GetAuthorizationHeader() @@ -33,7 +42,7 @@ public override string GetAuthorizationHeader() || TokenHelper.IsCloseToExpiry(_cachedAccessToken.Value.ExpiresOn)) { _cachedAccessToken = _credential.GetToken( - new TokenRequestContext(CommonConstants.IotHubAadTokenScopes), + new TokenRequestContext(_scopes), new CancellationToken()); } } diff --git a/iothub/service/src/DigitalTwin/DigitalTwinClient.cs b/iothub/service/src/DigitalTwin/DigitalTwinClient.cs index d5e5c131cc..384750042a 100644 --- a/iothub/service/src/DigitalTwin/DigitalTwinClient.cs +++ b/iothub/service/src/DigitalTwin/DigitalTwinClient.cs @@ -8,6 +8,7 @@ using Azure; using Azure.Core; using Microsoft.Azure.Devices.Authentication; +using Microsoft.Azure.Devices.Common; using Microsoft.Azure.Devices.DigitalTwin.Authentication; using Microsoft.Azure.Devices.Extensions; using Microsoft.Azure.Devices.Generated; @@ -82,6 +83,32 @@ public static DigitalTwinClient Create( string hostName, TokenCredential credential, params DelegatingHandler[] handlers) + { + return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, handlers); + } + + /// + /// Creates DigitalTwinClient, authenticating using an identity in Azure Active Directory (AAD). + /// + /// + /// For more about information on the options of authenticating using a derived instance of , see + /// . + /// For more information on configuring IoT hub with Azure Active Directory, see + /// + /// + /// IoT hub host name. + /// Azure Active Directory (AAD) credentials to authenticate with IoT hub. See + /// + /// The delegating handlers to add to the http client pipeline. You can add handlers for tracing, + /// implementing a retry strategy, routing requests through a proxy, etc. + /// + /// The custom scopes to use when authenticating. + /// A DigitalTwinsClient instance. + public static DigitalTwinClient Create( + string hostName, + TokenCredential credential, + string[] scopes, + params DelegatingHandler[] handlers) { if (string.IsNullOrEmpty(hostName)) { diff --git a/iothub/service/src/Jobs/JobClient.cs b/iothub/service/src/Jobs/JobClient.cs index 343b132517..84f1c98e70 100644 --- a/iothub/service/src/Jobs/JobClient.cs +++ b/iothub/service/src/Jobs/JobClient.cs @@ -117,6 +117,29 @@ public static JobClient Create( string hostName, TokenCredential credential, HttpTransportSettings transportSettings = default) + { + return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportSettings); + } + + /// + /// Creates JobClient, authenticating using an identity in Azure Active Directory (AAD). + /// + /// + /// For more about information on the options of authenticating using a derived instance of , see + /// . + /// For more information on configuring IoT hub with Azure Active Directory, see + /// + /// + /// IoT hub host name. + /// Azure Active Directory (AAD) credentials to authenticate with IoT hub. See + /// The HTTP transport settings. + /// The custom scopes to authenticate with. + /// A JobClient instance. + public static JobClient Create( + string hostName, + TokenCredential credential, + string[] scopes, + HttpTransportSettings transportSettings = default) { if (string.IsNullOrEmpty(hostName)) { @@ -128,7 +151,7 @@ public static JobClient Create( throw new ArgumentNullException(nameof(credential)); } - var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential); + var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes); return new JobClient(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings()); } diff --git a/iothub/service/src/Messaging/ServiceClient.cs b/iothub/service/src/Messaging/ServiceClient.cs index 5a800abed6..42147809f9 100644 --- a/iothub/service/src/Messaging/ServiceClient.cs +++ b/iothub/service/src/Messaging/ServiceClient.cs @@ -155,6 +155,33 @@ public static ServiceClient Create( TransportType transportType = TransportType.Amqp, ServiceClientTransportSettings transportSettings = default, ServiceClientOptions options = default) + { + return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportType, transportSettings, options); + } + + /// + /// Creates ServiceClient, authenticating using an identity in Azure Active Directory (AAD). + /// + /// + /// For more about information on the options of authenticating using a derived instance of , see + /// . + /// For more information on configuring IoT hub with Azure Active Directory, see + /// + /// + /// IoT hub host name. + /// Azure Active Directory credentials to authenticate with IoT hub. See + /// Specifies whether Amqp or Amqp_WebSocket_Only transport is used. + /// The custom scopes to use when authenticating. + /// Specifies the AMQP_WS and HTTP proxy settings for service client. + /// The options that allow configuration of the service client instance during initialization. + /// A ServiceClient instance. + public static ServiceClient Create( + string hostName, + TokenCredential credential, + string[] scopes, + TransportType transportType = TransportType.Amqp, + ServiceClientTransportSettings transportSettings = default, + ServiceClientOptions options = default) { if (string.IsNullOrEmpty(hostName)) { @@ -166,7 +193,7 @@ public static ServiceClient Create( throw new ArgumentNullException($"{nameof(credential)}, Parameter cannot be null"); } - var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential); + var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes); bool useWebSocketOnly = transportType == TransportType.Amqp_WebSocket_Only; return new ServiceClient( diff --git a/iothub/service/src/Registry/RegistryManager.cs b/iothub/service/src/Registry/RegistryManager.cs index ec0fd11e78..9734c0dbf2 100644 --- a/iothub/service/src/Registry/RegistryManager.cs +++ b/iothub/service/src/Registry/RegistryManager.cs @@ -153,6 +153,29 @@ public static RegistryManager Create( string hostName, TokenCredential credential, HttpTransportSettings transportSettings = default) + { + return Create(hostName, credential, CommonConstants.IotHubAadTokenScopes, transportSettings); + } + + /// + /// Creates RegistryManager, authenticating using an identity in Azure Active Directory (AAD). + /// + /// + /// For more about information on the options of authenticating using a derived instance of , see + /// . + /// For more information on configuring IoT hub with Azure Active Directory, see + /// + /// + /// IoT hub host name. + /// Azure Active Directory (AAD) credentials to authenticate with IoT hub. + /// The HTTP transport settings. + /// The custom scopes to use when authenticating. + /// A RegistryManager instance. + public static RegistryManager Create( + string hostName, + TokenCredential credential, + string[] scopes, + HttpTransportSettings transportSettings = default) { if (string.IsNullOrEmpty(hostName)) { @@ -164,7 +187,7 @@ public static RegistryManager Create( throw new ArgumentNullException($"{nameof(credential)}, Parameter cannot be null"); } - var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential); + var tokenCredentialProperties = new IotHubTokenCrendentialProperties(hostName, credential, scopes); return new RegistryManager(tokenCredentialProperties, transportSettings ?? new HttpTransportSettings()); } From 5f1604ec248bddf3ffce1d5112b40999f09639ce Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:09:37 -0800 Subject: [PATCH 02/10] Update codeowners file --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c08162d664..48d599d1e5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # Track1 .NET Azure IoT Hub and DPS SDKs -* @timtay-microsoft @abhipsaMisra @andyk-ms @brycewang-microsoft @tmahmood-microsoft @patilsnr +* @timtay-microsoft @lev-i @olivakar From b1096c97406c3b94ac96f14d58c41ba7f76001e0 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:21:21 -0800 Subject: [PATCH 03/10] add Avishek as codeowner --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 48d599d1e5..bd324605f8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,3 +1,3 @@ # Track1 .NET Azure IoT Hub and DPS SDKs -* @timtay-microsoft @lev-i @olivakar +* @timtay-microsoft @lev-i @olivakar @avishekpant From ccdbef8e7dbd4fdb59bd2e8219095334091cd872 Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:25:51 -0800 Subject: [PATCH 04/10] Update out-of-date nuget dependencies --- e2e/test/E2ETests.csproj | 1 + .../FileUploadSample/FileUploadSample.csproj | 2 +- .../MethodSample/MethodSample.csproj | 2 +- .../SimulatedDevice/SimulatedDevice.csproj | 2 +- .../SimulatedDeviceWithCommand.csproj | 2 +- .../DeviceReconnectionSample.csproj | 1 + .../PnpConvention/PnpHelpers.csproj | 8 ++++---- .../TemperatureController.csproj | 3 ++- .../PnpDeviceSamples/Thermostat/Thermostat.csproj | 3 ++- .../src/Microsoft.Azure.Devices.Client.csproj | 10 +++++----- .../Microsoft.Azure.Devices.Client.Tests.csproj | 14 +++++++------- .../EdgeDeploymentSample.csproj | 2 +- .../FileUploadNotificationReceiverSample.csproj | 2 +- .../InvokeDeviceMethod/InvokeDeviceMethod.csproj | 2 +- .../getting started/JobsSample/JobsSample.csproj | 2 +- .../ReadD2cMessages/ReadD2cMessages.csproj | 2 +- .../ServiceClientSample/ServiceClientSample.csproj | 1 + .../AzureSasCredentialAuthenticationSample.csproj | 2 +- .../CleanupDevicesSample.csproj | 2 +- .../ImportExportDevicesSample.csproj | 2 +- .../RoleBasedAuthenticationSample.csproj | 4 ++-- .../TemperatureController.csproj | 3 ++- .../Thermostat/Thermostat.csproj | 3 ++- .../TemperatureController.csproj | 3 ++- .../PnpServiceSamples/Thermostat/Thermostat.csproj | 3 ++- iothub/service/src/Microsoft.Azure.Devices.csproj | 6 +++--- .../tests/Microsoft.Azure.Devices.Tests.csproj | 10 +++++----- .../getting started/X509Sample/X509Sample.csproj | 10 +++++----- .../SymmetricKeySample/SymmetricKeySample.csproj | 10 +++++----- .../how to guides/TpmSample/TpmSample.csproj | 10 +++++----- ...rosoft.Azure.Devices.Provisioning.Client.csproj | 2 +- ....Azure.Devices.Provisioning.Client.Tests.csproj | 6 +++--- .../CleanupEnrollmentsSample.csproj | 2 +- .../EnrollmentGroupSample.csproj | 2 +- .../IndividualEnrollmentSample.csproj | 2 +- .../BulkOperationSample/BulkOperationSample.csproj | 2 +- ...osoft.Azure.Devices.Provisioning.Service.csproj | 2 +- ...Azure.Devices.Provisioning.Service.Tests.csproj | 8 ++++---- ...zure.Devices.Provisioning.Transport.Amqp.csproj | 4 ++-- ...evices.Provisioning.Transport.Amqp.Tests.csproj | 6 +++--- ...zure.Devices.Provisioning.Transport.Http.csproj | 2 +- ...evices.Provisioning.Transport.Http.Tests.csproj | 6 +++--- ...zure.Devices.Provisioning.Transport.Mqtt.csproj | 2 +- ...evices.Provisioning.Transport.Mqtt.Tests.csproj | 6 +++--- .../ColorConsoleLogger/ColorConsoleLogger.csproj | 3 ++- .../SecurityProviderTpmSimulator.csproj | 7 +++++-- ....Azure.Devices.Provisioning.Security.Tpm.csproj | 2 +- ....Devices.Provisioning.Security.Tpm.Tests.csproj | 6 +++--- shared/src/Microsoft.Azure.Devices.Shared.csproj | 2 +- .../Microsoft.Azure.Devices.Shared.Tests.csproj | 10 +++++----- 50 files changed, 111 insertions(+), 98 deletions(-) diff --git a/e2e/test/E2ETests.csproj b/e2e/test/E2ETests.csproj index 505f0aa1e8..95cc47ae5c 100644 --- a/e2e/test/E2ETests.csproj +++ b/e2e/test/E2ETests.csproj @@ -40,6 +40,7 @@ + diff --git a/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj b/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj index 2621440c1f..aed1f4e7d6 100644 --- a/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj +++ b/iothub/device/samples/getting started/FileUploadSample/FileUploadSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj index 7cb0a69c4c..650d5571a0 100644 --- a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj +++ b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj b/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj index 203cd57782..f6151a0414 100644 --- a/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj +++ b/iothub/device/samples/getting started/SimulatedDevice/SimulatedDevice.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj b/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj index 203cd57782..f6151a0414 100644 --- a/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj +++ b/iothub/device/samples/getting started/SimulatedDeviceWithCommand/SimulatedDeviceWithCommand.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj index 4932b1e395..5d3a5b919f 100644 --- a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj +++ b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj @@ -10,6 +10,7 @@ + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj index 6fc57db9c9..1311bfe729 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj @@ -8,10 +8,10 @@ - - - - + + + + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj index f09ee74a83..e1f9747144 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj @@ -9,7 +9,8 @@ - + + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj index 235b844b87..54010ab3da 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj @@ -10,7 +10,8 @@ - + + diff --git a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj index 8044b4e824..8eeebb2457 100644 --- a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj +++ b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj @@ -96,9 +96,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -110,8 +110,8 @@ - - + + diff --git a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj index 2333b7375e..dc93e774b8 100644 --- a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj +++ b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj @@ -26,14 +26,14 @@ - - - - - - + + + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj index 648800d6cd..d8c7cba584 100644 --- a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj +++ b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj index e6eed95ea6..9d94029364 100644 --- a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj +++ b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj b/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj index 209e2768a0..2de1cb7e32 100644 --- a/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj +++ b/iothub/service/samples/getting started/InvokeDeviceMethod/InvokeDeviceMethod.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj index 7c0901b9ed..0de4f0de18 100644 --- a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj +++ b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj b/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj index cde015c636..b641cd6575 100644 --- a/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj +++ b/iothub/service/samples/getting started/ReadD2cMessages/ReadD2cMessages.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj index 90e14904b0..900ea36fcb 100644 --- a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj +++ b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj @@ -8,6 +8,7 @@ + diff --git a/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj b/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj index 5f3f45f120..842c1fc5fd 100644 --- a/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj +++ b/iothub/service/samples/how to guides/AzureSasCredentialAuthenticationSample/AzureSasCredentialAuthenticationSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj b/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj index 3fa7b07d7b..11c4dc045a 100644 --- a/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj +++ b/iothub/service/samples/how to guides/CleanupDevicesSample/CleanupDevicesSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj b/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj index 8cf4bd0438..938cab5a22 100644 --- a/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj +++ b/iothub/service/samples/how to guides/ImportExportDevicesSample/ImportExportDevicesSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj b/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj index 8cac8ba8de..8e0bb7c133 100644 --- a/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj +++ b/iothub/service/samples/how to guides/RoleBasedAuthenticationSample/RoleBasedAuthenticationSample.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj index 02a6a93226..8a02918492 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj @@ -8,7 +8,8 @@ - + + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj index 02a6a93226..8a02918492 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj @@ -8,7 +8,8 @@ - + + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj index 1ef59e3f7e..e9d35351a7 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj @@ -8,7 +8,8 @@ - + + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj index 02a6a93226..8a02918492 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj @@ -8,7 +8,8 @@ - + + diff --git a/iothub/service/src/Microsoft.Azure.Devices.csproj b/iothub/service/src/Microsoft.Azure.Devices.csproj index 73002c7ec2..0d9ae4d5fa 100644 --- a/iothub/service/src/Microsoft.Azure.Devices.csproj +++ b/iothub/service/src/Microsoft.Azure.Devices.csproj @@ -136,12 +136,12 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -182,6 +182,6 @@ - + diff --git a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj index 5a7937c5c1..49fbab6ec1 100644 --- a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj +++ b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj @@ -18,11 +18,11 @@ - - - - - + + + + + diff --git a/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj b/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj index 93a2d0e359..bb7521f297 100644 --- a/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj +++ b/provisioning/device/samples/getting started/X509Sample/X509Sample.csproj @@ -9,13 +9,13 @@ - - + + - - - + + + diff --git a/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj b/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj index d4632ce2bb..200eb988a7 100644 --- a/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj +++ b/provisioning/device/samples/how to guides/SymmetricKeySample/SymmetricKeySample.csproj @@ -8,13 +8,13 @@ - - + + - - - + + + diff --git a/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj b/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj index 355e5615c5..93e584b012 100644 --- a/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj +++ b/provisioning/device/samples/how to guides/TpmSample/TpmSample.csproj @@ -8,13 +8,13 @@ - - - + + + - - + + diff --git a/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj b/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj index 8d0c02601a..a06fd7645d 100644 --- a/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj +++ b/provisioning/device/src/Microsoft.Azure.Devices.Provisioning.Client.csproj @@ -59,7 +59,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj b/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj index 61219c1f9b..6506e7c005 100644 --- a/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj +++ b/provisioning/device/tests/Microsoft.Azure.Devices.Provisioning.Client.Tests.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj b/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj index 91b14f4975..15c724c7bc 100644 --- a/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj +++ b/provisioning/service/samples/getting started/CleanupEnrollmentsSample/CleanupEnrollmentsSample.csproj @@ -9,7 +9,7 @@ - + diff --git a/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj b/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj index db780d015b..1c1e160bb1 100644 --- a/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj +++ b/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.csproj @@ -7,7 +7,7 @@ - + diff --git a/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj b/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj index be41b8427f..cea6aceb19 100644 --- a/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj +++ b/provisioning/service/samples/getting started/EnrollmentSample/IndividualEnrollmentSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj b/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj index 795c5b44b5..c5f9046a36 100644 --- a/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj +++ b/provisioning/service/samples/how to guides/BulkOperationSample/BulkOperationSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj b/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj index 87ae33d989..24c15d1605 100644 --- a/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj +++ b/provisioning/service/src/Microsoft.Azure.Devices.Provisioning.Service.csproj @@ -64,7 +64,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj b/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj index e76d379104..22653bdca8 100644 --- a/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj +++ b/provisioning/service/tests/Microsoft.Azure.Devices.Provisioning.Service.Tests.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj b/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj index 6af69b3716..3584ca7094 100644 --- a/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj +++ b/provisioning/transport/amqp/src/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.csproj @@ -101,8 +101,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj b/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj index 29446a93b7..60c6a48fd8 100644 --- a/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj +++ b/provisioning/transport/amqp/tests/Microsoft.Azure.Devices.Provisioning.Transport.Amqp.Tests.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj b/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj index 9786970b19..03ac233337 100644 --- a/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj +++ b/provisioning/transport/http/src/Microsoft.Azure.Devices.Provisioning.Transport.Http.csproj @@ -100,7 +100,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj b/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj index b63e1b0532..06e875745b 100644 --- a/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj +++ b/provisioning/transport/http/tests/Microsoft.Azure.Devices.Provisioning.Transport.Http.Tests.csproj @@ -11,9 +11,9 @@ - - - + + + 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 30d6abf097..b973e03164 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 @@ -110,7 +110,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj b/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj index 8d67fef893..01da47eea3 100644 --- a/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj +++ b/provisioning/transport/mqtt/tests/Microsoft.Azure.Devices.Provisioning.Transport.Mqtt.Tests.csproj @@ -11,9 +11,9 @@ - - - + + + diff --git a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj index cdd1401223..aebc81129f 100644 --- a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj +++ b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj @@ -6,7 +6,8 @@ - + + diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj index 3d8096766c..ab5fb4919d 100644 --- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj +++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj @@ -9,12 +9,15 @@ - + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj b/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj index 7c40e4155e..95457a994e 100644 --- a/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj +++ b/security/tpm/src/Microsoft.Azure.Devices.Provisioning.Security.Tpm.csproj @@ -59,7 +59,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj b/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj index be0e17162d..333c3cc46c 100644 --- a/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj +++ b/security/tpm/tests/Microsoft.Azure.Devices.Provisioning.Security.Tpm.Tests.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/shared/src/Microsoft.Azure.Devices.Shared.csproj b/shared/src/Microsoft.Azure.Devices.Shared.csproj index 8a55d86213..ffd421ccfe 100644 --- a/shared/src/Microsoft.Azure.Devices.Shared.csproj +++ b/shared/src/Microsoft.Azure.Devices.Shared.csproj @@ -51,7 +51,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj index 94d204cb8c..ea3398019b 100644 --- a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj +++ b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj @@ -15,11 +15,11 @@ - - - - - + + + + + From b0e70a6b34d1d10e67837a64e468f3333c6ad61f Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:48:15 -0800 Subject: [PATCH 05/10] more --- .../PnpDeviceSamples/PnpConvention/PnpHelpers.csproj | 2 +- iothub/device/src/Microsoft.Azure.Devices.Client.csproj | 2 +- iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs | 2 ++ iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs | 4 +++- .../tests/Microsoft.Azure.Devices.Client.Tests.csproj | 2 +- iothub/service/src/Messaging/Models/Message.cs | 2 +- iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj | 2 +- .../SecurityProviderTpmSimulator.cs | 6 ++++++ shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj | 2 +- 9 files changed, 17 insertions(+), 7 deletions(-) diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj index 1311bfe729..4ce2526d3f 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj index 8eeebb2457..0ae56aa9a4 100644 --- a/iothub/device/src/Microsoft.Azure.Devices.Client.csproj +++ b/iothub/device/src/Microsoft.Azure.Devices.Client.csproj @@ -110,7 +110,7 @@ - + diff --git a/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs b/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs index cd9f3de5ba..5dac3f2295 100644 --- a/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs +++ b/iothub/device/src/Transport/AmqpIot/AmqpIotSendingLink.cs @@ -94,7 +94,9 @@ internal async Task SendMessagesAsync(IEnumerable messa foreach (Message message in messages) { +#pragma warning disable CA2000 // Dispose objects before losing scope using AmqpMessage amqpMessage = AmqpIotMessageConverter.MessageToAmqpMessage(message); +#pragma warning restore CA2000 // Dispose objects before losing scope var data = new Data { Value = AmqpIotMessageConverter.ReadStream(amqpMessage.ToStream()), diff --git a/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs b/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs index 4e35a17e29..62ea68bcc5 100644 --- a/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs +++ b/iothub/device/src/Transport/Mqtt/MqttIotHubAdapter.cs @@ -23,7 +23,9 @@ using Microsoft.Azure.Devices.Shared; #if NET5_0_OR_GREATER + using TaskCompletionSource = System.Threading.Tasks.TaskCompletionSource; + #else using TaskCompletionSource = Microsoft.Azure.Devices.Shared.TaskCompletionSource; #endif @@ -1108,7 +1110,7 @@ private static IByteBuffer GetWillMessageBody(Message message) { Stream bodyStream = message.GetBodyStream(); byte[] buffer = new byte[bodyStream.Length]; - bodyStream.Read(buffer, 0, buffer.Length); + _ = bodyStream.Read(buffer, 0, buffer.Length); IByteBuffer copiedBuffer = Unpooled.CopiedBuffer(buffer); return copiedBuffer; } diff --git a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj index dc93e774b8..e25182fece 100644 --- a/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj +++ b/iothub/device/tests/Microsoft.Azure.Devices.Client.Tests.csproj @@ -26,7 +26,7 @@ - + diff --git a/iothub/service/src/Messaging/Models/Message.cs b/iothub/service/src/Messaging/Models/Message.cs index e66c611df2..0c6b6a29e2 100644 --- a/iothub/service/src/Messaging/Models/Message.cs +++ b/iothub/service/src/Messaging/Models/Message.cs @@ -369,7 +369,7 @@ public byte[] GetBytes() { // We can trust Amqp bufferListStream.Length; byte[] bytes = new byte[listStream.Length]; - listStream.Read(bytes, 0, bytes.Length); + _ = listStream.Read(bytes, 0, bytes.Length); return bytes; } diff --git a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj index 49fbab6ec1..5449a1c59c 100644 --- a/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj +++ b/iothub/service/tests/Microsoft.Azure.Devices.Tests.csproj @@ -22,7 +22,7 @@ - + diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs index ab2e760e75..876057204a 100644 --- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs +++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.cs @@ -9,6 +9,8 @@ using Microsoft.Azure.Devices.Shared; using Tpm2Lib; +#pragma warning disable CA1416 + namespace Microsoft.Azure.Devices.Provisioning.Security.Samples { /// @@ -69,7 +71,9 @@ public static void StopSimulatorProcess() { process?.Kill(); } +#pragma warning disable CA1031 catch (Exception) +#pragma warning restore CA1030 { } } @@ -133,3 +137,5 @@ protected override void Dispose(bool disposing) } } } + +#pragma warning restore CA1416 diff --git a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj index ea3398019b..a271887abb 100644 --- a/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj +++ b/shared/tests/Microsoft.Azure.Devices.Shared.Tests.csproj @@ -15,7 +15,7 @@ - + From 761a3ff4dd8d6985fe3338260fff0088b3d9c47a Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:58:42 -0800 Subject: [PATCH 06/10] maybe --- .../DeviceReconnectionSample/DeviceReconnectionSample.csproj | 1 + .../TemperatureController/TemperatureController.csproj | 2 +- .../solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj | 2 +- .../FileUploadNotificationReceiverSample.csproj | 1 + .../ServiceClientSample/ServiceClientSample.csproj | 1 + .../TemperatureController/TemperatureController.csproj | 2 +- .../DigitalTwinClientSamples/Thermostat/Thermostat.csproj | 2 +- .../TemperatureController/TemperatureController.csproj | 2 +- .../solutions/PnpServiceSamples/Thermostat/Thermostat.csproj | 2 +- samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj | 2 +- 10 files changed, 10 insertions(+), 7 deletions(-) diff --git a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj index 5d3a5b919f..a719c6961c 100644 --- a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj +++ b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj @@ -9,6 +9,7 @@ + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj index e1f9747144..9a8fae200b 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj index 54010ab3da..9a80ca87f2 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj @@ -10,7 +10,7 @@ - + diff --git a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj index 9d94029364..d98fec1af4 100644 --- a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj +++ b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj @@ -8,6 +8,7 @@ + diff --git a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj index 900ea36fcb..51b08704b5 100644 --- a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj +++ b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj @@ -8,6 +8,7 @@ + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj index 8a02918492..91a983e557 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj index 8a02918492..91a983e557 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj index e9d35351a7..86ce4d1ea9 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj index 8a02918492..91a983e557 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj @@ -8,7 +8,7 @@ - + diff --git a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj index aebc81129f..0589ee1a2c 100644 --- a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj +++ b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj @@ -6,7 +6,7 @@ - + From 12b57d5ffd13eade280aa98cc2c9d3fe8020a8ad Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 11:59:47 -0800 Subject: [PATCH 07/10] fxcop --- .../SecurityProviderTpmSimulator.csproj | 4 ---- 1 file changed, 4 deletions(-) diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj index ab5fb4919d..a9e1c1485b 100644 --- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj +++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj @@ -14,10 +14,6 @@ - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - From 03dfef497374e8a887fae637793eda778a49b7aa Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 12:09:15 -0800 Subject: [PATCH 08/10] json --- .../samples/getting started/MethodSample/MethodSample.csproj | 2 +- .../DeviceReconnectionSample/DeviceReconnectionSample.csproj | 2 +- .../TemperatureController/TemperatureController.csproj | 2 +- .../solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj | 2 +- .../EdgeDeploymentSample/EdgeDeploymentSample.csproj | 2 +- .../FileUploadNotificationReceiverSample.csproj | 2 +- .../samples/getting started/JobsSample/JobsSample.csproj | 2 +- .../ServiceClientSample/ServiceClientSample.csproj | 2 +- .../TemperatureController/TemperatureController.csproj | 2 +- .../DigitalTwinClientSamples/Thermostat/Thermostat.csproj | 2 +- .../TemperatureController/TemperatureController.csproj | 2 +- .../solutions/PnpServiceSamples/Thermostat/Thermostat.csproj | 2 +- samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj | 2 +- .../SecurityProviderTpmSimulator.csproj | 1 + 14 files changed, 14 insertions(+), 13 deletions(-) diff --git a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj index 650d5571a0..5e306d239e 100644 --- a/iothub/device/samples/getting started/MethodSample/MethodSample.csproj +++ b/iothub/device/samples/getting started/MethodSample/MethodSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj index a719c6961c..88b40e14c4 100644 --- a/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj +++ b/iothub/device/samples/how to guides/DeviceReconnectionSample/DeviceReconnectionSample.csproj @@ -11,7 +11,7 @@ - + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj index 9a8fae200b..158ed6cc2c 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/TemperatureController/TemperatureController.csproj @@ -10,7 +10,7 @@ - + diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj index 9a80ca87f2..c5e2d07262 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/Thermostat/Thermostat.csproj @@ -11,7 +11,7 @@ - + diff --git a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj index d8c7cba584..d85e318b87 100644 --- a/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj +++ b/iothub/service/samples/getting started/EdgeDeploymentSample/EdgeDeploymentSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj index d98fec1af4..eda9caece2 100644 --- a/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj +++ b/iothub/service/samples/getting started/FileUploadNotificationReceiverSample/FileUploadNotificationReceiverSample.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj index 0de4f0de18..05778f257a 100644 --- a/iothub/service/samples/getting started/JobsSample/JobsSample.csproj +++ b/iothub/service/samples/getting started/JobsSample/JobsSample.csproj @@ -8,7 +8,7 @@ - + diff --git a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj index 51b08704b5..fe2623fa17 100644 --- a/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj +++ b/iothub/service/samples/getting started/ServiceClientSample/ServiceClientSample.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj index 91a983e557..7991e92a22 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/TemperatureController/TemperatureController.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj index 91a983e557..7991e92a22 100644 --- a/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/DigitalTwinClientSamples/Thermostat/Thermostat.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj index 86ce4d1ea9..1302faf31a 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/TemperatureController/TemperatureController.csproj @@ -9,7 +9,7 @@ - + diff --git a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj index 91a983e557..7991e92a22 100644 --- a/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj +++ b/iothub/service/samples/solutions/PnpServiceSamples/Thermostat/Thermostat.csproj @@ -9,7 +9,7 @@ - + diff --git a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj index 0589ee1a2c..def41e93cc 100644 --- a/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj +++ b/samples/helpers/ColorConsoleLogger/ColorConsoleLogger.csproj @@ -7,7 +7,7 @@ - + diff --git a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj index a9e1c1485b..c3b604b885 100644 --- a/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj +++ b/security/tpm/samples/SecurityProviderTpmSimulator/SecurityProviderTpmSimulator.csproj @@ -12,6 +12,7 @@ + From 156f16068d49085b9e16d558c58dcc7c3584945b Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 14:19:43 -0800 Subject: [PATCH 09/10] Bump service client version --- iothub/service/src/Microsoft.Azure.Devices.csproj | 2 +- versions.csv | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iothub/service/src/Microsoft.Azure.Devices.csproj b/iothub/service/src/Microsoft.Azure.Devices.csproj index 0d9ae4d5fa..e8d21ae113 100644 --- a/iothub/service/src/Microsoft.Azure.Devices.csproj +++ b/iothub/service/src/Microsoft.Azure.Devices.csproj @@ -34,7 +34,7 @@ - 1.39.1 + 1.40.0 Microsoft Azure IoT Service Client SDK True True diff --git a/versions.csv b/versions.csv index de06416107..e9ffe1da73 100644 --- a/versions.csv +++ b/versions.csv @@ -1,6 +1,6 @@ AssemblyPath, Version iothub\device\src\Microsoft.Azure.Devices.Client.csproj, 1.42.3 -iothub\service\src\Microsoft.Azure.Devices.csproj, 1.39.1 +iothub\service\src\Microsoft.Azure.Devices.csproj, 1.40.0 shared\src\Microsoft.Azure.Devices.Shared.csproj, 1.30.4 provisioning\device\src\Microsoft.Azure.Devices.Provisioning.Client.csproj, 1.19.4 provisioning\service\src\Microsoft.Azure.Devices.Provisioning.Service.csproj, 1.18.4 From 72bce3ff1898e1cb6a9f458599534226d5af6a7b Mon Sep 17 00:00:00 2001 From: timtay-microsoft Date: Thu, 21 Nov 2024 14:34:08 -0800 Subject: [PATCH 10/10] No --- .../PnpConvention/PnpConventionTests.cs | 164 ------------------ .../PnpConvention/PnpHelpers.csproj | 8 - 2 files changed, 172 deletions(-) delete mode 100644 iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs deleted file mode 100644 index 7118367b2b..0000000000 --- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpConventionTests.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using FluentAssertions; -using Microsoft.Azure.Devices.Shared; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace PnpHelpers -{ - class PnpConventionTests - { - /// - /// Ensures the PnP convention helpers produce content to spec and using different data types - /// - [TestClass] - [TestCategory("Unit")] - public class PnpHelperTests - { - [TestMethod] - public void CreateRootPropertyPatch() - { - // Format: - // { - // "samplePropertyName": 20 - // } - - const string propertyName = "someName"; - const int propertyValue = 10; - - TwinCollection patch = PnpConvention.CreatePropertyPatch(propertyName, propertyValue); - var jObject = JObject.Parse(patch.ToJson()); - - jObject.Count.Should().Be(1, "there should be a single property added"); - jObject.Value(propertyName).Should().Be(propertyValue); - } - - [TestMethod] - public void CreateComponentPropertyPatch() - { - // Format: - // { - // "sampleComponentName": { - // "__t": "c", - // "samplePropertyName"": 20 - // } - // } - - const string componentName = "someComponent"; - const string propertyName = "someName"; - const int propertyValue = 10; - - TwinCollection patch = PnpConvention.CreateComponentPropertyPatch(componentName, propertyName, propertyValue); - - var jObject = JObject.Parse(patch.ToJson()); - JObject component = jObject.Value(componentName); - - component.Count.Should().Be(2, "there should be two properties added - the above property and a component identifier {\"__t\": \"c\"}"); - component.Value(propertyName).Should().Be(propertyValue); - component[PnpConvention.PropertyComponentIdentifierKey].Should().NotBeNull(); - ((string)component[PnpConvention.PropertyComponentIdentifierKey]).Should().Be(PnpConvention.PropertyComponentIdentifierValue); - } - - [TestMethod] - public void CreateRootPropertyEmbeddedValuePatch() - { - // Format: - // { - // "samplePropertyName": { - // "value": 20, - // "ac": 200, - // "av": 5, - // "ad": "The update was successful." - // } - // } - - const string propertyName = "someName"; - const int propertyValue = 10; - const int ackCode = 200; - const long ackVersion = 2; - - TwinCollection patch = PnpConvention.CreateWritablePropertyResponse(propertyName, propertyValue, ackCode, ackVersion); - - var jObject = JObject.Parse(patch.ToJson()); - EmbeddedPropertyPatch actualPatch = jObject.ToObject(); - - // The property patch object should have "value", "ac" and "av" properties set. Since we did not supply an "ackDescription", "ad" should be null. - actualPatch.Value.SerializedValue.Should().Be(JsonConvert.SerializeObject(propertyValue)); - actualPatch.Value.AckCode.Should().Be(ackCode); - actualPatch.Value.AckVersion.Should().Be(ackVersion); - actualPatch.Value.AckDescription.Should().BeNull(); - } - - [TestMethod] - public void CreateComponentPropertyEmbeddedValuePatch() - { - // Format: - // { - // "sampleComponentName": { - // "__t": "c", - // "samplePropertyName": { - // "value": 20, - // "ac": 200, - // "av": 5, - // "ad": "The update was successful." - // } - // } - // } - - const string componentName = "someComponentName"; - const string propertyName = "someName"; - const int propertyValue = 10; - const int ackCode = 200; - const long ackVersion = 2; - const string ackDescription = "The update was successful"; - - TwinCollection patch = PnpConvention.CreateComponentWritablePropertyResponse( - componentName, - propertyName, - JsonConvert.SerializeObject(propertyValue), - ackCode, - ackVersion, - ackDescription); - - var jObject = JObject.Parse(patch.ToJson()); - JObject component = jObject.Value(componentName); - - // There should be two properties added to the component- the above property and a component identifier "__t": "c". - component.Count.Should().Be(2); - component[PnpConvention.PropertyComponentIdentifierKey].Should().NotBeNull(); - ((string)component[PnpConvention.PropertyComponentIdentifierKey]).Should().Be(PnpConvention.PropertyComponentIdentifierValue); - - // The property patch object should have "value", "ac", "av" and "ad" properties set. - EmbeddedPropertyPatch actualPatch = component.ToObject(); - actualPatch.Value.SerializedValue.Should().Be(JsonConvert.SerializeObject(propertyValue)); - actualPatch.Value.AckCode.Should().Be(ackCode); - actualPatch.Value.AckVersion.Should().Be(ackVersion); - actualPatch.Value.AckDescription.Should().Be(ackDescription); - } - } - - internal class EmbeddedPropertyPatch - { - [JsonProperty("someName")] - internal EmbeddedPropertyPatchValue Value { get; set; } - } - - internal class EmbeddedPropertyPatchValue - { - [JsonProperty("value")] - internal string SerializedValue { get; set; } - - [JsonProperty("ac")] - internal int AckCode { get; set; } - - [JsonProperty("av")] - internal long AckVersion { get; set; } - - [JsonProperty("ad")] - internal string AckDescription { get; set; } - } - } -} \ No newline at end of file diff --git a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj index 4ce2526d3f..ec4614c2fb 100644 --- a/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj +++ b/iothub/device/samples/solutions/PnpDeviceSamples/PnpConvention/PnpHelpers.csproj @@ -2,18 +2,10 @@ net6.0 - True 9.0 False - - - - - - -