<commit_before>﻿using System;
using System.Text;
using System.Reflection;
using System.Collections.Generic;

namespace SickDev.CommandSystem {
    internal static class SignatureBuilder {
        private static readonly Dictionary<Type, string> aliases = new Dictionary<Type, string>{
            { typeof(byte), "byte" },
            { typeof(sbyte), "sbyte" },
            { typeof(short), "short" },
            { typeof(ushort), "ushort" },
            { typeof(int), "int" },
            { typeof(uint), "uint" },
            { typeof(long), "long" },
            { typeof(ulong), "ulong" },
            { typeof(float), "float" },
            { typeof(double), "double" },
            { typeof(decimal), "decimal" },
            { typeof(object), "object" },
            { typeof(bool), "bool" },
            { typeof(char), "char" },
            { typeof(string), "string" },
            { typeof(void), "void" },
            { typeof(byte?), "byte?" },
            { typeof(sbyte?), "sbyte?" },
            { typeof(short?), "short?" },
            { typeof(ushort?), "ushort?" },
            { typeof(int?), "int?" },
            { typeof(uint?), "uint?" },
            { typeof(long?), "long?" },
            { typeof(ulong?), "ulong?" },
            { typeof(float?), "float?" },
            { typeof(double?), "double?" },
            { typeof(decimal?), "decimal?" },
            { typeof(bool?), "bool?" },
            { typeof(char?), "char?" },
        };

        public static string Build(MethodInfo method, string nameOverride = null) {
            StringBuilder signature = new StringBuilder();
            signature.Append(TypeToString(method.ReturnType));
            signature.Append(" ");
            signature.Append(nameOverride??method.Name);
            ParameterInfo[] parameters = method.GetParameters();
            if (parameters.Length > 0)
                AddParameters(signature, parameters);
            return signature.ToString();
        }

        static void AddParameters(StringBuilder signature, ParameterInfo[] parameters) {
            signature = signature.Append('(');
            for (int i = 0; i < parameters.Length; i++) {
                AddParameter(signature, parameters[i]);
                if (i != parameters.Length - 1)
                    signature = signature.Append(", ");
            }
            signature = signature.Append(')');
        }

        static void AddParameter(StringBuilder signature, ParameterInfo parameter) {
            signature = signature.Append(TypeToString(parameter.ParameterType));
            signature = signature.Append(" ");
            signature = signature.Append(parameter.Name);
            if (parameter.IsOptional) {<commit_msg>Removed void return from signature builder<commit_after>﻿using System;
using System.Text;
using System.Reflection;
using System.Collections.Generic;

namespace SickDev.CommandSystem {
    internal static class SignatureBuilder {
        private static readonly Dictionary<Type, string> aliases = new Dictionary<Type, string>{
            { typeof(byte), "byte" },
            { typeof(sbyte), "sbyte" },
            { typeof(short), "short" },
            { typeof(ushort), "ushort" },
            { typeof(int), "int" },
            { typeof(uint), "uint" },
            { typeof(long), "long" },
            { typeof(ulong), "ulong" },
            { typeof(float), "float" },
            { typeof(double), "double" },
            { typeof(decimal), "decimal" },
            { typeof(object), "object" },
            { typeof(bool), "bool" },
            { typeof(char), "char" },
            { typeof(string), "string" },
            { typeof(void), "void" },
            { typeof(byte?), "byte?" },
            { typeof(sbyte?), "sbyte?" },
            { typeof(short?), "short?" },
            { typeof(ushort?), "ushort?" },
            { typeof(int?), "int?" },
            { typeof(uint?), "uint?" },
            { typeof(long?), "long?" },
            { typeof(ulong?), "ulong?" },
            { typeof(float?), "float?" },
            { typeof(double?), "double?" },
            { typeof(decimal?), "decimal?" },
            { typeof(bool?), "bool?" },
            { typeof(char?), "char?" },
        };

        public static string Build(MethodInfo method, string nameOverride = null) {
            StringBuilder signature = new StringBuilder();
            string returnType = TypeToString(method.ReturnType);
            if(returnType != aliases[typeof(void)]) {
                signature.Append(returnType);
                signature.Append(" ");
            }
            signature.Append(nameOverride??method.Name);
            ParameterInfo[] parameters = method.GetParameters();
            if (parameters.Length > 0)
                AddParameters(signature, parameters);
            return signature.ToString();
        }

        static void AddParameters(StringBuilder signature, ParameterInfo[] parameters) {
            signature = signature.Append('(');
            for (int i = 0; i < parameters.Length; i++) {
                AddParameter(signature, parameters[i]);
                if (i != parameters.Length - 1)
                    signature = signature.Append(", ");
            }
            signature = signature.Append(')');
        }

        static void AddParameter(StringBuilder signature, ParameterInfo parameter) {
            signature = signature.Append(TypeToString(parameter.ParameterType));
            signature = signature.Append(" ");
            signature = signature.Append(parameter.Name);
            if (parameter.IsOptional) {
{'fraction_non_alphanumeric': 0.15016943106830746, 'fraction_numerical': 0.001070090957731407, 'mean_word_length': 1.9656266525647805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4771818', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1396, 'n_words': 300}