From 12df3e59accc401d967219de6109e68b37389e7c Mon Sep 17 00:00:00 2001 From: Basel Rustum Date: Mon, 8 Jun 2020 11:38:58 -0700 Subject: [PATCH] fix(samples):remove unnecessary lines from sample (#12606) --- .../samples/DigitalTwinsClientSample/ComponentSamples.cs | 4 +--- .../samples/DigitalTwinsClientSample/CustomDigitalTwin.cs | 4 ++-- sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md | 7 ++----- .../Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs | 3 +-- .../src/Serialization/BasicDigitalTwin.cs | 1 - .../src/Serialization/ModelProperties.cs | 2 +- 6 files changed, 7 insertions(+), 14 deletions(-) diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/ComponentSamples.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/ComponentSamples.cs index 8af4e31afa59b..ba1082e7f79e4 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/ComponentSamples.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/ComponentSamples.cs @@ -63,7 +63,6 @@ public async Task RunSamplesAsync(DigitalTwinsClient client) "Component1", new ModelProperties { - Metadata = { }, // component properties CustomProperties = { @@ -118,12 +117,11 @@ public async Task RunSamplesAsync(DigitalTwinsClient client) var customTwin = new CustomDigitalTwin { Id = customDtId, - Metadata = new CustomDigitalTwinMetadata { ModelId = modelId }, + Metadata = { ModelId = modelId }, Prop1 = "Prop1 val", Prop2 = 987, Component1 = new Component1 { - Metadata = new Component1Metadata { }, ComponentProp1 = "Component prop1 val", ComponentProp2 = 123, } diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/CustomDigitalTwin.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/CustomDigitalTwin.cs index 1480c559746ef..aa84fb801bce5 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/CustomDigitalTwin.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/DigitalTwinsClientSample/CustomDigitalTwin.cs @@ -19,7 +19,7 @@ internal class CustomDigitalTwin public string ETag { get; set; } [JsonPropertyName("$metadata")] - public CustomDigitalTwinMetadata Metadata { get; set; } + public CustomDigitalTwinMetadata Metadata { get; set; } = new CustomDigitalTwinMetadata(); [JsonPropertyName("Prop1")] public string Prop1 { get; set; } @@ -34,7 +34,7 @@ internal class CustomDigitalTwin internal class Component1 { [JsonPropertyName("$metadata")] - public Component1Metadata Metadata { get; set; } + public Component1Metadata Metadata { get; set; } = new Component1Metadata(); [JsonPropertyName("ComponentProp1")] public string ComponentProp1 { get; set; } diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md index 1263f957d19e5..389e9cf067778 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/samples/Readme.md @@ -138,7 +138,6 @@ var basicTwin = new BasicDigitalTwin "Component1", new ModelProperties { - Metadata = { }, // component properties CustomProperties = { @@ -164,12 +163,11 @@ You can review the [CustomDigitalTwin definition](https://github.com/Azure/azure var customTwin = new CustomDigitalTwin { Id = customDtId, - Metadata = new CustomDigitalTwinMetadata { ModelId = modelId }, + Metadata = { ModelId = modelId }, Prop1 = "Prop1 val", Prop2 = 987, Component1 = new Component1 { - Metadata = new Component1Metadata { }, ComponentProp1 = "Component prop1 val", ComponentProp2 = 123, } @@ -212,12 +210,11 @@ Custom types provide the best possible experience. var customTwin = new CustomDigitalTwin { Id = customDtId, - Metadata = new CustomDigitalTwinMetadata { ModelId = modelId }, + Metadata = { ModelId = modelId }, Prop1 = "Prop1 val", Prop2 = 987, Component1 = new Component1 { - Metadata = new Component1Metadata { }, ComponentProp1 = "Component prop1 val", ComponentProp2 = 123, } diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs index 5d33dfb1b2f9a..ddb016caab171 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/DigitalTwinsClient.cs @@ -189,12 +189,11 @@ public virtual Response GetDigitalTwin(string digitalTwinId, Cancellatio /// var customTwin = new CustomDigitalTwin /// { /// Id = customDtId, - /// Metadata = new CustomDigitalTwinMetadata { ModelId = modelId }, + /// Metadata = { ModelId = modelId }, /// Prop1 = "Prop1 val", /// Prop2 = 987, /// Component1 = new Component1 /// { - /// Metadata = new Component1Metadata { }, /// ComponentProp1 = "Component prop1 val", /// ComponentProp2 = 123, /// } diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/BasicDigitalTwin.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/BasicDigitalTwin.cs index 8c14f28931abe..2cbc6e95135c7 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/BasicDigitalTwin.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/BasicDigitalTwin.cs @@ -33,7 +33,6 @@ namespace Azure.DigitalTwins.Core.Serialization /// "Component1", /// new ModelProperties /// { - /// Metadata = { }, /// // component properties /// CustomProperties = /// { diff --git a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/ModelProperties.cs b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/ModelProperties.cs index dcd44f30dae0c..b32473bd2f1e7 100644 --- a/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/ModelProperties.cs +++ b/sdk/digitaltwins/Azure.DigitalTwins.Core/src/Serialization/ModelProperties.cs @@ -18,7 +18,7 @@ public class ModelProperties /// Information about the model a component conforms to. This field is present on every digital twin. /// [JsonPropertyName("$metadata")] - public ComponentMetadata Metadata { get; } = new ComponentMetadata(); + public ComponentMetadata Metadata { get; internal set; } = new ComponentMetadata(); /// /// Additional properties of the digital twin. This field will contain any properties of the digital twin that are not already defined by the other strong types of this class.