<commit_before>﻿using Mono.Cecil;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;

namespace NetInject
{
    static class CecilHelper
    {
        public static IEnumerable<TypeDefinition> GetAllTypes(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllTypes());

        public static IEnumerable<TypeDefinition> GetAllTypes(this ModuleDefinition mod)
            => mod.Types.SelectMany(t => t.GetAllTypes());

        public static IEnumerable<TypeDefinition> GetAllTypes(this TypeDefinition type)
            => (new[] { type }).Concat(type.NestedTypes.SelectMany(t => t.GetAllTypes()));

        public static CharSet? ToCharset(this PInvokeInfo pinv)
           => pinv.IsCharSetAnsi ? CharSet.Ansi : pinv.IsCharSetAuto ? CharSet.Auto :
            pinv.IsCharSetUnicode ? CharSet.Unicode : default(CharSet?);

        public static AssemblyNameReference ToRef(this Assembly ass)
            => new AssemblyNameReference(ass.GetName().Name, ass.GetName().Version);

        public static IEnumerable<string> GetAllNatives(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllNatives());

        public static IEnumerable<string> GetAllNatives(this ModuleDefinition mod)
            => mod.ModuleReferences.Select(m => m.Name);

        public static IEnumerable<IMetadataScope> GetAllExternalRefs(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllExternalRefs());

        public static IEnumerable<IMetadataScope> GetAllExternalRefs(this ModuleDefinition mod)
            => mod.AssemblyReferences.OfType<IMetadataScope>().Concat(mod.ModuleReferences);

        public static void Remove(this AssemblyDefinition ass, ModuleReference native)
        {
            foreach (var mod in ass.Modules)
                mod.ModuleReferences.Remove(native);
        }
    }
}<commit_msg>Added go back<commit_after>﻿using Mono.Cecil;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Mono.Cecil.Cil;
using System;

namespace NetInject
{
    static class CecilHelper
    {
        public static IEnumerable<TypeDefinition> GetAllTypes(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllTypes());

        public static IEnumerable<TypeDefinition> GetAllTypes(this ModuleDefinition mod)
            => mod.Types.SelectMany(t => t.GetAllTypes());

        public static IEnumerable<TypeDefinition> GetAllTypes(this TypeDefinition type)
            => (new[] { type }).Concat(type.NestedTypes.SelectMany(t => t.GetAllTypes()));

        public static CharSet? ToCharset(this PInvokeInfo pinv)
           => pinv.IsCharSetAnsi ? CharSet.Ansi : pinv.IsCharSetAuto ? CharSet.Auto :
            pinv.IsCharSetUnicode ? CharSet.Unicode : default(CharSet?);

        public static AssemblyNameReference ToRef(this Assembly ass)
            => new AssemblyNameReference(ass.GetName().Name, ass.GetName().Version);

        public static IEnumerable<string> GetAllNatives(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllNatives());

        public static IEnumerable<string> GetAllNatives(this ModuleDefinition mod)
            => mod.ModuleReferences.Select(m => m.Name);

        public static IEnumerable<IMetadataScope> GetAllExternalRefs(this AssemblyDefinition ass)
            => ass.Modules.SelectMany(m => m.GetAllExternalRefs());

        public static IEnumerable<IMetadataScope> GetAllExternalRefs(this ModuleDefinition mod)
            => mod.AssemblyReferences.OfType<IMetadataScope>().Concat(mod.ModuleReferences);

        public static void Remove(this AssemblyDefinition ass, ModuleReference native)
        {
            foreach (var mod in ass.Modules)
                mod.ModuleReferences.Remove(native);
        }

        public static Instruction GoBack(this Instruction il, int steps)
        {
            var previous = il;
            for (var i = 0; i < steps; i++)
                previous = previous.Previous;
            return previous;
        }
    }
}
{'fraction_non_alphanumeric': 0.096875, 'fraction_numerical': 0.0002403846153846154, 'mean_word_length': 3.156843156843157, 'pattern_counts': {'":': 0, '<': 20, '<?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': '6578015', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1094, 'n_words': 244}