<commit_before>﻿using System;
using System.Reflection.Emit;

namespace ILGeneratorExtensions
{
    public static class TypeManipulation
    {
        public static void IsInstanceOfType<T>(this ILGenerator generator) => generator.IsInstanceOfType(typeof(T));

        public static void IsInstanceOfType(this ILGenerator generator, Type type) => generator.Emit(OpCodes.Isinst, type);

        public static void CastClass(this ILGenerator generator, Type type)
        {
            if (type.IsValueType)
            {
                throw new InvalidOperationException("Cannot cast to a value type");
            }

            generator.Emit(OpCodes.Castclass, type);
        }

        public static void CastClass<T>(this ILGenerator generator) where T : class => generator.CastClass(typeof (T));

        public static void Box(this ILGenerator generator, Type type)
        {
            if (!type.IsValueType)
            {
                throw new InvalidOperationException("Can only box value types");
            }

            generator.Emit(OpCodes.Box, type);
        }

        public static void Box<T>(this ILGenerator generator) where T : struct => generator.Box(typeof (T));

        public static void Unbox(this ILGenerator generator, Type type)
        {
            if (!type.IsValueType)
            {
                throw new InvalidOperationException("Cannot unbox non-value types");
            }

            generator.Emit(OpCodes.Unbox, type);
        }

        public static void Unbox<T>(this ILGenerator generator) where T : struct => generator.Unbox(typeof (T));

        public static void UnboxAny(this ILGenerator generator, Type type) => generator.Emit(OpCodes.Unbox_Any, type);

        public static void UnboxAny<T>(this ILGenerator generator) => generator.UnboxAny(typeof (T));
    }
}
<commit_msg>sizeof<commit_after>﻿using System;
using System.Reflection.Emit;

namespace ILGeneratorExtensions
{
    public static class TypeManipulation
    {
        public static void IsInstanceOfType<T>(this ILGenerator generator) => generator.IsInstanceOfType(typeof(T));

        public static void IsInstanceOfType(this ILGenerator generator, Type type) => generator.Emit(OpCodes.Isinst, type);

        public static void CastClass(this ILGenerator generator, Type type)
        {
            if (type.IsValueType)
            {
                throw new InvalidOperationException("Cannot cast to a value type");
            }

            generator.Emit(OpCodes.Castclass, type);
        }

        public static void CastClass<T>(this ILGenerator generator) where T : class => generator.CastClass(typeof (T));

        public static void Box(this ILGenerator generator, Type type)
        {
            if (!type.IsValueType)
            {
                throw new InvalidOperationException("Can only box value types");
            }

            generator.Emit(OpCodes.Box, type);
        }

        public static void Box<T>(this ILGenerator generator) where T : struct => generator.Box(typeof (T));

        public static void Unbox(this ILGenerator generator, Type type)
        {
            if (!type.IsValueType)
            {
                throw new InvalidOperationException("Cannot unbox non-value types");
            }

            generator.Emit(OpCodes.Unbox, type);
        }

        public static void Unbox<T>(this ILGenerator generator) where T : struct => generator.Unbox(typeof (T));

        public static void UnboxAny(this ILGenerator generator, Type type) => generator.Emit(OpCodes.Unbox_Any, type);

        public static void UnboxAny<T>(this ILGenerator generator) => generator.UnboxAny(typeof (T));

        public static void SizeOf(this ILGenerator generator, Type type) => generator.Emit(OpCodes.Sizeof, type);

        public static void SizeOf<T>(this ILGenerator generator) => generator.SizeOf(typeof(T));
    }
}

{'fraction_non_alphanumeric': 0.08967112024665981, 'fraction_numerical': 0.0, 'mean_word_length': 2.555251141552511, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 30, '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': '2313762', 'n_tokens_mistral': 985, 'n_tokens_neox': 976, 'n_words': 287}