我意识到这是一个相当奇怪的请求,但我想知道是否有人知道一些适用于 C# 源代码(而不是编译后的程序集)的缩小/混淆工具。我正在尝试减少已编写的应用程序的字符数以满足字符限制,但我似乎找不到任何工具可以帮助我完成此任务。
我感兴趣的主要功能:
它不必是一个完整的混淆器,只需快速方便地减少代码块的字符数即可。
这并不是为了任何实际或现实世界的应用,而是为了竞赛。
I realize this is a rather odd request, but I was wondering if anyone was aware of some minification/obfuscation tools that work on C# source code (not a compiled assembly). I am trying to reduce the character count of an already written application to meet a character limit and I can't seem to find any tools that will help me achieve this task.
Main features I am interested in:
- Strip Whitespace
- Shorten Variable Names
It doesn't have to be a full on obfuscator, just something that will reduce the character count of a block of code quickly and conveniently.
This is not intended to have any practical or real world application, it's for a competition.
发布评论
评论(4)
我基于 CSharpMinifier /icsharpcode/NRefactory" rel="noreferrer">NRefactory。现在它可以删除注释、空格和换行符。接下来我计划添加标识符缩小。
I developed small lib for C# code minification CSharpMinifier based on NRefactory. Now it can remove comments, whitespaces and line breaks. Next I'am planning to add identifier minification.
我不知道有任何这样的工具,但使用 Visual Studio 中内置的重构工具进行一些变量重命名并不太难。
对于空格,使用正则表达式查找替换,将任何多个空格(VS 替换中的 :Wh+)替换为单个空格。
I am not aware of any such tool, but it would not be too hard to do some variable renaming using the built in refactor tools in Visual Studio.
For the whitespace, a regex find-replace, to replace any multiple spaces (:Wh+ in VS replace) with a single space.
@Ivan 的 CSharpMinifier 不适合我。所以我改用这个。如果您想尝试的话,有一个演示网络应用。
@Ivan's CSharpMinifier didn't work for me. So I am using this one instead. There is a demo web app if you want to try.
这是一个很好的在线版本来美化/缩小代码美化。
This is a good online version to beautify/minify Code Beautify.