網站地圖 最近更新 News ElispArea 教导

FlymakeCsharp

Flymake for C#

Flymake for csharp is now builtin to csharp-mode.el . There are enhancements that makes using FlyMake with C# modules, nicer.

http://i40.tinypic.com/ifze6c.jpg

For those who are unaware, Flymake is built-in to emacs, at least with v22 and later. It periodically compiles an active buffer when the minor mode is enabled, and then flags or highlights lines that cause errors or warnings during the compile as you edit. It is analogous to the red-squigglies you get in Visual Studio, highlighting syntax errors or other compile problems.

Download

You get the flymake-for-csharp stuff when you use csharp-mode, available at Lisp:csharp-mode.el

Rationale

FlyMake often works “out of the box” with other languages. But C# has a few differences that mean it doesn’t work right out of the box, with FlyMake.

  1. FlyMake is set up to use makefiles. But many C# modules are compiled as part of a project defined in a .csproj file, or an msbuild build file. Some C# modules are small and don’t use a makefile at all. Most developers use a mixture of these build environments, so FlyMake should be able to use any of them.
  2. In contrast to C, with C#, references to external libraries are checked at compile time, not only at link time. In cases where a .csproj file or makefile is used, the user will need to compile several .cs modules together, just in order to resolve those references to perform a syntax check. By default, FlyMake doesn’t handle that.

History

The original flymake-for-csharp came from a Blog Post on MSDN.

It has since been generalized, updated, and made more reliable and flexible.

In May 2011, it was integrated into csharp-mode itself.

Basic Usage

Flymake-for-csharp can do syntax-checking builds, on-the-fly, via flymake, using

To use it:

1) use csharp-mode

2) Add this to your csharp-mode-hook function:

      (flymake-mode)

3) specify how you want to use flymake, by including a comment at the top of the file, eg:

   // flymake: csc.exe /t:module /R:MyAssembly.dll @@FILE@@

For more detail, see the extensive comments in the elisp source code, or view the doc string for csharp-flymake-get-cmdline .

Complementary stuff

Don’t forget:


FlyMake