Autocomplete blocks in C# - c#

Iam used to Eclipse and Java development, but because of my job I need to start coding in C#. I find it a bit annoying that visual studio doesn't autocomplete my blocks. For instance when I write a new function, class or statement am used to that the IDE autocompletes my blocks. So when I type:
private function sendData(String msg, String email) {
and hit enter the closing bracket appears automatically, is there any settings that enables this function in Microsoft visual C# 2010 express ?

This isn't possible with Express versions, since you can't install extensions. You'll need to use Professional or higher and use third party extensions. Some simple free ones will do this (such as Productivity Power Tools), as does the commercial product ReSharper, which does much more more. The later likely would make Visual Studio have other features that you're probably used to comming form Eclipse, such as more refactoring support.

I'm almost certain that the Productivity Power Tools extension will give you this feature. You can find it here:
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
It's really a great add-on and it will give you a lot more control over options like this.

There is no functionality like this already built-in in Visual Studio, but you can install a plugin like Brace Completer to add the functionality .

No, you can't do it by default in Visual Studio. Visit Microsoft Connect to submit a feature request.

Related

Version Control in Visual Studio

I'm currently working on a large project, and am about to make some large changes, and was looking for a way to 'backup' my prior work. Is there built in functionality in Visual Studio to work with version control?
This project is developed only by me, and doesn't use Team Foundation Server (which is what most of my googling seems to give me answers on). Ideally, I would like to identify and restore all the different versions of my program as it evolves, without having to worry about totally messing something up...
Cheers and thanks in advance!
---EDIT---
With a version control system though, would that be stored on a seperate server? Or is it possible to store it locally? I'm more just concerned that I will just seriously mess up my code and not be able to undo it at some point...
There are several third-party source control integration tools, such as AnkhSVN or VisualSVN for SVN repositories (I use the former and can gladly recommend it). As far as "built-in", Visual Studio supports Team Foundation Server and Visual Source Safe out of the box, but those are both paid products and VSS should be avoided (in my opinion) for any new work.
Personally, I use TortiseSVN (for Windows integration) and AnkhSVN (for VS integration) with our SVN repository. There are free SVN servers as well, so you can get by with a very good solution while paying $0.
Well, there are a number of free source control alternatives out there and there are plug-ins (free ones) into Visual Studio that will allow you to hook right in. Take a look at those links and pick one that works for you!
Visual Studio has the ability to work with many source control providers. You simply have to hook them up.
Use "Tools->Options->Source Control->Plug-in Selection".
You may be able to use git with VS which means you don't need another dir/server etc for the repo. Consider Using Git with Visual Studio
TFS is really expensive, especially for just you. You can use VisualSVN.
it is a free download to us ANkhsvn. It is a plugin for visual studio that connects to various source control severs. You would first have to have a subversion server setup somewhere. Which is easy enough to do.
There is no built-in Version Control System in VS.NET, however, VS.NET supports multiple version control systems, like TFS, Visual Sourcesafe, SourceGear vault , etc...
As you state, you need a version control system. Look at this answer on selecting a Version Control System.
There are many version management systems. A lot of them are expensives, but... the are many others that are free! Take a look here:
http://producingoss.com/en/vc-systems.html
You can use SVN (Subversion) - one of the most used widely.

How to create a new language for use in Visual Studio

I want to write a new templating language, and I want Visual Studio to "support" it. What I need to know is:
How do I parse my new language?
Given some code in my new template language, how do I translate it into HTML? Right now I'm using regular expressions to parse it token by token, but I don't think this is going to scale very well as the language gets more complicated, and there's no error checking. I've heard of ANTLR but never used it. Would that be the right tool for this job, or is there perhaps something simpler? Ideally I'd like to send any syntax errors to the error window with as much information as possible (line #, type of error) like other languages do.
How do I create a new file type for Visual Studio?
How do I get syntax highlighting?
Can I use the same parser I created in step 1, or is this something entirely different?
How do I get Intellisense?
I'd prefer to write my parser in C#.
I would take a look at another language that has already done the legwork of integrating with Visual Studio. A great example is Boo. The language and Visual Studio integration are open source. So you can take a look at exactly what they had to do.
Boo Language: https://github.com/boo/boo-lang
Boo Syntax Highlighting for VS2010 (VSX add-in): http://vs2010boo.codeplex.com/
Boo Language Studio (syntax highlighting for VS2008): http://boolangstudio.codeplex.com/
The Boo Syntax Highlighting for VS2010 includes some recommended links on its homepage, which I'll copy for easy reference:
Nice article about "classification" (syntax highligting) in VS 2010: http://dotneteers.net/blogs/divedeeper/archive/2008/11/04/LearnVSXNowPart38.aspx
Examples for VSX add-ins: http://blogs.msdn.com/vsxteam/archive/2009/06/17/new-editor-samples-for-visual-studio-2010-beta-1.aspx
Regarding the Visual Studio aspects, what you need is a "language service", which is the entity that handles colorizing, intellisense, etc. for a given file extension/type.
For an intro, see this article
And for a code sample see here
Regarding parsing, there are lots of technologies, and I won't offer an opinion/advice.
Beware, there is a fair amount of work involved, although in my opinion it is much more straightforward in VS2010 than in previous versions of Visual Studio to provide this kind of extension.
See also
Visual Studio 2010 Extensibility, MPF and language services
I wrote a VS Language Service using this article as my basis:
http://www.codeproject.com/KB/recipes/VSLanguageService.aspx
It wasn't too bad if you have a basic handle on Grammars.
There is a sample in the VS SDK that shows most of the features you are looking for.
I was using VS with own language and desperately needed a syntax highlight. I built mine based on this tutorial: https://mattduffield.wordpress.com/2012/07/31/writing-a-brightscript-syntax-highlight-extension-for-visual-studio-2010/
I know the tutorial is in VS2010. I made mine in VS2012 with no or very small hiccups. (also worked in VS2013) Recently I changed to VS2015 and the solution can be edited, built with no problem.
I found this very useful collection of recent samples for Visual Studio 2013 SDK:
http://blogs.msdn.com/b/vsx/archive/2014/05/30/vs-2013-sdk-samples-released.aspx
It also contains the recent version of the OokLanguage which sounds promising.
We used ANTLR 4 to parse our language which works like a charm and allows direct interaction with C# code. Can totally recommend it.
As mentioned in other answers, the most interesting code sample is the Ook language extension for the latest version of Visual Studio (2017 at the time of writing).
For VS 2015 see the sample in the VS2015 branch.
In order to install the SDK for 2015 or later, you need to rerun the VS setup. In 2015 it's called "Visual Studio Extensibility Tools Update 3".

Visual Studio and C# and Web Developer Productivity Tools /Helps

I'm looking into Productivity tools for developing in C# / Visual Studio 2008 (pr0) and developing web apps (not using MVC).
Anything from favourite visual studio shortcuts to external tools and plug-ins.
Ctrl+. is one of my favorites. It adds a Using statement for the current class if you don't already have it.
For example if you have this:
Regex
And you hit Ctrl+.. Visual Studio will add
using System.Text.RegularExpressions;
to the top of your file.
I also like Code Rush and Refactor Pro from DevExpress.
A very interesting one that was just announced is Telerik's JustCode. It's basically a new refactoring tool (such as Resharper and CodeRush, also very good productivity improvement tools), but also handles Javascript in web projects.
Tools like these can dramatically improve the amount you can get done in a short amount of time.
ANTS Profiler from Red Gate helped our company find a lot of bottlenecks in our C# code.
Reflector from Red Gate PowerCommands visual studio add-in any form of Grep
We've just started using GhostDoc which is pretty useful for quickly generating outlines of comments especially when you're generating your documentation from your XML comments. It's definitely saved me some time.
its not a tool but a big reference chart - you can print it out and hang it on at your work area, to refer quick key bindings http://www.microsoft.com/en-us/download/details.aspx?id=7162

Visual studio (2008) integration - intellisense and colourizer

So I'm now about to look at getting visual studio integration working for our port of the Less ruby library: www.dotlesscss.com. This is basically a CSS preprocessor that extends on the CSS language to give you variables, mixins, nested rules etc...
What we want is to have our .Less file type take advantage of VS's intelligence and syntax highlighting. Now as the Less language is pretty much CSS with a few extra niceties, it would seem sensible to extend on the existing VS support for CSS files.
We have started to look at VS SDK and managed to get as far as colouring all text blue (its a start). But before we start looking at the Lexer impl I really want to know if we can somehow extend whats already been done with CSS support.
Any pointers in the right direction would be appreciated.
Chris.
Regardless of whether you choose 2005, 2008, or 2010, you'll face the same choice - you can pick one or the other but in no way can pick both.
Set .less files to open in Visual Studio's CSS editor - as is.
Write a new language service for Visual Studio from the ground up, with a syntax highlighter and IntelliSense, for your language.
If you choose #2, then you'll be writing what's called a language service for Visual Studio, and there are lots of resources here and on the web (my blog has some). Be warned it's a non-trivial task once you get past simple syntax highlighting.
This is straightforward in Visual Studio 2010, which is now in beta 2. The text editor is completely new and is designed to support this scenario. If you dig into the SDK you'll find a number of related examples.
For VS 2008 and earlier, you can't extend an existing editor. You have to provide a completely new editor that happens to duplicate all the functionality of the existing editor.

Extending the Visual Studio editor

I'm writing an add-in for extending Visual Studio 2008 (adding custom functionality). While doing that I came across a situation where it would be good if I could provide custom messages via tooltips for any line of code.
Doing this IMO requires accessing the VS editor control and by some way displaying the respective tooltip. This might also be visualized like breakpoints that on mouse hovering provide a tooltip message.
Is this implementation possible? If yes, what's the way to go? If not, what similar way do you suggest?
In a recent episode of Hanselminutes, they discussed how much more extensible the VS 2010 editor is going to be. Based on what they said, I think it will be rather difficult (although probably possible) until they introduce that extensibility.
Yes it is. You can add more customization on the code editor of VS 2008, even you can create your own language service with your own intellisense support in VS 2008.
You can do this simply by using VS 2008 SDK, and you can also quickly play with the standalone shell of Visual Studio 2008, and MS SQL Server 2008 Management Studio is one example of customized Visual Studio standalone shell.
You can visit MS Visual Studio Extensibility:
http://msdn.microsoft.com/en-us/vsx/default.aspx
And lots of videos on VS 2008 SDK:
http://msdn.microsoft.com/en-us/vsx/bb507746.aspx#extensibility
You should take a look at Resharper and work out whether your add-in would be better suited to being a Resharper Plug-In. This approach would require your users to buy Resharper, but this sort of thing is exactly what it does.
For example, check out http://stylecopforresharper.codeplex.com/ where this sort of hint/tooltip stuff in Resharper is used to highlight lines of code that have StyleCop issues.

Categories