diff --git a/e2e/test/Helpers/TestDeviceCallbackHandler.cs b/e2e/test/Helpers/TestDeviceCallbackHandler.cs index 6f2025de76..638e317a77 100644 --- a/e2e/test/Helpers/TestDeviceCallbackHandler.cs +++ b/e2e/test/Helpers/TestDeviceCallbackHandler.cs @@ -180,7 +180,7 @@ public async Task SetClientPropertyUpdateCallbackHandlerAsync(string expected string userContext = "myContext"; await _deviceClient - .SubscribeToWritablePropertiesEventAsync( + .SubscribeToWritablePropertyUpdateRequestsAsync( (patch, context) => { _logger.Trace($"{nameof(SetClientPropertyUpdateCallbackHandlerAsync)}: DeviceClient {_testDevice.Id} callback property: WritableProperty: {patch}, {context}"); diff --git a/e2e/test/iothub/properties/PropertiesE2ETests.cs b/e2e/test/iothub/properties/PropertiesE2ETests.cs index 7db552aa57..a38c55d80c 100644 --- a/e2e/test/iothub/properties/PropertiesE2ETests.cs +++ b/e2e/test/iothub/properties/PropertiesE2ETests.cs @@ -210,7 +210,7 @@ public static async Task Properties_DeviceSetsPropertyAndGetsItBackAsync(Devi // Validate the updated properties from the device-client ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.TryGetValue(propName, out T propFromCollection); + bool isPropertyPresent = clientProperties.ReportedFromClient.TryGetValue(propName, out T propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().BeEquivalentTo(propValue); @@ -245,7 +245,7 @@ private async Task Properties_ServiceSetsWritablePropertyAndDeviceUnsubscribes(C // Set a callback await deviceClient. - SubscribeToWritablePropertiesEventAsync( + SubscribeToWritablePropertyUpdateRequestsAsync( (patch, context) => { Assert.Fail("After having unsubscribed from receiving client property update notifications " + @@ -258,7 +258,7 @@ await deviceClient. // Unsubscribe await deviceClient - .SubscribeToWritablePropertiesEventAsync(null, null) + .SubscribeToWritablePropertyUpdateRequestsAsync(null, null) .ConfigureAwait(false); await RegistryManagerUpdateWritablePropertyAsync(testDevice.Id, propName, propValue) @@ -289,7 +289,7 @@ await Task // Validate the updated properties from the device-client ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.Writable.TryGetValue(propName, out T propValueFromCollection); + bool isPropertyPresent = clientProperties.WritablePropertyRequests.TryGetValue(propName, out T propValueFromCollection); isPropertyPresent.Should().BeTrue(); propValueFromCollection.Should().BeEquivalentTo(propValue); @@ -301,7 +301,7 @@ await Task string serializedActualPropertyValue = JsonConvert.SerializeObject(actualProp); serializedActualPropertyValue.Should().Be(JsonConvert.SerializeObject(propValue)); - await deviceClient.SubscribeToWritablePropertiesEventAsync(null, null).ConfigureAwait(false); + await deviceClient.SubscribeToWritablePropertyUpdateRequestsAsync(null, null).ConfigureAwait(false); await deviceClient.CloseAsync().ConfigureAwait(false); } @@ -319,7 +319,7 @@ private async Task Properties_ServiceSetsWritablePropertyAndDeviceReceivesItOnNe await registryManager.UpdateTwinAsync(testDevice.Id, twinPatch, "*").ConfigureAwait(false); ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.Writable.TryGetValue(propName, out string propFromCollection); + bool isPropertyPresent = clientProperties.WritablePropertyRequests.TryGetValue(propName, out string propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().Be(propValue); diff --git a/e2e/test/iothub/properties/PropertiesFaultInjectionTests.cs b/e2e/test/iothub/properties/PropertiesFaultInjectionTests.cs index 3c71d594f6..4016dff7df 100644 --- a/e2e/test/iothub/properties/PropertiesFaultInjectionTests.cs +++ b/e2e/test/iothub/properties/PropertiesFaultInjectionTests.cs @@ -129,7 +129,7 @@ static async Task TestOperationAsync(DeviceClient deviceClient, TestDevice testD ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); clientProperties.Should().NotBeNull(); - bool isPropertyPresent = clientProperties.TryGetValue(propName, out string propFromCollection); + bool isPropertyPresent = clientProperties.ReportedFromClient.TryGetValue(propName, out string propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().Be(propValue); } diff --git a/e2e/test/iothub/properties/PropertiesWithComponentsE2ETests.cs b/e2e/test/iothub/properties/PropertiesWithComponentsE2ETests.cs index 96040512d5..3e3b23be75 100644 --- a/e2e/test/iothub/properties/PropertiesWithComponentsE2ETests.cs +++ b/e2e/test/iothub/properties/PropertiesWithComponentsE2ETests.cs @@ -212,7 +212,7 @@ public static async Task PropertiesWithComponents_DeviceSetsPropertyAndGetsItBac // Validate the updated properties from the device-client ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.TryGetValue(ComponentName, propName, out T propFromCollection); + bool isPropertyPresent = clientProperties.ReportedFromClient.TryGetValue(ComponentName, propName, out T propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().BeEquivalentTo(propValue); @@ -252,7 +252,7 @@ private async Task PropertiesWithComponents_ServiceSetsWritablePropertyAndDevice // Set a callback await deviceClient. - SubscribeToWritablePropertiesEventAsync( + SubscribeToWritablePropertyUpdateRequestsAsync( (patch, context) => { Assert.Fail("After having unsubscribed from receiving client property update notifications " + @@ -265,7 +265,7 @@ await deviceClient. // Unsubscribe await deviceClient - .SubscribeToWritablePropertiesEventAsync(null, null) + .SubscribeToWritablePropertyUpdateRequestsAsync(null, null) .ConfigureAwait(false); await RegistryManagerUpdateWritablePropertyAsync(testDevice.Id, ComponentName, propName, propValue) @@ -296,7 +296,7 @@ await Task // Validate the updated properties from the device-client ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.Writable.TryGetValue(ComponentName, propName, out T propFromCollection); + bool isPropertyPresent = clientProperties.WritablePropertyRequests.TryGetValue(ComponentName, propName, out T propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().BeEquivalentTo(propValue); @@ -308,7 +308,7 @@ await Task string serializedActualPropertyValue = JsonConvert.SerializeObject(actualProp); serializedActualPropertyValue.Should().Be(JsonConvert.SerializeObject(propValue)); - await deviceClient.SubscribeToWritablePropertiesEventAsync(null, null).ConfigureAwait(false); + await deviceClient.SubscribeToWritablePropertyUpdateRequestsAsync(null, null).ConfigureAwait(false); await deviceClient.CloseAsync().ConfigureAwait(false); } @@ -331,7 +331,7 @@ private async Task PropertiesWithComponents_ServiceSetsWritablePropertyAndDevice await registryManager.UpdateTwinAsync(testDevice.Id, twinPatch, "*").ConfigureAwait(false); ClientProperties clientProperties = await deviceClient.GetClientPropertiesAsync().ConfigureAwait(false); - bool isPropertyPresent = clientProperties.Writable.TryGetValue(ComponentName, propName, out string propFromCollection); + bool isPropertyPresent = clientProperties.WritablePropertyRequests.TryGetValue(ComponentName, propName, out string propFromCollection); isPropertyPresent.Should().BeTrue(); propFromCollection.Should().Be(propValue); diff --git a/iothub/device/src/ClientProperties.cs b/iothub/device/src/ClientProperties.cs index 08520d5792..43d708f32d 100644 --- a/iothub/device/src/ClientProperties.cs +++ b/iothub/device/src/ClientProperties.cs @@ -10,7 +10,7 @@ namespace Microsoft.Azure.Devices.Client /// The class is not meant to be constructed by customer code. /// It is intended to be returned fully populated from the client method . /// - public class ClientProperties : ClientPropertyCollection + public class ClientProperties { /// /// Initializes a new instance of . @@ -19,27 +19,36 @@ public class ClientProperties : ClientPropertyCollection /// public ClientProperties() { - Writable = new ClientPropertyCollection(); + WritablePropertyRequests = new ClientPropertyCollection(); + ReportedFromClient = new ClientPropertyCollection(); } /// /// Initializes a new instance of with the specified collections. /// - /// A collection of writable properties returned from IoT Hub. - /// A collection of read-only properties returned from IoT Hub. - internal ClientProperties(ClientPropertyCollection requestedPropertyCollection, ClientPropertyCollection readOnlyPropertyCollection) + /// A collection of writable property requests returned from IoT Hub. + /// A collection of client reported properties returned from IoT Hub. + internal ClientProperties(ClientPropertyCollection writablePropertyRequestCollection, ClientPropertyCollection clientReportedPropertyCollection) { - SetCollection(readOnlyPropertyCollection); - Version = readOnlyPropertyCollection.Version; - Writable = requestedPropertyCollection; + WritablePropertyRequests = writablePropertyRequestCollection; + ReportedFromClient = clientReportedPropertyCollection; } /// - /// The collection of writable properties. + /// The collection of writable property requests received from service. /// /// - /// See the Writable properties documentation for more information. + /// See the Writable properties documentation for more information. /// - public ClientPropertyCollection Writable { get; private set; } + public ClientPropertyCollection WritablePropertyRequests { get; private set; } + + /// + /// The collection of properties reported by the client. + /// + /// + /// Client reported properties can either be Read-only properties + /// or they can be Writable properties. + /// + public ClientPropertyCollection ReportedFromClient { get; private set; } } } diff --git a/iothub/device/src/ClientTwinProperties.cs b/iothub/device/src/ClientTwinProperties.cs index 63b13195f5..dbc27249e4 100644 --- a/iothub/device/src/ClientTwinProperties.cs +++ b/iothub/device/src/ClientTwinProperties.cs @@ -23,10 +23,10 @@ internal ClientTwinProperties() internal ClientProperties ToClientProperties(PayloadConvention payloadConvention) { - ClientPropertyCollection writablePropertyCollection = ClientPropertyCollection.FromClientTwinDictionary(Desired, payloadConvention); - ClientPropertyCollection propertyCollection = ClientPropertyCollection.FromClientTwinDictionary(Reported, payloadConvention); + ClientPropertyCollection writablePropertyRequestCollection = ClientPropertyCollection.FromClientTwinDictionary(Desired, payloadConvention); + ClientPropertyCollection clientReportedPropertyCollection = ClientPropertyCollection.FromClientTwinDictionary(Reported, payloadConvention); - return new ClientProperties(writablePropertyCollection, propertyCollection); + return new ClientProperties(writablePropertyRequestCollection, clientReportedPropertyCollection); } } } diff --git a/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs b/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs index b3e87099a3..c093feca0a 100644 --- a/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs +++ b/iothub/device/src/Common/UrlEncodedDictionarySerializer.cs @@ -345,7 +345,7 @@ private Token CreateToken(TokenType tokenType, int readCount) // '?' is not a valid character for message property names or values, but instead signifies the start of a query string // in the case of an MQTT topic. For this reason, we'll replace the '?' from the property key before adding it into // application properties collection. - // https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-construct + // https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messages-construct string tokenValue = readCount == 0 ? null : value.Substring(position - readCount, readCount).Replace(QueryStringIdentifier, string.Empty); return new Token(tokenType, tokenValue); diff --git a/iothub/device/src/DeviceClient.ConventionBasedOperations.cs b/iothub/device/src/DeviceClient.ConventionBasedOperations.cs index 3c1e63468d..74619e6d26 100644 --- a/iothub/device/src/DeviceClient.ConventionBasedOperations.cs +++ b/iothub/device/src/DeviceClient.ConventionBasedOperations.cs @@ -67,7 +67,7 @@ public Task UpdateClientPropertiesAsync(ClientPr /// The global call back to handle all writable property updates. /// Generic parameter to be interpreted by the client code. /// A cancellation token to cancel the operation. - public Task SubscribeToWritablePropertiesEventAsync(Func callback, object userContext, CancellationToken cancellationToken = default) - => InternalClient.SubscribeToWritablePropertiesEventAsync(callback, userContext, cancellationToken); + public Task SubscribeToWritablePropertyUpdateRequestsAsync(Func callback, object userContext, CancellationToken cancellationToken = default) + => InternalClient.SubscribeToWritablePropertyUpdateRequestsAsync(callback, userContext, cancellationToken); } } diff --git a/iothub/device/src/InternalClient.ConventionBasedOperations.cs b/iothub/device/src/InternalClient.ConventionBasedOperations.cs index 4e785e96d0..e4a862bc31 100644 --- a/iothub/device/src/InternalClient.ConventionBasedOperations.cs +++ b/iothub/device/src/InternalClient.ConventionBasedOperations.cs @@ -96,7 +96,7 @@ internal async Task UpdateClientPropertiesAsync( } } - internal Task SubscribeToWritablePropertiesEventAsync(Func callback, object userContext, CancellationToken cancellationToken) + internal Task SubscribeToWritablePropertyUpdateRequestsAsync(Func callback, object userContext, CancellationToken cancellationToken) { // Subscribe to DesiredPropertyUpdateCallback internally and use the callback received internally to invoke the user supplied Property callback. var desiredPropertyUpdateCallback = new DesiredPropertyUpdateCallback((twinCollection, userContext) => diff --git a/iothub/device/src/ModuleClient.ConventionBasedOperations.cs b/iothub/device/src/ModuleClient.ConventionBasedOperations.cs index 8f8e7eedfb..be6e9adc53 100644 --- a/iothub/device/src/ModuleClient.ConventionBasedOperations.cs +++ b/iothub/device/src/ModuleClient.ConventionBasedOperations.cs @@ -67,7 +67,7 @@ public Task UpdateClientPropertiesAsync(ClientPr /// The global call back to handle all writable property updates. /// Generic parameter to be interpreted by the client code. /// A cancellation token to cancel the operation. - public Task SubscribeToWritablePropertiesEventAsync(Func callback, object userContext, CancellationToken cancellationToken = default) - => InternalClient.SubscribeToWritablePropertiesEventAsync(callback, userContext, cancellationToken); + public Task SubscribeToWritablePropertyUpdateRequestsAsync(Func callback, object userContext, CancellationToken cancellationToken = default) + => InternalClient.SubscribeToWritablePropertyUpdateRequestsAsync(callback, userContext, cancellationToken); } } diff --git a/iothub/device/src/PayloadCollection.cs b/iothub/device/src/PayloadCollection.cs index a6ab45581a..c9baeb4856 100644 --- a/iothub/device/src/PayloadCollection.cs +++ b/iothub/device/src/PayloadCollection.cs @@ -193,20 +193,5 @@ IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } - - /// - /// Will set the underlying of the payload collection. - /// - /// The collection to get the underlying dictionary from. - protected void SetCollection(PayloadCollection payloadCollection) - { - if (payloadCollection == null) - { - throw new ArgumentNullException(); - } - - Collection = payloadCollection.Collection; - Convention = payloadCollection.Convention; - } } } diff --git a/iothub/device/tests/ClientPropertiesTests.cs b/iothub/device/tests/ClientPropertiesTests.cs index 4dff48991e..243c01a5d3 100644 --- a/iothub/device/tests/ClientPropertiesTests.cs +++ b/iothub/device/tests/ClientPropertiesTests.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Microsoft.Azure.Devices.Client.Tests +namespace Microsoft.Azure.Devices.Client.Test { [TestClass] [TestCategory("Unit")] @@ -57,7 +57,7 @@ public void ClientPropertyCollection_CanEnumerateClientProperties() // assert // These are the device reported property values. - foreach (var deviceReportedKeyValuePairs in clientProperties) + foreach (var deviceReportedKeyValuePairs in clientProperties.ReportedFromClient) { if (deviceReportedKeyValuePairs.Key.Equals(StringPropertyName)) { @@ -78,7 +78,7 @@ public void ClientPropertyCollection_CanEnumerateClientProperties() } // These are the property values for which service has requested an update. - foreach (var updateRequestedKeyValuePairs in clientProperties.Writable) + foreach (var updateRequestedKeyValuePairs in clientProperties.WritablePropertyRequests) { if (updateRequestedKeyValuePairs.Key.Equals(DoublePropertyName)) { diff --git a/iothub/device/tests/ClientPropertyCollectionTests.cs b/iothub/device/tests/ClientPropertyCollectionTests.cs index 125b792bd2..48e3cc6e95 100644 --- a/iothub/device/tests/ClientPropertyCollectionTests.cs +++ b/iothub/device/tests/ClientPropertyCollectionTests.cs @@ -7,7 +7,7 @@ using Microsoft.Azure.Devices.Shared; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Microsoft.Azure.Devices.Client.Tests +namespace Microsoft.Azure.Devices.Client.Test { [TestClass] [TestCategory("Unit")] diff --git a/iothub/device/tests/ClientPropertyCollectionTestsNewtonsoft.cs b/iothub/device/tests/ClientPropertyCollectionTestsNewtonsoft.cs index 7e12e2c9b8..fce64ae95e 100644 --- a/iothub/device/tests/ClientPropertyCollectionTestsNewtonsoft.cs +++ b/iothub/device/tests/ClientPropertyCollectionTestsNewtonsoft.cs @@ -10,7 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.Azure.Devices.Client.Tests +namespace Microsoft.Azure.Devices.Client.Test { [TestClass] [TestCategory("Unit")] diff --git a/iothub/device/tests/NumericHelpersTests.cs b/iothub/device/tests/NumericHelpersTests.cs index d1f4e72684..caa3ad28e8 100644 --- a/iothub/device/tests/NumericHelpersTests.cs +++ b/iothub/device/tests/NumericHelpersTests.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; -namespace Microsoft.Azure.Devices.Client.Tests +namespace Microsoft.Azure.Devices.Client.Test { [TestClass] [TestCategory("Unit")] diff --git a/iothub/device/tests/TimeoutHelperTests.cs b/iothub/device/tests/TimeoutHelperTests.cs index 8a36ddec40..4e95f4898f 100644 --- a/iothub/device/tests/TimeoutHelperTests.cs +++ b/iothub/device/tests/TimeoutHelperTests.cs @@ -8,7 +8,7 @@ using FluentAssertions; using System.Threading.Tasks; -namespace Microsoft.Azure.Devices.Client.Tests +namespace Microsoft.Azure.Devices.Client.Test { /// /// The timeout helper is a way of keeping track of how much time remains against a specified deadline. diff --git a/shared/src/PayloadConvention.cs b/shared/src/PayloadConvention.cs index 99fd943723..468083e9c1 100644 --- a/shared/src/PayloadConvention.cs +++ b/shared/src/PayloadConvention.cs @@ -7,7 +7,7 @@ namespace Microsoft.Azure.Devices.Shared /// The payload convention class. /// /// The payload convention is used to define a specific serializer as well as a specific content encoding. - /// For example, IoT has a convention that is designed + /// For example, IoT has a convention that is designed /// to make it easier to get started with products that use specific conventions by default. public abstract class PayloadConvention {