从 VB.Net 程序集中删除变量名称
我正在尝试尽可能地减少 VB.Net 程序集方面的数量,并且我刚刚发现所有变量名称在实际程序集中都保持不变。由于我倾向于使用相当长的 var 名称,因此它会累加起来,并且通过在程序集上运行 dotfuscator,我可以将其缩小多达 10%。
因此我想知道:有没有办法告诉 Visual Studio 在生成的程序集中使用较短的 var 名称?使用 dotfuscator 是否有任何缺点(尽管我认为避免使用它,因为它需要在每次编译后调用,因此迫使我更新我的构建脚本......)?
多谢, 金融理财师。
I'm trying to reduce as much as I can my VB.Net assembly side, and I just figured out that all variable names were kept unchanged in the actual assembly. Since I tend to use pretty long var names, it adds up and, by running dotfuscator on my assembly, I could shrink it by as much as 10%.
Thus I wonder: is there any way to tell Visual Studio to use shorter var names in the generated assembly? Are there any downsides to using dotfuscator (I'd rated avoid it though, since it'd need to be called after every compilation, therefore forcing me to update my build scripts...)?
Thanks a lot,
CFP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不。在没有任何指导的情况下更改姓名实际上是不安全的。重命名可能会破坏代码,尤其是在使用反射时。
Visual Studio 始终追求安全。如果您想重新命名变量,您可以向构建脚本添加混淆,以使它们自动重做每个构建。
话虽这么说,一旦 JIT 在运行时编译了程序集,一切就不再重要了。混淆和使用较短名称的唯一优点是程序集稍小,这可能(稍微)缩短加载时间,但对于运行时来说应该不会有太大影响。
No. It's actually not safe to change names without any guidance. Renaming can break code, especially if you're using Reflection.
Visual Studio always goes for safety. If you want to re-name your variables, you could add obfuscation to the build scripts to have them automatically redone each build.
That being said, once the assembly is compiled at runtime by the JIT, it won't matter. The only advantages of obfuscating and using shorter names are a slightly smaller assembly, which may (slightly) improve your load times, but shouldn't matter much for runtime.
您可以购买进行压缩的 .NET Obsfuscator:
http://www.xenocode.com/Obfuscator/
You could buy a .NET Obsfucator that does compression:
http://www.xenocode.com/Obfuscator/