< Summary

Class:Azure.Search.Documents.Indexes.Models.PatternTokenizer
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternTokenizer.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternTokenizer.Serialization.cs
C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\PatternTokenizer.cs
Covered lines:49
Uncovered lines:9
Coverable lines:58
Total lines:160
Line coverage:84.4% (49 of 58)
Covered branches:20
Total branches:26
Branch coverage:76.9% (20 of 26)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
.ctor(...)-100%50%
get_Pattern()-100%100%
get_Group()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-75%66.67%
DeserializePatternTokenizer(...)-80.95%83.33%
get_FlagsInternal()-100%100%
set_FlagsInternal(...)-100%100%
get_Flags()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternTokenizer.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;
 9
 10namespace Azure.Search.Documents.Indexes.Models
 11{
 12    /// <summary> Tokenizer that uses regex pattern matching to construct distinct tokens. This tokenizer is implemented
 13    public partial class PatternTokenizer : LexicalTokenizer
 14    {
 15        /// <summary> Initializes a new instance of PatternTokenizer. </summary>
 16        /// <param name="name"> The name of the tokenizer. It must only contain letters, digits, spaces, dashes or under
 17        /// <exception cref="ArgumentNullException"> <paramref name="name"/> is null. </exception>
 318        public PatternTokenizer(string name) : base(name)
 19        {
 320            if (name == null)
 21            {
 022                throw new ArgumentNullException(nameof(name));
 23            }
 24
 325            ODataType = "#Microsoft.Azure.Search.PatternTokenizer";
 326        }
 27
 28        /// <summary> Initializes a new instance of PatternTokenizer. </summary>
 29        /// <param name="oDataType"> Identifies the concrete type of the tokenizer. </param>
 30        /// <param name="name"> The name of the tokenizer. It must only contain letters, digits, spaces, dashes or under
 31        /// <param name="pattern"> A regular expression pattern to match token separators. Default is an expression that
 32        /// <param name="flagsInternal"> Regular expression flags. </param>
 33        /// <param name="group"> The zero-based ordinal of the matching group in the regular expression pattern to extra
 334        internal PatternTokenizer(string oDataType, string name, string pattern, string flagsInternal, int? group) : bas
 35        {
 336            Pattern = pattern;
 337            FlagsInternal = flagsInternal;
 338            Group = group;
 339            ODataType = oDataType ?? "#Microsoft.Azure.Search.PatternTokenizer";
 340        }
 41
 42        /// <summary> A regular expression pattern to match token separators. Default is an expression that matches one 
 643        public string Pattern { get; set; }
 44        /// <summary> The zero-based ordinal of the matching group in the regular expression pattern to extract into tok
 645        public int? Group { get; set; }
 46    }
 47}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Generated\Models\PatternTokenizer.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.Text.Json;
 9using Azure.Core;
 10
 11namespace Azure.Search.Documents.Indexes.Models
 12{
 13    public partial class PatternTokenizer : IUtf8JsonSerializable
 14    {
 15        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 16        {
 317            writer.WriteStartObject();
 318            if (Optional.IsDefined(Pattern))
 19            {
 020                writer.WritePropertyName("pattern");
 021                writer.WriteStringValue(Pattern);
 22            }
 323            if (Optional.IsDefined(FlagsInternal))
 24            {
 325                writer.WritePropertyName("flags");
 326                writer.WriteStringValue(FlagsInternal);
 27            }
 328            if (Optional.IsDefined(Group))
 29            {
 030                writer.WritePropertyName("group");
 031                writer.WriteNumberValue(Group.Value);
 32            }
 333            writer.WritePropertyName("@odata.type");
 334            writer.WriteStringValue(ODataType);
 335            writer.WritePropertyName("name");
 336            writer.WriteStringValue(Name);
 337            writer.WriteEndObject();
 338        }
 39
 40        internal static PatternTokenizer DeserializePatternTokenizer(JsonElement element)
 41        {
 342            Optional<string> pattern = default;
 343            Optional<string> flags = default;
 344            Optional<int> group = default;
 345            string odataType = default;
 346            string name = default;
 2447            foreach (var property in element.EnumerateObject())
 48            {
 949                if (property.NameEquals("pattern"))
 50                {
 051                    pattern = property.Value.GetString();
 052                    continue;
 53                }
 954                if (property.NameEquals("flags"))
 55                {
 356                    flags = property.Value.GetString();
 357                    continue;
 58                }
 659                if (property.NameEquals("group"))
 60                {
 061                    group = property.Value.GetInt32();
 062                    continue;
 63                }
 664                if (property.NameEquals("@odata.type"))
 65                {
 366                    odataType = property.Value.GetString();
 367                    continue;
 68                }
 369                if (property.NameEquals("name"))
 70                {
 371                    name = property.Value.GetString();
 72                    continue;
 73                }
 74            }
 375            return new PatternTokenizer(odataType, name, pattern.Value, flags.Value, Optional.ToNullable(group));
 76        }
 77    }
 78}

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\Models\PatternTokenizer.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 PatternTokenizer
 10    {
 11        [CodeGenMember("flags")]
 12        private string FlagsInternal
 13        {
 614            get => string.Join("|", Flags);
 15            set
 16            {
 317                Flags.Clear();
 18
 319                if (!string.IsNullOrEmpty(value))
 20                {
 221                    string[] values = value.Split('|');
 1022                    for (int i = 0; i < values.Length; ++i)
 23                    {
 324                        Flags.Add(new RegexFlag(values[i]));
 25                    }
 26                }
 327            }
 28        }
 29
 30        /// <summary>
 31        /// Regular expression flags for <see cref="Pattern"/>.
 32        /// </summary>
 2733        public IList<RegexFlag> Flags { get; } = new List<RegexFlag>();
 34    }
 35}