<commit_before>﻿// Copyright 2005-2015 <NAME> & Contributors. All rights reserved. See doc/License.md in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;

namespace CommandLine
{
    /// <summary>
    /// Discriminator enumeration of <see cref="CommandLine.ParserResultType"/> derivates.
    /// </summary>
    public enum ParserResultType
    {
        /// <summary>
        /// Value of <see cref="CommandLine.Parsed{T}"/> type.
        /// </summary>
        Parsed,
        /// <summary>
        /// Value of <see cref="CommandLine.NotParsed{T}"/> type.
        /// </summary>
        NotParsed
    }

    /// <summary>
    /// Models a parser result. When inherited by <see cref="CommandLine.Parsed{T}"/>, it contains an instance of type <typeparamref name="T"/>
    /// with parsed values.
    /// When inherited by <see cref="CommandLine.NotParsed{T}"/>, it contains a sequence of <see cref="CommandLine.Error"/>.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public abstract class ParserResult<T>
    {
        private readonly ParserResultType tag;
        //private readonly T value;
        private readonly IEnumerable<Type> verbTypes;
        private readonly Type typeInfo;

        //internal ParserResult(ParserResultType tag, T value, IEnumerable<Type> verbTypes)
        internal ParserResult(ParserResultType tag, Type typeInfo, IEnumerable<Type> verbTypes)
        {
            this.tag = tag;
            //this.value = value;
            this.typeInfo = typeInfo;
            this.verbTypes = verbTypes;
        }

        /// <summary>
        /// Parser result type discriminator, defined as <see cref="CommandLine.ParserResultType"/> enumeration.
        /// </summary>
        public ParserResultType Tag
        {
            get { return this.tag; }
        }

        internal Type TypeInfo
        {
            get { return typeInfo; }
        }

        internal IEnumerable<Type> VerbTypes
        {
            get { return verbTypes; }
        }

        //internal T Value
        //{
        //    get { return value; }
        //}
    }

