< Summary

Class:Azure.ResourceManager.Network.Models.Resource
Assembly:Azure.ResourceManager.Network
File(s):C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\Resource.cs
C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\Resource.Serialization.cs
Covered lines:14
Uncovered lines:53
Coverable lines:67
Total lines:169
Line coverage:20.8% (14 of 67)
Covered branches:0
Total branches:38
Branch coverage:0% (0 of 38)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Id()-100%100%
get_Name()-100%100%
get_Type()-100%100%
get_Location()-100%100%
get_Tags()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeResource(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\Resource.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9
 10namespace Azure.ResourceManager.Network.Models
 11{
 12    /// <summary> Common resource representation. </summary>
 13    public partial class Resource
 14    {
 15        /// <summary> Initializes a new instance of Resource. </summary>
 38816        public Resource()
 17        {
 38818        }
 19
 20        /// <summary> Initializes a new instance of Resource. </summary>
 21        /// <param name="id"> Resource ID. </param>
 22        /// <param name="name"> Resource name. </param>
 23        /// <param name="type"> Resource type. </param>
 24        /// <param name="location"> Resource location. </param>
 25        /// <param name="tags"> Resource tags. </param>
 231226        internal Resource(string id, string name, string type, string location, IDictionary<string, string> tags)
 27        {
 231228            Id = id;
 231229            Name = name;
 231230            Type = type;
 231231            Location = location;
 231232            Tags = tags;
 231233        }
 34
 35        /// <summary> Resource ID. </summary>
 398436        public string Id { get; set; }
 37        /// <summary> Resource name. </summary>
 162838        public string Name { get; }
 39        /// <summary> Resource type. </summary>
 126440        public string Type { get; }
 41        /// <summary> Resource location. </summary>
 476442        public string Location { get; set; }
 43        /// <summary> Resource tags. </summary>
 404844        public IDictionary<string, string> Tags { get; set; }
 45    }
 46}

C:\Git\azure-sdk-for-net\sdk\network\Azure.ResourceManager.Network\src\Generated\Models\Resource.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.ResourceManager.Network.Models
 13{
 14    public partial class Resource : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            if (Id != null)
 20            {
 021                writer.WritePropertyName("id");
 022                writer.WriteStringValue(Id);
 23            }
 024            if (Name != null)
 25            {
 026                writer.WritePropertyName("name");
 027                writer.WriteStringValue(Name);
 28            }
 029            if (Type != null)
 30            {
 031                writer.WritePropertyName("type");
 032                writer.WriteStringValue(Type);
 33            }
 034            if (Location != null)
 35            {
 036                writer.WritePropertyName("location");
 037                writer.WriteStringValue(Location);
 38            }
 039            if (Tags != null)
 40            {
 041                writer.WritePropertyName("tags");
 042                writer.WriteStartObject();
 043                foreach (var item in Tags)
 44                {
 045                    writer.WritePropertyName(item.Key);
 046                    writer.WriteStringValue(item.Value);
 47                }
 048                writer.WriteEndObject();
 49            }
 050            writer.WriteEndObject();
 051        }
 52
 53        internal static Resource DeserializeResource(JsonElement element)
 54        {
 055            string id = default;
 056            string name = default;
 057            string type = default;
 058            string location = default;
 059            IDictionary<string, string> tags = default;
 060            foreach (var property in element.EnumerateObject())
 61            {
 062                if (property.NameEquals("id"))
 63                {
 064                    if (property.Value.ValueKind == JsonValueKind.Null)
 65                    {
 66                        continue;
 67                    }
 068                    id = property.Value.GetString();
 069                    continue;
 70                }
 071                if (property.NameEquals("name"))
 72                {
 073                    if (property.Value.ValueKind == JsonValueKind.Null)
 74                    {
 75                        continue;
 76                    }
 077                    name = property.Value.GetString();
 078                    continue;
 79                }
 080                if (property.NameEquals("type"))
 81                {
 082                    if (property.Value.ValueKind == JsonValueKind.Null)
 83                    {
 84                        continue;
 85                    }
 086                    type = property.Value.GetString();
 087                    continue;
 88                }
 089                if (property.NameEquals("location"))
 90                {
 091                    if (property.Value.ValueKind == JsonValueKind.Null)
 92                    {
 93                        continue;
 94                    }
 095                    location = property.Value.GetString();
 096                    continue;
 97                }
 098                if (property.NameEquals("tags"))
 99                {
 0100                    if (property.Value.ValueKind == JsonValueKind.Null)
 101                    {
 102                        continue;
 103                    }
 0104                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 0105                    foreach (var property0 in property.Value.EnumerateObject())
 106                    {
 0107                        if (property0.Value.ValueKind == JsonValueKind.Null)
 108                        {
 0109                            dictionary.Add(property0.Name, null);
 110                        }
 111                        else
 112                        {
 0113                            dictionary.Add(property0.Name, property0.Value.GetString());
 114                        }
 115                    }
 0116                    tags = dictionary;
 117                    continue;
 118                }
 119            }
 0120            return new Resource(id, name, type, location, tags);
 121        }
 122    }
 123}