< Summary

Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 77
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%110%
.ctor(...)100%110%
GetEncoding()0%440%
Equals(...)0%220%
GetHashCode()100%110%

File(s)

https://raw.githubusercontent.com/dotnet/runtime/811a7eabb75c42db53440e8ba3f60c07511cfd1f/src/libraries/System.Private.CoreLib/src/System/Text/EncodingInfo.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Diagnostics.CodeAnalysis;
 5
 6namespace System.Text
 7{
 8    public sealed class EncodingInfo
 9    {
 10        /// <summary>
 11        /// Construct an <see cref="EncodingInfo"/> object.
 12        /// </summary>
 13        /// <param name="provider">The <see cref="EncodingProvider"/> object which created this <see cref="EncodingInfo"
 14        /// <param name="codePage">The encoding codepage</param>
 15        /// <param name="name">The encoding name</param>
 16        /// <param name="displayName">The encoding display name</param>
 17        /// <returns></returns>
 018        public EncodingInfo(EncodingProvider provider, int codePage, string name, string displayName) : this(codePage, n
 19        {
 020            ArgumentNullException.ThrowIfNull(provider);
 021            ArgumentNullException.ThrowIfNull(name);
 022            ArgumentNullException.ThrowIfNull(displayName);
 23
 024            Provider = provider;
 025        }
 26
 027        internal EncodingInfo(int codePage, string name, string displayName)
 28        {
 029            CodePage = codePage;
 030            Name = name;
 031            DisplayName = displayName;
 032        }
 33
 34        /// <summary>
 35        /// Get the encoding codepage number
 36        /// </summary>
 37        /// <value>The codepage integer number</value>
 038        public int CodePage { get; }
 39
 40        /// <summary>
 41        /// Get the encoding name
 42        /// </summary>
 43        /// <value>The encoding name string</value>
 044        public string Name { get; }
 45
 46        /// <summary>
 47        /// Get the encoding display name
 48        /// </summary>
 49        /// <value>The encoding display name string</value>
 050        public string DisplayName { get; }
 51
 52        /// <summary>
 53        /// Get the <see cref="Encoding"/> object match the information in the <see cref="EncodingInfo"/> object
 54        /// </summary>
 55        /// <returns>The <see cref="Encoding"/> object</returns>
 056        public Encoding GetEncoding() => Provider?.GetEncoding(CodePage) ?? Encoding.GetEncoding(CodePage);
 57
 58        /// <summary>
 59        /// Compare this <see cref="EncodingInfo"/> object to other object.
 60        /// </summary>
 61        /// <param name="value">The other object to compare with this object</param>
 62        /// <returns>True if the value object is EncodingInfo object and has a codepage equals to this EncodingInfo obje
 063        public override bool Equals([NotNullWhen(true)] object? value) => value is EncodingInfo that && CodePage == that
 64
 65        /// <summary>
 66        /// Get a hashcode representing the current EncodingInfo object.
 67        /// </summary>
 68        /// <returns>The integer value representing the hash code of the EncodingInfo object.</returns>
 69        public override int GetHashCode()
 70        {
 071            return CodePage;
 72        }
 73
 074        internal EncodingProvider? Provider { get; }
 75    }
 76}
 77