<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infra.IoC
{
    [ContractClass(typeof(TypesContract))]
    public abstract class Types : IEnumerable<Type>
    {
        public static Types Referenced { get; } = new AssemblyTypes(Assemblies.Referenced);
        public static Types Local { get; } = new AssemblyTypes(Assemblies.Local);
        public static Types In(string directory) => In(Assemblies.In(directory));
        public static Types In(Assemblies assemblies) => new AssemblyTypes(assemblies);

        public abstract IEnumerator<Type> GetEnumerator();

        IEnumerator IEnumerable.GetEnumerator()
        {
            Contract.Ensures(Contract.Result<IEnumerator>() != null);
            return GetEnumerator();
        }

        public Types With<TAttribute>() where TAttribute : Attribute
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this, 
                t => t.IsDefined(typeof(TAttribute), false));
        }

        public Types KindOf(string kind)
        {
            Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(kind));
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.Namespace?.EndsWith("." + kind) == true);
        }

        public Types Only<T>()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => typeof(T).IsAssignableFrom(t));
        }

        public Types Interfaces()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.IsInterface);
        }

        public Types Classes()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.IsClass && !t.IsAbstract);
        }
  
        public static Types operator +(Types x, Types y)
        {
            Contract.Requires<ArgumentNullException>(x != null);
            Contract.Requires<ArgumentNullException>(y != null);
            Contract.Ensures(Contract.Result<Types>() != null);
            return new CombinedTypes(x, y);
        }
    }

    [ContractClassFor(typeof(Types))]<commit_msg>Extend Types with Skip().<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Infra.IoC
{
    [ContractClass(typeof(TypesContract))]
    public abstract class Types : IEnumerable<Type>
    {
        public static Types Referenced { get; } = new AssemblyTypes(Assemblies.Referenced);
        public static Types Local { get; } = new AssemblyTypes(Assemblies.Local);
        public static Types In(string directory) => In(Assemblies.In(directory));
        public static Types In(Assemblies assemblies) => new AssemblyTypes(assemblies);

        public abstract IEnumerator<Type> GetEnumerator();

        IEnumerator IEnumerable.GetEnumerator()
        {
            Contract.Ensures(Contract.Result<IEnumerator>() != null);
            return GetEnumerator();
        }

        public Types With<TAttribute>() where TAttribute : Attribute
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this, 
                t => t.IsDefined(typeof(TAttribute), false));
        }

        public Types KindOf(string kind)
        {
            Contract.Requires<ArgumentException>(!String.IsNullOrWhiteSpace(kind));
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.Namespace?.EndsWith("." + kind) == true);
        }

        public Types Only<T>()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => typeof(T).IsAssignableFrom(t));
        }

        public Types Skip<T>()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return this.Skip(typeof(T));
        }

        public Types Skip(Type type)
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => !type.IsAssignableFrom(t));
        }

        public Types Interfaces()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.IsInterface);
        }

        public Types Classes()
        {
            Contract.Ensures(Contract.Result<Types>() != null);
            return new SelectedTypes(
                this,
                t => t.IsClass && !t.IsAbstract);
        }
  
        public static Types operator +(Types x, Types y)
        {
            Contract.Requires<ArgumentNullException>(x != null);
            Contract.Requires<ArgumentNullException>(y != null);
            Contract.Ensures(Contract.Result<Types>() != null);
            return new CombinedTypes(x, y);
        }
    }

    [ContractClassFor(typeof(Types))]
{'fraction_non_alphanumeric': 0.11129266521423384, 'fraction_numerical': 0.0, 'mean_word_length': 2.0153256704980844, 'pattern_counts': {'":': 0, '<': 34, '<?xml version=': 0, '>': 49, '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': '4366241', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1403, 'n_words': 305}