Open Source .NET Development [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Open Source .NET Development [Electronic resources] - نسخه متنی

Brian Nantz

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید


.NET Editing Tools


As a developer, most of our time is spent using a glorified text editor. Therefore, choosing an editor is a very important task because you will be sitting in front of it for an awfully long time. There are literally hundreds of editors out there (proprietary and Open Source) that support various programming languages. You must weigh the goals of your project and your company to be able to choose the correct editor for your situation.

Editor Features


Here are some features to look for in an editor. These are not the only methods you can use to compare editors but rather are a collection of useful features on which I have become dependent.

Integrated Help

While the .NET SDK comes with great documentation, the way in which the editor integrates it (or the lack thereof) can almost determine the editor for you. However, switching back and forth between the editor and the documentation is not the end of the world. Each editor will have its little quirks. One annoying feature of VS.NET is when cutting and pasting from locations that use HTML (like MSDN or a Web page), VS.NET pastes the HTML markup, which is not exactly what is usually desired.

TIP

There is a wiiciwgp (What is in the clipboard is what gets pasted) plug-in for VS.NET available from http://www.codeproject.com/useritems/wiicwgp.asp that eliminates the HTML cut-and-paste problem.

I find myself using several of the editors later listed in this chapter, depending on the job at hand.

Syntax Highlighting

We take this for granted in IDEs today, but syntax highlighting is a very important feature. Being able to easily distinguish language key words from built-in types just by the color of the word is extremely helpful. It is not possible to demonstrate this familiar feature in a black and white book, but all of the editors listed here do support syntax highlighting. However, with some of the editors, you may need to download a plug-in or specialized file that extends the editor for the desired language.

Integrated Debugger

Another feature that is almost assumed in an editor today is an integrated debugger. This allows a developer to debug the application directly from the editor. Some IDEs support this better than others. Microsoft's freely available .NET SDK comes with a functional graphical debugger (DbgCLR) and a somewhat cryptic debugger (Cordg). Both tools can be found in the FrameworkSDK folder in the .NET SDK directory. The source for Cordg is also shipped with the SDK. The SDK documentation is very helpful in describing how to use the Cordg utility to print out variables and dump memory, so I will not rehash that information. Some editors wrap the functionality of the debugger of your choice into the IDE, allowing you to step line-by-line through the code. While this is much better than having to switch tools, probably the best debugger integration I have seen is in the Visual Basic 6 (VB6) IDE. VB6 allowed you to edit the code while debugging and continue on without having to break the debug session and recompile (which has been promised in the Visual Studio.NET 2005). Another nice feature is retrieving the value of a variable by just hovering the mouse over the text in the IDE. The integration and debugging with SQL also is very nice.

Integrated Command Shell

Being able to issue various operating system commands from the IDE is often useful. I was surprised to find that many of the newer editors do not support this or support only a subset of commands. Many of the old-faithful editors that have been around forever have the best integration of issuing commands from the IDE.

TIP

Microsoft has finally released a command shell for VS.NET, which is available as part of the VS.NET Powertoys (http://www.gotdotnet.com).

Intellisense Autocomplete

You may say that programmers have become lazy, but I think that the cleverest improvement in IDEs in a long time is Autocomplete. Later on, Figure 3-3 shows this feature in action. Intellisense saves a large amount of time in weeding out compiler syntax errors. I think one thing Microsoft has always done extremely well is put out development tools that are superior to any other tools available. Some of the more advanced tools available today rival Microsoft tools, but when attending conferences (and I do attend conferences not geared only to Microsoft), I have observed that usually a majority of developers use Microsoft development tools to get the job done. This is one of the sore spots with Java. Until the last few years, Java's IDEs were not as easy to use as other languages' IDEs. However, if you frequent MSDN TV (http://msdn.microsoft.com) as I do, you will note that many of the leading Microsoft developers use the very Open Source editors mentioned in this chapter and not Visual Studio.NET.

Figure 3-3. Sharp Develop IDE.

[View full size image]

Key Bindings and Shortcuts

By far the most powerful feature of an editor is key bindings and shortcuts. While these features are often overlooked, they provide greater time savings than any other feature. Editors provide these features in many different ways. VI is probably the most powerful at straight text editing. You can turn a file upside down and backwards with just a few keystrokes. (This can also be dangerous if not used properly!) But some editors have gone the extra mile and have specialized their shortcuts to .NET languages. For instance, a few editors support C# XML commenting much better than others. Of course the most specialized is Visual Studio.NET, and a list of facts and bindings can be found at http://www.sellsbrothers.com/spout/default.aspx?content=archive#vs.netfunfact.

NOTE


For visual studio .NET 2003 users there is a plugin at http://microsoft.com/downloads/detail.aspx?FamilyID=3FF96915-30E5-430E-95B3-621DCCD25150 that lists all key bindings in VS.NET.

Source Code Management Integration

Most editors today have some sort of integration with Source Control Management (SCM). I am not a big fan of version control that is integrated into IDEs. This is probably because Microsoft's tools have never done a very good job of integration. Because of the level of integration (or lack thereof) in Microsoft's tools, I have developed a preference of just using a separate tool for SCM.

Multiple Operating System Support

One feature you may not have thought of but should keep in mind when selecting an editor is the operating systems that it supports. As .NET matures on operating systems other than Windows, this editor feature becomes more important. Since many programmers memorize their key bindings and shortcuts, choosing an editor that works the same way on different operating systems eliminates having to learn a new editor and is a big timesaver. Of course this is not a key factor if you know you will always be using a specific OS.

Emacs


Emacs is a GNU project in and of itself, which means it is free. Emacs also supports many operating systems and languages. I find Emacs easy to use and a very quick editor that is much more powerful than Notepad. Figure 3-1 shows Emacs with the C# plug-in.

Figure 3-1. NTEmacs with C# Plug-in.

[View full size image]

Because Emacs did not originate on Windows, some of the common shortcuts (like Ctrl-X for cut and Ctrl-C for copy) are not supported. Ctrl-X is reserved to tell Emacs there is an upcoming command. For instance, Ctrl-X S saves a file. Many of the drop-down menus are consistent with Microsoft programs though. Emacs can integrate with just about any program, from CVS SCM to email.

TIP

For a list of Emacs commands, see http://www.refcards.com/about/emacsl.

Setting Up Emacs

Since Emacs is already installed on most versions of Linux and Unix, I will focus this section on using Emacs on the Windows platform. First you must visit http://www.gnu.org/software/emacs/windows/ntemacsl and download NTEmacs, which is the Windows port of the GNU project. Installing it is very simple. Then download the C# plug-in from http://www.cybercom.net/~zbrad/DotNet/Emacs/ and unzip it to the [emacsInsallDirectory]\site-lisp. Then copy the zbrad.emacs file to c:\.emacs from the command line. For Linux and other OSs that contain Emacs, you can just use the C# plug-in instructions and skip the Emacs installation steps.

VIM


VI iMproved (VIM) is a very popular distribution of the powerful VI editor. Available under the GNU GPL license, VIM is downloadable from http://vim.sourceforge.net. VIM is easily installed on either Windows or Linux, and the latest version I downloaded has the C# syntax module already installed. Figure 3-2 shows VIM in action.

Figure 3-2. VIM's C# Editing Capabilities.

[View full size image]

VI has two modes of editing a file: Command Mode and Insert Mode. Command mode allows commands such as file saves, file opens, etc. to be executed on the file. Insert mode allows text to be inserted in the file. VIM also has the same wide integration with other programs that Emacs has.

Command Mode

VIM defaults to command mode. To issue a command, the colon (:) is used. Entering Insert Mode is just one of many commands available in VIM. VIM comes with great documentation, and almost any Unix book has a chapter on VI.

Insert Mode

Once in Insert Mode, text can be inserted to the currently active buffer. Traditional VI cursor navigation is a little different than most Windows applications. However, VIM has graciously allowed the arrow keys to be used to navigate throughout the buffer.

Sharp Develop


Sharp Develop (#develop) is an Open Source IDE for developing .NET applications, which itself is written in C# using Windows Forms (see Chapter 4, "Build Automation") for its builds. Sharp Develop goes farther than most other editors by also supporting VB.NET, Resource Files, and Web services. Most editors listed here support XML, Java, C++ and a smattering of other languages, but #develop is the only one I have found so far that supports VB.NET- and .NET-based Webservices so well.

#develop uses other Open Source projects from icsharpcode.com including the CVS C# Module for Software Configuration Management (SCM) integration and #ziplib to zip all the files together into a solution file. Both #CVS and #ziplib are also used by the nAnt project, which goes to show how reusable Open Source is. Sharp Develop uses nAnt, and nAnt uses components of #develop. I am sure that neither team had each other in mind when creating the projects. This is the amazing power of Open Source. Sharp Develop's beautiful user interface uses another Open Source project called Magic (http://www.dotnetmagic.com). Unfortunately, the Magic UI makes a lot of direct Win32 calls and thus prohibits #develop from working on any other platform than Windows, but the Sharp Develop team is working hard to remedy this and has replaced much, if not all, of the Magic Library with Lutz Roeder's CommandBar (http://www.aisto.com/roeder/dotnet/).

Web Matrix


Although not an Open Source product, Web Matrix does qualify as free software per the FSF's freedom level 0 definition. Web Matrix is freely available (http://www.asp.net/webmatrix) and is the most powerful editor available for ASP.NET Webform Applications. This IDE is very similar to the Visual Studio.NET user interface but without the cost. Figure 3-4 demonstrates Microsoft's Web Matrix contribution to the development community.

Figure 3-4. Microsoft Web Matrix.

[View full size image]

Eclipse


Eclipse (Chapter 2, "Open Source and the .NET Platform").

Figure 3-5. Eclipse IDE.

[View full size image]

Although I am rather new to Eclipse, I had no problem adjusting once I understood an overview of the editor. The Eclipse project is made up of basically two aspects: workspaces and workbenches.

Workspaces

A workspace deals with projects. Projects contain files, folders, and other resources such as SCM. A workspace is a team-focused feature. The workspace is a container for workbenches, the project history (used almost like a mini-SCM to prevent data loss), and markers (used for status of things like error messages and to-do lists). Resources are so well managed that a user can open a workspace and receive the exact same views, plug-ins, tools, and overall project status.

Workbenches

Workspaces are not really reflected in the user interface and are more of a conceptual thing. Workbenches are what you see when you fire up the UI. Workbenches consist of editors, views, and perspectives.

Editor

An editor (top-left portion of Figure 3-5) allows a user to create or modify an object. Most often, an object is a file type like C#, XML, or Java. Editors can be generic text editors or more specific and complex editors supplied by other plug-in tools.

View

Views provide information about an object. In Figure 3-5, Navigator, Outline, and Task are all views giving information about the test.cs object. Changes to a view are usually applied immediately, whereas changes to an editor are buffered until the user explicitly saves them. Additional views are supplied by other plug-ins.

Perspective

Perspectives are a collection of editor and view configurations. Only one perspective can be viewed in the workbench at a time. Eclipse comes with built-in perspectives (CVS, Install/Update, Java, Java-Browsing, and Resource). Figure 3-5 is in the Resource perspective. The icons on the top left of Eclipse allow you to change perspectives.

TIP


After installing Eclipse, you must switch to Install/Update Perspective to install the Improve Technologies C# Plug-in.


One Last Word on Editors


In presenting and talking about Open Source .NET development, it has become increasingly apparent that developers confuse the features of Visual Studio .NET with the features of .NET in general. I have heard many coders protest that they cannot use Open Source because Visual Studio .NET is their favorite tool and that Edit and Continue is a cool Microsoft .NET feature. This is an example of a feature of the IDE and has nothing to do with .NET development in general. Do not make this mistake! When looking at Open Source projects, you will usually find that some of the developers use Visual Studio .NET. The dead give-away is the solution and project files, but sometimes things are a little more subtle, like the Visual Studio .NET autogenerated source (i.e., IntializeComponents). In addition, many Open Source projects are meant to be used with Visual Studio .NET, and you do not have to choose one way or the other. Visual Studio .NET is an impressive tool, but so is Sharp Develop. In fact, many of the C# refactoring tools featured in Visual Studio .NET 2005 are also found in Sharp Develop, and then some. (Also keep an eye on resharper from Jetbrains for some cool refactoring tools). One of the strengths of Open Source .NET development is that you can use Visual Studio .NET to develop and deploy your application using an Open Source CLI. If you want to see this in action, skip over to Chapter 11, "Web Development," and look at Listing 11.4: the HTML head meta tags give away that this ASP.NET Web page was developed using Visual Studio .NET 2003 and deployed on Linux using Mono! I did this to specifically prove this point. One of the unique features of Open Source .NET is the mixture of Microsoft and Open Source together. Generally, Microsoft is viewed as the biggest opponent to Open Source, and vice-versa. (Recently, though, I think SCO has taken the front seat in this area!) However, Microsoft is opening to the idea of Open Source. In communicating with Microsoft developers and watching some of their demonstrations, I have seen them use projects such as NUnit and SVG#. Obviously, Microsoft is aware of Open Source most evidently by the new MSBuild tool they released and its relation to another Open Source Tool called NAnt (more on this in Chapter 4). Unbelievable history was made with a recent Slashdot.org posting pointing out that Microsoft has released some of their code to Open Source (WTLhttp://sourceforge.net/projects/wtl/ and WIXhttp://sourceforge.net/projects/wix/). Having somewhat of an unconventional view of both Microsoft and Open Source, this does not surprise me at all.

Microsoft is taking advantage of the most powerful force of Open Source; not the great free tools and reusable components and the money they can save you or the access to the code that many proprietary companies charge extra for if they even allow you to have it. What Microsoft is taking advantage of is learning from other people's ideas and implementations. Behold the power of Open Source: even the largest software company in the world finds it irresistible!


    / 275