< Summary

Class:Azure.Search.Documents.Indexes.Models.TextTranslationSkill
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\TextTranslationSkill.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\TextTranslationSkill.Serialization.cs
Covered lines:87
Uncovered lines:10
Coverable lines:97
Total lines:210
Line coverage:89.6% (87 of 97)
Covered branches:40
Total branches:48
Branch coverage:83.3% (40 of 48)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-75%50%
.ctor(...)-100%50%
get_DefaultToLanguageCode()-100%100%
get_DefaultFromLanguageCode()-100%100%
get_SuggestedFrom()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-82.35%75%
DeserializeTextTranslationSkill(...)-95.65%96.15%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\TextTranslationSkill.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;
 9using System.Collections.Generic;
 10
 11namespace Azure.Search.Documents.Indexes.Models
 12{
 13    /// <summary> A skill to translate text from one language to another. </summary>
 14    public partial class TextTranslationSkill : SearchIndexerSkill
 15    {
 16        /// <summary> Initializes a new instance of TextTranslationSkill. </summary>
 17        /// <param name="inputs"> Inputs of the skills could be a column in the source data set, or the output of an ups
 18        /// <param name="outputs"> The output of a skill is either a field in a search index, or a value that can be con
 19        /// <param name="defaultToLanguageCode"> The language code to translate documents into for documents that don&ap
 20        /// <exception cref="ArgumentNullException"> <paramref name="inputs"/> or <paramref name="outputs"/> is null. </
 121        public TextTranslationSkill(IEnumerable<InputFieldMappingEntry> inputs, IEnumerable<OutputFieldMappingEntry> out
 22        {
 123            if (inputs == null)
 24            {
 025                throw new ArgumentNullException(nameof(inputs));
 26            }
 127            if (outputs == null)
 28            {
 029                throw new ArgumentNullException(nameof(outputs));
 30            }
 31
 132            DefaultToLanguageCode = defaultToLanguageCode;
 133            ODataType = "#Microsoft.Skills.Text.TranslationSkill";
 134        }
 35
 36        /// <summary> Initializes a new instance of TextTranslationSkill. </summary>
 37        /// <param name="oDataType"> Identifies the concrete type of the skill. </param>
 38        /// <param name="name"> The name of the skill which uniquely identifies it within the skillset. A skill with no 
 39        /// <param name="description"> The description of the skill which describes the inputs, outputs, and usage of th
 40        /// <param name="context"> Represents the level at which operations take place, such as the document root or doc
 41        /// <param name="inputs"> Inputs of the skills could be a column in the source data set, or the output of an ups
 42        /// <param name="outputs"> The output of a skill is either a field in a search index, or a value that can be con
 43        /// <param name="defaultToLanguageCode"> The language code to translate documents into for documents that don&ap
 44        /// <param name="defaultFromLanguageCode"> The language code to translate documents from for documents that don&
 45        /// <param name="suggestedFrom"> The language code to translate documents from when neither the fromLanguageCode
 146        internal TextTranslationSkill(string oDataType, string name, string description, string context, IList<InputFiel
 47        {
 148            DefaultToLanguageCode = defaultToLanguageCode;
 149            DefaultFromLanguageCode = defaultFromLanguageCode;
 150            SuggestedFrom = suggestedFrom;
 151            ODataType = oDataType ?? "#Microsoft.Skills.Text.TranslationSkill";
 152        }
 53
 54        /// <summary> The language code to translate documents into for documents that don&apos;t specify the to languag
 355        public TextTranslationSkillLanguage DefaultToLanguageCode { get; set; }
 56        /// <summary> The language code to translate documents from for documents that don&apos;t specify the from langu
 457        public TextTranslationSkillLanguage? DefaultFromLanguageCode { get; set; }
 58        /// <summary> The language code to translate documents from when neither the fromLanguageCode input nor the defa
 259        public TextTranslationSkillLanguage? SuggestedFrom { get; set; }
 60    }
 61}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\TextTranslationSkill.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.Search.Documents.Indexes.Models
 13{
 14    public partial class TextTranslationSkill : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 118            writer.WriteStartObject();
 119            writer.WritePropertyName("defaultToLanguageCode");
 120            writer.WriteStringValue(DefaultToLanguageCode.ToString());
 121            if (Optional.IsDefined(DefaultFromLanguageCode))
 22            {
 123                writer.WritePropertyName("defaultFromLanguageCode");
 124                writer.WriteStringValue(DefaultFromLanguageCode.Value.ToString());
 25            }
 126            if (Optional.IsDefined(SuggestedFrom))
 27            {
 028                if (SuggestedFrom != null)
 29                {
 030                    writer.WritePropertyName("suggestedFrom");
 031                    writer.WriteStringValue(SuggestedFrom.Value.ToString());
 32                }
 33                else
 34                {
 035                    writer.WriteNull("suggestedFrom");
 36                }
 37            }
 138            writer.WritePropertyName("@odata.type");
 139            writer.WriteStringValue(ODataType);
 140            if (Optional.IsDefined(Name))
 41            {
 142                writer.WritePropertyName("name");
 143                writer.WriteStringValue(Name);
 44            }
 145            if (Optional.IsDefined(Description))
 46            {
 047                writer.WritePropertyName("description");
 048                writer.WriteStringValue(Description);
 49            }
 150            if (Optional.IsDefined(Context))
 51            {
 152                writer.WritePropertyName("context");
 153                writer.WriteStringValue(Context);
 54            }
 155            writer.WritePropertyName("inputs");
 156            writer.WriteStartArray();
 457            foreach (var item in Inputs)
 58            {
 159                writer.WriteObjectValue(item);
 60            }
 161            writer.WriteEndArray();
 162            writer.WritePropertyName("outputs");
 163            writer.WriteStartArray();
 464            foreach (var item in Outputs)
 65            {
 166                writer.WriteObjectValue(item);
 67            }
 168            writer.WriteEndArray();
 169            writer.WriteEndObject();
 170        }
 71
 72        internal static TextTranslationSkill DeserializeTextTranslationSkill(JsonElement element)
 73        {
 174            TextTranslationSkillLanguage defaultToLanguageCode = default;
 175            Optional<TextTranslationSkillLanguage> defaultFromLanguageCode = default;
 176            Optional<TextTranslationSkillLanguage?> suggestedFrom = default;
 177            string odataType = default;
 178            Optional<string> name = default;
 179            Optional<string> description = default;
 180            Optional<string> context = default;
 181            IList<InputFieldMappingEntry> inputs = default;
 182            IList<OutputFieldMappingEntry> outputs = default;
 2083            foreach (var property in element.EnumerateObject())
 84            {
 985                if (property.NameEquals("defaultToLanguageCode"))
 86                {
 187                    defaultToLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString());
 188                    continue;
 89                }
 890                if (property.NameEquals("defaultFromLanguageCode"))
 91                {
 192                    defaultFromLanguageCode = new TextTranslationSkillLanguage(property.Value.GetString());
 193                    continue;
 94                }
 795                if (property.NameEquals("suggestedFrom"))
 96                {
 197                    if (property.Value.ValueKind == JsonValueKind.Null)
 98                    {
 199                        suggestedFrom = null;
 1100                        continue;
 101                    }
 0102                    suggestedFrom = new TextTranslationSkillLanguage(property.Value.GetString());
 0103                    continue;
 104                }
 6105                if (property.NameEquals("@odata.type"))
 106                {
 1107                    odataType = property.Value.GetString();
 1108                    continue;
 109                }
 5110                if (property.NameEquals("name"))
 111                {
 1112                    name = property.Value.GetString();
 1113                    continue;
 114                }
 4115                if (property.NameEquals("description"))
 116                {
 1117                    description = property.Value.GetString();
 1118                    continue;
 119                }
 3120                if (property.NameEquals("context"))
 121                {
 1122                    context = property.Value.GetString();
 1123                    continue;
 124                }
 2125                if (property.NameEquals("inputs"))
 126                {
 1127                    List<InputFieldMappingEntry> array = new List<InputFieldMappingEntry>();
 4128                    foreach (var item in property.Value.EnumerateArray())
 129                    {
 1130                        array.Add(InputFieldMappingEntry.DeserializeInputFieldMappingEntry(item));
 131                    }
 1132                    inputs = array;
 1133                    continue;
 134                }
 1135                if (property.NameEquals("outputs"))
 136                {
 1137                    List<OutputFieldMappingEntry> array = new List<OutputFieldMappingEntry>();
 4138                    foreach (var item in property.Value.EnumerateArray())
 139                    {
 1140                        array.Add(OutputFieldMappingEntry.DeserializeOutputFieldMappingEntry(item));
 141                    }
 1142                    outputs = array;
 143                    continue;
 144                }
 145            }
 1146            return new TextTranslationSkill(odataType, name.Value, description.Value, context.Value, inputs, outputs, de
 147        }
 148    }
 149}