< Summary

Class:Azure.Search.Documents.Indexes.Models.PatternAnalyzer
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternAnalyzer.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternAnalyzer.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\PatternAnalyzer.cs
Covered lines:71
Uncovered lines:3
Coverable lines:74
Total lines:192
Line coverage:95.9% (71 of 74)
Covered branches:31
Total branches:34
Branch coverage:91.1% (31 of 34)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
.ctor(...)-100%50%
get_LowerCaseTerms()-100%100%
get_Pattern()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-90.91%90%
DeserializePatternAnalyzer(...)-100%100%
get_FlagsInternal()-100%100%
set_FlagsInternal(...)-100%100%
get_Flags()-100%100%
get_Stopwords()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternAnalyzer.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;
 10using Azure.Core;
 11
 12namespace Azure.Search.Documents.Indexes.Models
 13{
 14    /// <summary> Flexibly separates text into terms via a regular expression pattern. This analyzer is implemented usin
 15    public partial class PatternAnalyzer : LexicalAnalyzer
 16    {
 17        /// <summary> Initializes a new instance of PatternAnalyzer. </summary>
 18        /// <param name="name"> The name of the analyzer. It must only contain letters, digits, spaces, dashes or unders
 19        /// <exception cref="ArgumentNullException"> <paramref name="name"/> is null. </exception>
 520        public PatternAnalyzer(string name) : base(name)
 21        {
 522            if (name == null)
 23            {
 024                throw new ArgumentNullException(nameof(name));
 25            }
 26
 527            Stopwords = new ChangeTrackingList<string>();
 528            ODataType = "#Microsoft.Azure.Search.PatternAnalyzer";
 529        }
 30
 31        /// <summary> Initializes a new instance of PatternAnalyzer. </summary>
 32        /// <param name="oDataType"> Identifies the concrete type of the analyzer. </param>
 33        /// <param name="name"> The name of the analyzer. It must only contain letters, digits, spaces, dashes or unders
 34        /// <param name="lowerCaseTerms"> A value indicating whether terms should be lower-cased. Default is true. </par
 35        /// <param name="pattern"> A regular expression pattern to match token separators. Default is an expression that
 36        /// <param name="flagsInternal"> Regular expression flags. </param>
 37        /// <param name="stopwords"> A list of stopwords. </param>
 538        internal PatternAnalyzer(string oDataType, string name, bool? lowerCaseTerms, string pattern, string flagsIntern
 39        {
 540            LowerCaseTerms = lowerCaseTerms;
 541            Pattern = pattern;
 542            FlagsInternal = flagsInternal;
 543            Stopwords = stopwords;
 544            ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternAnalyzer";
 545        }
 46
 47        /// <summary> A value indicating whether terms should be lower-cased. Default is true. </summary>
 1048        public bool? LowerCaseTerms { get; set; }
 49        /// <summary> A regular expression pattern to match token separators. Default is an expression that matches one 
 1450        public string Pattern { get; set; }
 51    }
 52}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternAnalyzer.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 PatternAnalyzer : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 518            writer.WriteStartObject();
 519            if (Optional.IsDefined(LowerCaseTerms))
 20            {
 021                writer.WritePropertyName("lowercase");
 022                writer.WriteBooleanValue(LowerCaseTerms.Value);
 23            }
 524            if (Optional.IsDefined(Pattern))
 25            {
 226                writer.WritePropertyName("pattern");
 227                writer.WriteStringValue(Pattern);
 28            }
 529            if (Optional.IsDefined(FlagsInternal))
 30            {
 531                writer.WritePropertyName("flags");
 532                writer.WriteStringValue(FlagsInternal);
 33            }
 534            if (Optional.IsCollectionDefined(Stopwords))
 35            {
 236                writer.WritePropertyName("stopwords");
 237                writer.WriteStartArray();
 1638                foreach (var item in Stopwords)
 39                {
 640                    writer.WriteStringValue(item);
 41                }
 242                writer.WriteEndArray();
 43            }
 544            writer.WritePropertyName("@odata.type");
 545            writer.WriteStringValue(ODataType);
 546            writer.WritePropertyName("name");
 547            writer.WriteStringValue(Name);
 548            writer.WriteEndObject();
 549        }
 50
 51        internal static PatternAnalyzer DeserializePatternAnalyzer(JsonElement element)
 52        {
 553            Optional<bool> lowercase = default;
 554            Optional<string> pattern = default;
 555            Optional<string> flags = default;
 556            Optional<IList<string>> stopwords = default;
 557            string odataType = default;
 558            string name = default;
 5259            foreach (var property in element.EnumerateObject())
 60            {
 2161                if (property.NameEquals("lowercase"))
 62                {
 263                    lowercase = property.Value.GetBoolean();
 264                    continue;
 65                }
 1966                if (property.NameEquals("pattern"))
 67                {
 268                    pattern = property.Value.GetString();
 269                    continue;
 70                }
 1771                if (property.NameEquals("flags"))
 72                {
 573                    flags = property.Value.GetString();
 574                    continue;
 75                }
 1276                if (property.NameEquals("stopwords"))
 77                {
 278                    List<string> array = new List<string>();
 1679                    foreach (var item in property.Value.EnumerateArray())
 80                    {
 681                        array.Add(item.GetString());
 82                    }
 283                    stopwords = array;
 284                    continue;
 85                }
 1086                if (property.NameEquals("@odata.type"))
 87                {
 588                    odataType = property.Value.GetString();
 589                    continue;
 90                }
 591                if (property.NameEquals("name"))
 92                {
 593                    name = property.Value.GetString();
 94                    continue;
 95                }
 96            }
 597            return new PatternAnalyzer(odataType, name, Optional.ToNullable(lowercase), pattern.Value, flags.Value, Opti
 98        }
 99    }
 100}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\PatternAnalyzer.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using Azure.Core;
 6
 7namespace Azure.Search.Documents.Indexes.Models
 8{
 9    public partial class PatternAnalyzer
 10    {
 11        [CodeGenMember("flags")]
 12        private string FlagsInternal
 13        {
 1014            get => string.Join("|", Flags);
 15            set
 16            {
 517                Flags.Clear();
 18
 519                if (!string.IsNullOrEmpty(value))
 20                {
 421                    string[] values = value.Split('|');
 2222                    for (int i = 0; i < values.Length; ++i)
 23                    {
 724                        Flags.Add(new RegexFlag(values[i]));
 25                    }
 26                }
 527            }
 28        }
 29
 30        /// <summary>
 31        /// Gets regular expression flags for <see cref="Pattern"/>.
 32        /// </summary>
 4533        public IList<RegexFlag> Flags { get; } = new List<RegexFlag>();
 34
 35        /// <summary>
 36        /// Gets a list of stopwords.
 37        /// </summary>
 1338        public IList<string> Stopwords { get; }
 39    }
 40}