Change VB project code to C# using Visual Studio 2010 - c#

Does anyone know how to Change VB project code to C# using Visual Studio 2010?
Any help appreciated

I don't believe Visual Studio itself provides any capabilities around this, but there are various other options. There are specific converters such as the ones from Tangible. Alternatively, you could build the VB code and then decompile to C# in something like Reflector or dotPeek. (Latest versions of Reflector are not free, but there is still a version 6 release which will not have a time bomb.)
Note that a verbatim translation of the code is likely to end up calling various methods in the Microsoft.VisualBasic assembly - you'll want to do a bit more work to turn it into idiomatic C#.

Directly in Visual Studio you can't do this. However, you can use tools such as this one or this one.

Telerik has a free converter here

Related

Automatically add NuGet dependencies and using statements in Visual Studio Code?

I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. In order to use new classes (framework or third-party) in my .cs file, I need to
Manually add a NuGet dependency in project.json and then
Manually add a using statement to my .cs file.
It seems that there should be a better way to import new functionality that doesn't involve searching for the right NuGet and the correct namespace. Any suggestions?
Well, once I got my IntelliSense issues figured out (Visual Studio Code on Mac), I don't have to type using statements anymore. OmniSharp-based IntelliSense is smart enough to suggest (Cmd + . on Mac) adding them for me:
I still have to add a NuGet dependency manually, but I think this is the default behavior in the full Visual Studio too and you need ReSharper to get smarter than that.
Unfortunately, as far as I know of, the short answer is no.
Visual Studio Code is meant to be a light weight editor, so does not have support for the kind of feature you are describing out of the box. The full Visual Studio on Windows does have support for that. When you type the name of a class/type you want to use, eg. JsonConvert, it will detect that the missing type is available on NuGet and offer you the ability to download the correct package and add the using statement. (In the screenshot I already have the NuGet package installed, so it only needs to add the using statement)
This feature is available in the Community edition of Visual Studio, which you can download for free from the visualstudio.com website.
This does require you to run Windows, so I'm not sure if you consider this an option.
Now on the wishful thinking side: VS Code does support extensions these days and it has the power of the Roslyn engine, so theoretically someone could write an extension that will offer this functionality in the future.
You could also try getting it added to the core editor, by opening an issue on GitHub: https://github.com/Microsoft/vscode/issues
I'm afraid neither of these will really help you in the short term though.

How to use roslyn c# compiler with visual studio 2015?

