Does anybody know a class, that writes the structure(public (static, instance) members)/data of an object/class to string (for debugging-purposes) or even generate fancy html-divs or something like that?
Well, the obvious answer is to use the debugger build into Visual Studio, it has some wonderful tools (Watches, Quick Watch, Immediate window, etc...) If for some reason you dont have access to the debugger, I suggest you fix whatever it keeping you from it, but otherwise you can write yourself a fairly robust object dumper using Reflection. Or you can take Eric White's advice and use the ObjectDumper.
Check out: http://blogs.msdn.com/ericwhite/archive/2008/08/14/object-dumper-an-invaluable-tool-for-writing-code-in-the-functional-programming-style.aspx
I don't know of any vendor packages off the top of my head, but the XmlSerializer would do that for you pretty easily.
Related
I am using camelCase convention for private member variables in my C# projects. Because of changed code quality requirements now I "have to"/"would like to" rename/refactor all these members to _camelCase.
For example logger will be _logger.
Additional info:
1) I definitely know that a particular rename/refactor could cause error, and an interactive refactor tool will warm me in that case. Still I want to automate mass rename, I'll take the risk ending with not compilable source what needs manual corrections.
2) I use latest ReSharper if this helps, but still I can not figure solution for my task. (To be clear I do not suggest ReSharper should be the solution, just a possibility.
Thanks in advance
There is a guy called Steve Cadwallader who has made a visual studio extension called "CodeMaid" (http://www.codemaid.net/). It has several things you can use for cleaning up code etc and the source code is free i think. If you have strict code quality requirements like this maybe its worth it to download his extension and do a slight modification to it. I know it already do stuff with private member variables so it shouldnt be too hard to modify.
This extension can do stuff on a file or project basis which makes it easy for you if you have a large number of files to modify.
One easy way of doing this is to just you Ctrl + F & Find and replace. This however doesn't give you the security that you have only updated the relevant variables and could end up changing other thing. But you can always undo the changes easily if they cause problems.
UPDATE
Having read other answers I have tried Ctrl + R + R and this is now the way I will be doing things. I would up vote that answer but can't as I don't have enough reputation yet!
The only way I found is via the Resharper's "Show Potential Fixes" Menu option as outlined by Jowen here.
How to reformat naming styles with ReSharper?
I use VS 2010 and C#. When I want to found all references to the methods or properties I press Shift+F12. It's possible to find only get or set references for examined property.
It's possible? Maybe I should install any extension?
The poor man's way is to simply remove/comment-out either the getter or setter and recompile: all the errors will be your references. ;)
EDIT: Instead of deleting it (which could be invalid syntax), change the visibility of the particular get/set to private.
I would suggest you to evalutate the ReSharper product which has extremely powerful features that enhance Visual Studio a lot.
Find Usages is what you are looking for.
If you find the ReSharper to be ok (and you will!) then go ahead and buy a license after evaluation.
Just make sure to try it out at least!
I have inherited an API which doesn't have proper comments, and I am working on changing that.
Anyone know if there is some sort of mechanism to add a default XML comments to all the members of a class or an assembly?
(I remember seeing something like that on a webcast and I think he might have used PowerShell script to achieve that.)
This way I can avoid lots of repetitive steps, and have everything in place to go and start writing just the comments.
Anyone has any better suggestions?
GhostDoc is pretty fantastic for XML documentation, although you'll need to purchase a copy to generate automatic documentation for all classes/members. The free version allows you to right click (or use a hotkey) on class or member and it will generate the documentation.
I've found GhostDoc to be pretty good.
Once you've run it over your code you then simply add details where required.
http://submain.com/products/ghostdoc.aspx
During my trial of ReSharper 5, I noticed its version of IntelliSense falls behind Visual Studio 2010's in three ways that were key to me:
ReSharper doesn't support IntelliSense in the "QuickWatch..." debugger utility.
ReSharper's IntelliSense seems to break down for me in .aspx files between the <%= %> tags.
I couldn't find a way to get a listing of properties within an object initializer block. (VS does this if you hit the space key.)
Thankfully ReSharper lets you use Visual Studio IntelliSense alongside its other great features. Am I missing out on anything great by not using ReSharper's IntelliSense?
Well you're losing quite a bit. Here are some quick facts about ReSharper code completion: http://www.jetbrains.com/resharper/webhelp/Coding_Assistance__Code_Completion.html
Smart Completion (Ctrl+Shift+Space in IntelliJ IDEA keymap) is especially useful because in common scenarios it gives you a narrow selection of symbols that you most likely want to complete, and in some cases acts as a shortcut to code generation features
By the way, Smart Completion is the kind of completion that you should use with object initializers: www.jetbrains.com/resharper/webhelp/Coding_Assistance__Code_Completion__Smart.html#object_initializers
As for completion within the <%= %> pair, this should work fine. Please let us know what exactly went wrong by submitting an issue to youtrack.jetbrains.net/issues/RSRP Thanks!
P.S. I work at JetBrains
A five minute comparison I'd say that ReSharper's gives you a bit of help in the typing.
So if you have a method that's A(int a, int b) and you hit ctrl+space when you select A it will add (), will place you in the middle of the brackets and will show you the information about the method. Other than that you're probably not missing much.
For me that is quite helpful, but if you're having trouble doing ASP.NET and those are known bugs / limitations its always best to pick the best tool for the job.
Personally I turn it off. It is annoying and slows me down. Here is a prime example:
No you're not missing much apart from a test runner that supports NUnit. I've had the same problem and also (rather worryingly), hideous performance. I tend to use the productivity power tools extension and the native refactor stuff instead. Info here:
http://visualstudiogallery.msdn.microsoft.com/en-us/d0d33361-18e2-46c0-8ff2-4adea1e34fef
R# also does stuff which I plainly do not want to do and my code ends up littered with commented resharper hints.
I find the CompleteCodeSmart functionality something I use frequently and save me alot of typing.
I know you can perform a 'Find All References' on a function and you can determine if it is being used anywhere, but is there a tool that will go through all of my functions and highlight any that are not called anywhere in the code?
I believe ReSharper can do what you want. More specifically, the Safe Delete command should at least faciliate the job. Although I haven't tried it, the Code Cleanup tool may well do the whole thing automatically.
I prefer ReSharper for this, but if you're looking for a free product, Microsoft FxCop will identity unused public methods.