CodeRush code cleanup formatting - coderush

I have a few classes that are a complete mess.
I would like for CodeRush to organize the code so that public, private, etc. methods become grouped. I would also like for CodeRush to organize my public methods into a region, and put fields and properties into regions.
How can I do this?

Have a look at the CR_ClassCleaner plugin -
http://code.google.com/p/dxcorecommunityplugins/wiki/CR_ClassCleaner

In addition to the CR_ClassCleaner plug-in, there's a lighter and simplified version of such functionality in the CR_MemberOrganizer plug-in shipped in CodeRush as an open source feature.

Related

How to get type info from Go compiled packages in language x?

I want to write a simple editor with basic autocomplete functionality for the Go language as a pet project. How would one go about doing it? I took a look at the Go plugins for Eclipse and IntelliJ, but they were too big for me to comprehend (not to mention getting one to compile).
The Go standard library offers the building blocks for a Go parser which
you can use to parse the source files and look for function definitions and the like.
There's also the godoc command which
already does what you want: extracting method definitions and it's documentation. You may look in the
source code to see how godoc is
working or use godoc directly.
This editor written in Go projects has a manageable amount of code,
you may look into it.
The de facto standard approach to this problem is to use nsf's gocode. I have tried it only in Vim - it works very well.
Even though there's ready made support for specific editors, gocode is not editor specific. It's a daemon with a communication protocol. It is thus usable from any program.

How To Version My Custom Classes

I have written some custom classes for coredata for use in projects. These will be updated over time.
Besides using git, what is the best way to manage versioning for my custom classes in my iOS projects?
There's really nice new feature In Xcode4.x for version control, you can take help of that in order to achieve that.
For details on it: Check this link:
http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/Xcode_User_Guide/000-About_Xcode/about.html

Supply method bodies in Tools API

Years ago, I wrote a code template that took a few simple parameters (points) and produced a class skeleton. Since some of the method bodies had code in them, I couldn't call InvokeClassCompletion and just placed the implementations with the declarations (user had to move them).
It has occurred to me that I can write a code template script engine to insert these methods in the correct position, but I don't see how I'm supposed to navigate the file. There are declarations for IOTAEditReader and IOTAEditWriter in ToolsAPI.pas, but I'm guessing there is a step missing - certainly I don't need to manually parse the Delphi code just to find the implementation section?
Does anyone have experience with it?
The IDE has plenty of parsers in it, but not one is made available for IDE plugins (ToolsAPI). So you have to write your own parser or use an existing one like http://delphiblog.twodesk.com/using-the-castalia-delphi-parser
You might find that GExperts or CNPack contains almost all the code you need, in one of its editor wizards.
If not, then, those two are the best reference I know for writing IDE plugins. As far as writing parsers, see Andreas' answer.
If you just want better code templates, you could consider buying Castalia, as it has an improved code template feature over the builtin delphi IDE plugin features. Castalia internally uses the Castalia delphi parser mentioned by andreas. It's quite good.

How do I "White Label" my ASP.Net MVC Application?

I have a "white labelled" application that is installed onto multiple customers' servers. On any given installation the differences will include content, style sheets and graphics but also some actual code / business logic. I want my TFS Server to build all flavours of my application automatically. What are my options for doing this? e.g. should I be using Themes? What about #if conditional compilation flags.
P.S. The question is not about how to setup the Build Server - I've done that already.
For the business logic I would abstract the differences into a separate libraries, and then you can use an IoC / DI pattern or provider pattern to resolve the correct business logic at runtime.
As for the content I would look into themes. Essentially you could have your build server build all the code once, then when you package the code you choose which assemblies you need and use the appropriate configuration, and choose the appropiate theme folder for the client at hand.
I don't like using # directives in this case. If you think about it your unit tests would have to run for each conditional you have. If you remove the conditionals and abstract the differences your unit tests can just run on all the pluggable assemblies at once.
Content/image - you can make your own HtmlHelper/UrlHelper extension to do Html\Url.Content() to pickup right things for right customers, in addition to copying needed files from right folders (which is simple, /Content + /ContentCustomer1, 2, ...).
There's no single answer, I suppose. One easy answer would be to move your Order.Calculate() method to a partial class, so that you have
OrderPartsForCustomer1.cs
OrderPartsForCustomer2.cs
where you'll have
public partial class Order
{
public Money Calculate()
{
}
}
You'll just include needed .cs classes then, and don't clutter your code with #ifs.
If you want common code for all, and overrides just for specific customers, you can have OrderPartsCommon.cs, which you will copy/use if there's not customer-specific overide.

Code reuse tools

I usually maintain code snippets that I can resuse in a Wikidpad personal wiki with a small index page that can take me to any code that I want.
I want to share these snippets with my team and am looking for easy ways to do it.
Are there any tools that would help me setup such a repository? Or should I simply install a wiki and port my personal wiki there?
Thanks
Hari
Google Docs, perhaps? Search-ability is the key. No one has time to cross-index, keyword-stuff, and organize "snippets" into complex ontologies.
Also, remember that when someone reuses code, they also reuse the bugs, limitations, and performance issues you may have worked out in subsequent revisions. The best way to reuse code is not to copy it, but to document it and make it accessible for direct reuse.
Some IDEs have a code-snippet utility built into them. e.g. Visual Studio has Code Snippet Manager.
Or perhaps an addin like Resharper. My point being find something that integrates nicely with the IDE that your team uses.
Why not use code snipplr
An easy and reusable solution: a repository with web interface like subversion. Also Github can be a good option since you don't need installation

Resources