I've a bit of confusion about roslyn.
What I have done:
I've installed vs 2015 community edition and download in extensibilty > download compiler platform sdk.
So I created a simple console application: hello world example.
Well now I'm expect to choise the c# compiler between the vs2015 default one and roslyn..., but I've not found such option.
So my first question is: how to select version of c# compiler?
Second I've downloaded master-roslyn and I build, then I found csc.exe, well the odd things is that if I lauch the exe
I get c# compiler version 42.42.42.42. ???? Right?
Then I've follow some tutorials, but all purpose me:
to load a source from text file or string vars and analyze or change syntax tree, then compile to var.
Well at this point I'm confused... So:
What is roslyn exactly? A meta compiler? This mean that I can change my code at runtime just like Reflection?
Second: how can compile with vs2015 with default csc or choose roslyn?
third: If I build a custom version of roslyn How can I compile my source using Vs2015 ?
Which know if csc.exe is roslyn? No help or command line print the codename.
Thanks
So it looks like you've got a few questions:
What is Roslyn?
Roslyn is the new default compiler inside of Visual Studio 2015. If you're building and running applications within Visual Studio 2015, they're being compiled with the Roslyn compiler. You'll get to take advantage of all the new C# 6 features that are available only within the new compiler.
If you're using VS2015, Roslyn has replaced the old compiler entirely and as far as I know you can't use the old compiler within VS 2015.
Roslyn is also a platform that allows you to build programs that can modify, interpret and understand other programs. It's not really meant to let you write code that modifies itself (although that's probably possible to a degree).
The common use cases for Roslyn are:
Building Code Analyzers that provide errors and warnings within Visual Studio.
Building extensions for Visual Studio that understand source code.
Building other tools that understand or run source code. Example: ScriptCS - Scripting with C# code.
In order to use Roslyn for these purposes, you pull down the Microsoft.CodeAnalysis packages from NuGet. You can use these packages to parse code, analyze syntax trees, analyze symbols or compile code and emit IL.
If you're interested in learning more about Roslyn, I've started a series called Learn Roslyn Now that you might be interested in.
Can I replace the compiler?
Yes you can, but I'm not convinced this is a great idea outside of testing changes you want to contribute back to Roslyn. You can pull down Roslyn from GitHub and follow these instructions to build and run Roslyn from within Visual Studio.
If you follow those instructions, you'll be able to run the Roslyn project with F5. It will start a new instance of Visual Studio that's using your customized compiler. This is how people outside of Microsoft will contribute features to the compiler from now on. (Previously you couldn't deploy your custom compiler to Visual Studio but they fixed that in Visual Studio Update 1).
Roslyn is two things:
An API that lets you see "compiler things" like syntax trees and symbols.
A new csc.exe that is implemented atop #1.
If you want to make changes to the compiler and use that to build, take a look at these instructions if you haven't already. There's a few different ways you can make your own version of csc.exe and then use that to build something. But there's no "choice" dialog like you're looking for.
Roslyn is the default compiler of Visual Studio 2015. So, if you install VS2015 you´re already using Roslyn.
Roslyn is a codename for .NET Compiler Platform, and it provides open-source C# and Visual Basic compilers. The project is available on github.

Aspect Oriented Programming with Roslyn

Does roslyn or visual studio 2015 provide API to rewrite IL or "something like that"? Let me explain...
I've read in msdn magazine's article Use Roslyn to Write a Live Code Analyzer, that it is possible to write custom code analyzers distributed via nuget packages, without need for visual studio plugins.
I'm really curious, if roslyn compiler and visual studio 2015 will allow to implement e.g. Code Cotracts such way, that no plugin is required to build it correctly.
Also, I would like to gain productivity and readability of my code with aspects like [NotifyPropertyChanged] data annotation on properties, but again, if it won't build correctly on every machine with visual studio 2015, it's not a good idea.
It is possible to use DispatchProxy from System.Reflection.DispatchProxy package. Unfortunately I haven't found any examples how to use it, but it looks like a replacement for RealProxy class with some differences (examples how to use RealProxy: hear and here).

How to implement code folding in C#

I'm beginning to work on a COBOL/BASIC IDE at work (to replace the one that we have currently that's a slight step up from Notepad). It'll be made in C#. The management is really interested in implementing some Visual Studio type features, and a big one is code folding. I've looked on MSDN, but I didn't see any good way to collapse lines (or to add the expand/collapse buttons).
I'm assuming that the text area should be a RichTextBox. Am I off track here? I suppose it could be done with some sort of modified TreeView, but that seems a little wrong to me. Is there some way of doing this that I'm just missing?
Why not use an existing IDE and extend it? Writing one from scratch is a huge undertaking (you need a parser, lexer, syntax highlighter and more), and is even more complicated if you need to support multiple languages (you mention COBOL and Basic).
Notepad++ has syntax coloring and one can add languages to it - COBOL is one of the ones installed by default. It supports code folding and has many plugins (you can write your own, that will suit your needs).
Edit:
Eclipse is another excellent IDE that has similar support, and as mentioned in the comments has a COBOL plug-in.
I suggest you take a look at SharpDevelop. It's a pretty good IDE with a bunch of Visual Studio like features already built in. It's written in C# and fully supports code folding with syntax highlighting in several languages. Plus, it's Open Source under the LGPL license. So, if you don't want to base your app on SharpDevelop then you can still reuse some of their controls like the code editor or windowing toolkit.
You should consider adding the COBOL language to SharpDevelop instead of starting from scratch. If you can't do this, then you can still use the SharpDevelop code as a decent reference on how to make a good IDE work.
Sometimes embedding Eclipse or a full-fledged editor is not appropriate. It's overkill or overweight or wrong for some other reason. I appreciate the first inclination suggested in other posts to not re-invent here, but in some cases a small invention is what is necessary. For example, the textbox used to make Stack Overflow posts .... is neither Eclipse nor an embedded Visual Studio. I wonder why?
It's important to ask the question - build it or buy it? - but sometimes, the correct answer is BUILD IT.
XPathVisualizer provides a simple example of a code-folding text editor implemented in C#, and based on a RichTextBox. It's not VB, though - it's an XML editor. But the general principles apply.
Here's a look at it.
To implement XML syntax colorization dynamically, while the user types, it uses a separate background thread. The reasons why and some of the details are described in a separate answer on Stack Overflow.
You could do something similar for your COBOL/VB thing. XPathVisualizer is open source, licensed with MS-PL, so you can browse and borrow.
If your team is used to "Visual Studio features," then I'll assume you use Visual Studio there at the office. Here are my suggestions:
Base your IDE on Visual Studio, for the following reasons:
Use Visual Studio 2010 if possible. The SDK is greatly improved from 2008/earlier.
Use Visual Studio 2008/2005 otherwise. At the moment, all of my commercial IDE products only support 2005/2008.
If your team uses Visual Studio, they will hate Eclipse. Not even an option to consider in this case unless you choose to use an existing Eclipse plug-in, saving you the time of creating a new IDE.
If your team isn't using Visual Studio 2010, you can use the Visual Studio 2010 Shell in Integrated Mode for free (Isolated Mode is not what you want). This lets you use Visual Studio 2010 for your IDE for now, and should the team upgrade later to one of the full versions of Visual Studio 2010, the IDE for your language will cleanly integrate into the full version. Edit: Visual Studio Shell is basically the core of Visual Studio without any specific languages (C#, C++, VB, etc.) included. Microsoft provides this core for free, and it's a great option specifically for people interested in creating their own language support.
Read my answers in the following two questions:
Here's a longer post on my reasons for using 2010 over 2008: How do I implement intellisense support for a custom DLR language in VS2008?
Here's a very long answer on implementing various features (most of which are based on the 2005/2008 SDK): How do i implement intellisense for my language in visual studio?
Writing a complete IDE is a HUGE task. I would recommend trying to find an existing one that has what you want, or make adaptions to an existing open source IDE.
To answer your question: I guess that the Visual Studio IDE uses a custom control, written from scratch, rather than a RichText control.

JavaScript Editors for .NET Programmers

I am a .NET developer, what JavaScript code editor would make sense to use if I spend most of my day in Visual Studio?
For a .NET programmer, I would think Visual Studio 2008 -- using jQuery with the vsdoc files.
You can use Notepad++.Other editor also you can use is Yaldex.
Try Far Manager and its built-in editor together with Colorer-take5 plugin. Very good solution to the source code managing and editing.

Categories

Resources