生成C#垃圾代码——自定义单词库


一、环境安装

代码脚本需要用到Lua语言,因此,需要自行百度安装配置好Lua的环境。

二、使用步骤

1.运行Lua代码生成C#垃圾代码

Windows在CMD中运行,Mac在终端运行。

命令如下:
lua garbage_code_generater.lua -o output -c 5

参数说明
-h: 帮助
-o: 输出路径, 默认值=“garbate”
-c: 生成类数量, 默认值=400
-mc: 类方法数量, 默认值=30
-pc: 类变量数量, 默认值=30
-ac: 类属性数量, 默认值=30
-verbose: 输出每一个类文件名
-q: 安静模式, 不输出任何东西

2.Lua文件的代码

代码生成后会在Output文件夹下生成5个脚本,Lua的代码如下所示:

local os = os
local math = math
local io = io

math.randomseed(os.time())

local charlist = 
{
   "Script","Contraller","Select","Game","Manager","Field","Procedure","Print",
"Number","Selected","Want","Window","Message","Dialog","Example","Create","Insert","Related",
"Item","Edit","Marked","Area","Paremeter","Then","Variable","Tab","Up","String","Each","Active",
"Topic","Start","Mode","Selection","Function","Word","Make","Right","Value","Button","Index",
"Without","Appear","Left","Save","Next","Off","Following","Control","Only","User","End","System",
"Contain","Time","Letter","Data","Setting","Desire","Positiion","Down","Task","View","Switch",
"Include","Get","Default","Structure","Into","Path","Blank","Open","Add","Enable"
}

local charlist_length = #charlist

local header_charlist = 
{
   "Student","Player","Wall","Quality","Compile","Period",
"Number","Selected","Want","Window","Message","Dialog","Example","Create","Insert","Related",
"Item","Edit","Marked","Area","Paremeter","Then","Variable","Tab","Up","String","Each","Active",
"Topic","Start","Mode","Selection","Function","Word","Make","Right","Value","Button","Index",
"Without","Appear","Left","Save","Next","Off","Following","Control","Only","User","End","System",
"Contain","Time","Letter","Data","Setting","Desire","Positiion","Down","Task","View","Switch",
"Include","Get","Default","Structure","Into","Path","Blank","Open","Add","Enable"
}

local header_charlist_length = #header_charlist

local function getChar(chars, charscount, i)
    local idx = i ;
    return chars[idx];
end

local function getRandomChar()
    return getChar(charlist, charlist_length, math.random(1, charlist_length))
end

local function getRandomHChar()
    return getChar(header_charlist, header_charlist_length, math.random(1, header_charlist_length))
end

local function getRandomName(l)
    local r = getRandomHChar()
    for _=2,l do
        r = r .. getRandomChar()
    end
    return r
end

local base_type_and_default = {
   
    ["bool"] = "false",
    ["int"] = "0",
    ["float"] = "0.0f",
    ["double"] = "0.0",
    ["string"] = "null"
}

local base_type_randomfunction =
{
   
    ["bool"] = function(a, b, c)
        local r = math.random(1, 5)
        if r == 1 then
            return {
   a .. " = " .. b .. " && " .. c ..";"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值