obfuscation macro - visual-studio-2010

I've been looking into obfuscation software, but wondered if one could do it easily with a macro.
If you go into the class diagram in visual studio 2010, you can easily click on class names, properties, fields, etc, and rename them from something meaningful to a, aa, aaa, abc, whatever.
In a really small project, this would be really easy, but not so in larger projects. Could one just write a macro that looped through the set of classes, field, properties, etc. in the class diagram, and renamed them.
I couldn't immediately figure out how (given I haven't written any macros in studio).
Any direction would be helpful. I'm happy to post the final macro code.
Thanks!
Wayne.

Doing this via a macro does not guarantee correctness - many times, VS fails to rename a class/method- what would happen in that case?
Also, "writing" a macro" sounds simple to the ears, but you are essential writing a complete obfuscator - you must decide what you must rename classes/methods to, avoid conflicts, take care of special cases like virtual methods, exclude some classes/methods, and countless other rules.
You are much better off using an obfuscator. Try Crypto Obfuscator.

Any reason why you'd go with a macro instead of Dotfuscator? It's free in VS2010, and has more features with a commercial license.
If you wanted simply to push a button and have your sourcecode obfuscated on-the-fly, you could write a macro. Dotfuscator commercial does boast "Visual Studio Integration".

Related

Is it possible to rename all variables in Visual Studio 2022

I decompiled the dll that my app creates for publishing it and found out, that everything is easy to read. The app is not rocket science but I'd like to hide some things, e. g. there are constants that are called productionHourlyRate what no one should know.
I know, there are obfuscation softwares but they are expensive.
An easy way would be to rename all variables and methods before publication, e. g. productionHourlyRate -> v1. Is there a built in possibility to do (and undo) this in Visual Studio 2022. Of course, I could rename them one by one but this is not very comfortable.
Or: Is there a free obfuscator that makes dlls undecompilable? No matter which tool I read about, I always find comments like "I decompiled the obfuscated dll with xyz and received the whole source code.".
Many thanks, Philipp
Edit: It is a C#/.Net app (Blazor WebAssembly)
Since there was no answer to this question, there is probably no Visual Studio built in solution.
So, I created an Excel tool that renames alle class, method and variable names in the specified files. Please find it here.
Important:
Make sure, you run this obuscator only when using a version control tool. You CANNOT undo the obfuscation with this Excel tool.
Usage
Add file paths in worksheet "files".
Run macro "Obfuscate" to obfuscate class, method and variable names with "v1", "v2"…
Publish your app.
Undo the changes with your version control tool.
Once all files are manually listed, the obfuscation should only take a few seconds.

Is it possible to auto-format code in Visual Studio's Web Essentials

I would like to have a way to auto-format specific code in Web Essentials to suit our internal design rules. So, for example, when a user types a hex code with lower case letters, it will automatically set all letters in the code to upper case. I've been searching around for a solution to this but I can't seem to find anything or know if it's even possible.
For clarity, I would like to "write" a set of rules (ideally to a file that could be distributed) that people could use to auto-format their code.
In addition to this, is it possible to output a block of code from a smaller, pre-defined string of text. So, for example, instead of writing out:
/*------------------------------------*\
Tables
\*------------------------------------*/
the user could write:
section Tables
and have it output like above.
Thank you in advance.
JetBrains Resharper is my opinion the best tool for Visual Studio that can help with all of this (and much more). Some find it expensive and might slow down Visual Studio somewhat if you're using an older computer.
https://www.jetbrains.com/resharper/

Handling white space and formatting in source control

I work on a team that uses TFS for source control. Recently some team members are complaining that others are checking in files that have been heavily modified in the sense that the IDE (Visual Studio) has done some sort of automatic formatting on them. This is particularly burdensome on users who make heavy use of the comparison functionality. I am admittedly unfamiliar with the nuts and bolts of Visual Studio. One member has suggested that we all use the same editor settings so that this doesn't happen.
Is having all team members adopt the same code editor settings the best way to handle this problem?
Having everybody use the same settings is a good idea in general. If everybody adheres to the same format, settings, and conventions, then this can help reduce the "learning curve" when switching between code that another person wrote.
That being said, if most of the differences are whitespaces then that may indicate a shortcoming of the diff tool. Fortunately, Visual Studio allows you to swap out the built-in diff tool with something of your choosing. You just have to find one that works best for your needs. KDiff3 is a pretty good one.
Here's an example on how to configure KDiff3 with Visual Studio. There's a setting (possibly a command line parameter) in KDiff that you can set and it will ignore whitespace differences.

Manage often used code in Visual Studio

When programming a big project, you often need the same pieces of code in different pages. calling methods, returning references, ...
Now, I always need to open a page, and copy paste parts from that. but I'm getting tired of that. There should be a better way to list very often used code. I've read about snippets but they seem a lot of work. How do you manage that?
Snippets are not a lot of work if you use one of the handy snippet-easing extensions to Visual Studio. I happen to like this one http://visualstudiogallery.msdn.microsoft.com/B08B0375-139E-41D7-AF9B-FAEE50F68392 by Matt Manela. Once it's installed, you can right-click a block of code and make it into a snippet. You can also set up replacements just like when you do an if or for block with the built-in snippets.

Visual Studio ToDo.Who's using?

I'm interesting with statistic and motivation of using task list in VS. Why are you use it or not? Some people i asked even want a tool, that can synchronize VS ToDo with Outlook. What do you think?
IMO you can use Todos for:
Remember that you must do something like "Todo: implement this interface"
To mark a line/block of code as instruction for another coder if your are code in a team like "Todo: you can use foo instead of bar because ..."
If you review your code you can mark any code that he can be improved like "Todo: use Linq instead of foreach"
You can replace the default tasklist-window from visual studio with plugins:
Tasklist replacement for Visual Studio
http://genne-develop.com/
I used TODO for two purposes:
To mark enhancements that can be
done at a later stage. So whenever,
there is slack time, you can pick
one of them out of your pending TODO
list.
Things that are still need to be done while I am coding - so that I can re-visit those places and fix them. This is something like bookmarks except they are visible to other folks even if I forgot to fix them.
I use TODO comment syntax - it's there in code and not in .suo file as mentioned by Benjol.
I use TODO sparingly - only when I have something that I'm not the master of (something another team-member is working on etc.). I treat it as I treat bugs - max 5 at any time.
If I need scaffolding - I create temporary classes with Fake as a prefix in the class-name.
I guess, I don't want my production code to also act as my scrum-board/task-list.
One thing to be wary of about Task Lists in VS is that they are stored in the .suo file, which (I believe) most people tend to exclude from source control.

Resources