    /// <summary>
    /// It contains an instance of type <typeparamref name="T"/> with parsed values.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public sealed class Parsed<T> : ParserResult<T>, IEquatable<Parsed<T>>
    {
        private readonly T value;

        internal Parsed(T value, IEnumerable<Type> verbTypes)
            : base(ParserResultType.Parsed, value.GetType(), verbTypes)
            //: base(ParserResultType.Parsed, value, verbTypes)
        {
            this.value = value;
        }

        internal Parsed(T value)
            : this(value, Enumerable.Empty<Type>())
        {
        }

        /// <summary>
        /// Gets the instance with parsed values.
        /// </summary>
        //public new T Value
        public T Value
        {
            //get { return base.Value; }
            get { return value; }
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="System.Object"/>.</param>
        /// <returns><value>true</value> if the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>; otherwise, <value>false</value>.</returns>
        public override bool Equals(object obj)
        {
            var other = obj as Parsed<T>;
            if (other != null)
            {
                return Equals(other);
            }

            return base.Equals(obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <remarks>A hash code for the current <see cref="System.Object"/>.</remarks>
        public override int GetHashCode()
        {
            return new { Tag, Value, VerbTypes }.GetHashCode();
        }

        /// <summary>
        /// Returns a value that indicates whether the current instance and a specified <see cref="CommandLine.Parsed{T}"/> have the same value.
        /// </summary>
        /// <param name="other">The <see cref="CommandLine.Parsed{T}"/> instance to compare.</param>
        /// <returns><value>true</value> if this instance of <see cref="CommandLine.Parsed{T}"/> and <paramref name="other"/> have the same value; otherwise, <value>false</value>.</returns>
        public bool Equals(Parsed<T> other)
        {
            if (other == null)
            {
                return false;
            }

            return this.Tag.Equals(other.Tag)
                    && Value.Equals(other.Value)
                    && VerbTypes.SequenceEqual(other.VerbTypes);
        }
    }

    /// <summary>
    /// It contains a sequence of <see cref="CommandLine.Error"/>.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public sealed class NotParsed<T> : ParserResult<T>, IEquatable<NotParsed<T>>
    {
        private readonly IEnumerable<Error> errors;

        //internal NotParsed(T value, IEnumerable<Type> verbTypes, IEnumerable<Error> errors)
        //    : base(ParserResultType.NotParsed, value, verbTypes)
        internal NotParsed(Type typeInfo, IEnumerable<Type> verbTypes, IEnumerable<Error> errors)
            : base(ParserResultType.NotParsed, typeInfo, verbTypes)
        {
            this.errors = errors;
        }

        //internal NotParsed(T value, IEnumerable<Error> errors)
        //    : this(value, Enumerable.Empty<Type>(), errors)
        internal NotParsed(Type typeInfo, IEnumerable<Error> errors)
            : this(typeInfo, Enumerable.Empty<Type>(), errors)
        {
        }


        /// <summary>
        /// Gets the sequence of parsing errors.
        /// </summary>
        public IEnumerable<Error> Errors
        {
            get { return errors; }
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>.<commit_msg>:paperclip: Removing commented code<commit_after>﻿// Copyright 2005-2015 <NAME> & Contributors. All rights reserved. See doc/License.md in the project root for license information.

using System;
using System.Collections.Generic;
using System.Linq;

namespace CommandLine
{
    /// <summary>
    /// Discriminator enumeration of <see cref="CommandLine.ParserResultType"/> derivates.
    /// </summary>
    public enum ParserResultType
    {
        /// <summary>
        /// Value of <see cref="CommandLine.Parsed{T}"/> type.
        /// </summary>
        Parsed,
        /// <summary>
        /// Value of <see cref="CommandLine.NotParsed{T}"/> type.
        /// </summary>
        NotParsed
    }

    /// <summary>
    /// Models a parser result. When inherited by <see cref="CommandLine.Parsed{T}"/>, it contains an instance of type <typeparamref name="T"/>
    /// with parsed values.
    /// When inherited by <see cref="CommandLine.NotParsed{T}"/>, it contains a sequence of <see cref="CommandLine.Error"/>.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public abstract class ParserResult<T>
    {
        private readonly ParserResultType tag;
        private readonly IEnumerable<Type> verbTypes;
        private readonly Type typeInfo;

        internal ParserResult(ParserResultType tag, Type typeInfo, IEnumerable<Type> verbTypes)
        {
            this.tag = tag;
            this.typeInfo = typeInfo;
            this.verbTypes = verbTypes;
        }

        /// <summary>
        /// Parser result type discriminator, defined as <see cref="CommandLine.ParserResultType"/> enumeration.
        /// </summary>
        public ParserResultType Tag
        {
            get { return this.tag; }
        }

        internal Type TypeInfo
        {
            get { return typeInfo; }
        }

        internal IEnumerable<Type> VerbTypes
        {
            get { return verbTypes; }
        }
    }

    /// <summary>
    /// It contains an instance of type <typeparamref name="T"/> with parsed values.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public sealed class Parsed<T> : ParserResult<T>, IEquatable<Parsed<T>>
    {
        private readonly T value;

        internal Parsed(T value, IEnumerable<Type> verbTypes)
            : base(ParserResultType.Parsed, value.GetType(), verbTypes)
            //: base(ParserResultType.Parsed, value, verbTypes)
        {
            this.value = value;
        }

        internal Parsed(T value)
            : this(value, Enumerable.Empty<Type>())
        {
        }

        /// <summary>
        /// Gets the instance with parsed values.
        /// </summary>
        public T Value
        {
            get { return value; }
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="System.Object"/>.</param>
        /// <returns><value>true</value> if the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>; otherwise, <value>false</value>.</returns>
        public override bool Equals(object obj)
        {
            var other = obj as Parsed<T>;
            if (other != null)
            {
                return Equals(other);
            }

            return base.Equals(obj);
        }

        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <remarks>A hash code for the current <see cref="System.Object"/>.</remarks>
        public override int GetHashCode()
        {
            return new { Tag, Value, VerbTypes }.GetHashCode();
        }

        /// <summary>
        /// Returns a value that indicates whether the current instance and a specified <see cref="CommandLine.Parsed{T}"/> have the same value.
        /// </summary>
        /// <param name="other">The <see cref="CommandLine.Parsed{T}"/> instance to compare.</param>
        /// <returns><value>true</value> if this instance of <see cref="CommandLine.Parsed{T}"/> and <paramref name="other"/> have the same value; otherwise, <value>false</value>.</returns>
        public bool Equals(Parsed<T> other)
        {
            if (other == null)
            {
                return false;
            }

            return this.Tag.Equals(other.Tag)
                    && Value.Equals(other.Value)
                    && VerbTypes.SequenceEqual(other.VerbTypes);
        }
    }

    /// <summary>
    /// It contains a sequence of <see cref="CommandLine.Error"/>.
    /// </summary>
    /// <typeparam name="T">The type with attributes that define the syntax of parsing rules.</typeparam>
    public sealed class NotParsed<T> : ParserResult<T>, IEquatable<NotParsed<T>>
    {
        private readonly IEnumerable<Error> errors;

        internal NotParsed(Type typeInfo, IEnumerable<Type> verbTypes, IEnumerable<Error> errors)
            : base(ParserResultType.NotParsed, typeInfo, verbTypes)
        {
            this.errors = errors;
        }

        internal NotParsed(Type typeInfo, IEnumerable<Error> errors)
            : this(typeInfo, Enumerable.Empty<Type>(), errors)
        {
        }


        /// <summary>
        /// Gets the sequence of parsing errors.
        /// </summary>
        public IEnumerable<Error> Errors
        {
            get { return errors; }
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="System.Object"/>.
{'fraction_non_alphanumeric': 0.12639710716633792, 'fraction_numerical': 0.0013149243918474688, 'mean_word_length': 1.9608272506082725, 'pattern_counts': {'":': 0, '<': 198, '<?xml version=': 0, '>': 198, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3080346', 'n_tokens_mistral': 3280, 'n_tokens_neox': 3199, 'n_words': 936}