< Summary

Information
Class: System.IO.Compression.ZLibException
Assembly: System.IO.Compression
File(s): D:\runner\runtime\src\libraries\System.IO.Compression\src\System\IO\Compression\DeflateZLib\ZLibException.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 74
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
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%
.ctor(...)100%110%
.ctor(...)100%110%
System.Runtime.Serialization.ISerializable.GetObjectData(...)100%110%

File(s)

D:\runner\runtime\src\libraries\System.IO.Compression\src\System\IO\Compression\DeflateZLib\ZLibException.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.ComponentModel;
 5using System.Runtime.Serialization;
 6
 7namespace System.IO.Compression
 8{
 9    /// <summary>
 10    /// This is the exception that is thrown when a ZLib returns an error code indicating an unrecoverable error.
 11    /// </summary>
 12    [Serializable]
 13    [System.Runtime.CompilerServices.TypeForwardedFrom("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5
 14    public class ZLibException : IOException, ISerializable
 15    {
 016        private readonly string? _zlibErrorContext = string.Empty;
 017        private readonly string? _zlibErrorMessage = string.Empty;
 018        private readonly ZLibNative.ErrorCode _zlibErrorCode = ZLibNative.ErrorCode.Ok;
 19
 20        /// <summary>
 21        /// This is the preferred constructor to use.
 22        /// The other constructors are provided for compliance to Fx design guidelines.
 23        /// </summary>
 24        /// <param name="message">A (localised) human readable error description.</param>
 25        /// <param name="zlibErrorContext">A description of the context within zlib where the error occurred (e.g. the f
 26        /// <param name="zlibErrorCode">The error code returned by a ZLib function that caused this exception.</param>
 27        /// <param name="zlibErrorMessage">The string provided by ZLib as error information (unlocalised).</param>
 028        public ZLibException(string? message, string? zlibErrorContext, int zlibErrorCode, string? zlibErrorMessage) : b
 029        {
 030            _zlibErrorContext = zlibErrorContext;
 031            _zlibErrorCode = (ZLibNative.ErrorCode)zlibErrorCode;
 032            _zlibErrorMessage = zlibErrorMessage;
 033        }
 34
 35        /// <summary>
 36        /// This constructor is provided in compliance with common .NET Framework design patterns;
 37        /// developers should prefer using the constructor
 38        /// <code>public ZLibException(string message, string zlibErrorContext, ZLibNative.ErrorCode zlibErrorCode, stri
 39        /// </summary>
 040        public ZLibException() { }
 41
 42        /// <summary>
 43        /// This constructor is provided in compliance with common .NET Framework design patterns;
 44        /// developers should prefer using the constructor
 45        /// <code>public ZLibException(string message, string zlibErrorContext, ZLibNative.ErrorCode zlibErrorCode, stri
 46        /// </summary>
 47        /// <param name="message">The error message that explains the reason for the exception.</param>
 48        /// <param name="innerException">The exception that is the cause of the current exception, or a <code>null</code
 049        public ZLibException(string? message, Exception? innerException) : base(message, innerException) { }
 50
 51        /// <summary>
 52        /// Initializes a new ZLibException with serialized data.
 53        /// </summary>
 54        /// <param name="info">The SerializationInfo that holds the serialized object data about the exception being thr
 55        /// <param name="context">The StreamingContext that contains contextual information about the source or destinat
 56        [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlForma
 57        [EditorBrowsable(EditorBrowsableState.Never)]
 058        protected ZLibException(SerializationInfo info, StreamingContext context) : base(info, context)
 059        {
 060            _zlibErrorContext = info.GetString("zlibErrorContext");
 061            _zlibErrorCode = (ZLibNative.ErrorCode)info.GetInt32("zlibErrorCode");
 062            _zlibErrorMessage = info.GetString("zlibErrorMessage");
 063        }
 64
 65        [Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlForma
 66        void ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
 067        {
 068            base.GetObjectData(si, context);
 069            si.AddValue("zlibErrorContext", _zlibErrorContext);
 070            si.AddValue("zlibErrorCode", (int)_zlibErrorCode);
 071            si.AddValue("zlibErrorMessage", _zlibErrorMessage);
 072        }
 73    }
 74}