Getting csharp-mode Emacs syntax highlighting working - c#

Googling "csharp mode emacs" yields the page
http://www.emacswiki.org/emacs/CSharpMode
which includes a few links to various downloadable emacs lisp files. The 2005 link (DylanMoonfire) is broken, so I downloaded:
http://lists.ximian.com/pipermail/mono-list/2002-May/006182.html
as ~/.emacslib/csharp-mode.el
and added:
(autoload 'csharp-mode "csharp-mode"
"Major mode for editing C# code." t)
(setq auto-mode-alist (cons '( "\\.cs\\'" . csharp-mode ) auto-mode-alist ))
to my .emacs file (anywhere, beginning, middle or end). I attempt to edit a new text file called "t.cs" and I get the error:
File mode specification error: (error "Buffer t.cs is not a CC Mode buffer (c-set-style)")
and no syntax highlighting. I'm not well versed in emacs-lisp but I know enough to install support for loads of language modes and csharp-mode is just not playing nice compared to every other language mode I've installed.
I was getting excited to play with Mono on my Mac and ran into this ridiculous barrier! Anyone out there know how to get decent support for C# syntax highlighting in emacs?
Note: I'm using a MacBook Pro running Emacs 22.1.1 on OS X Leopard.

I found a more recent version of csharp-mode 0.7.0, go to the end of the page and download as plain text. Haven't tried loading the mode however.
Just uploaded the code to emacswiki as well: charp-mode.el

What you have seems to be very outdated. It's too bad that the more up-to-date version was not hosted somewhere safer, like the Emacs core, EmacsWiki, or Github.
But anyway, you might as well try asking on #emacs (Freenode) and see if someone can send you the more up-to-date file.

I made a slight modification to make Tab indent 4 spaces and deal with braces correctly, so now hitting tab on any line "does the right thing" with respect to conventions in Visual Studio.
http://www.updike.org/files/csharp-mode.el

The EmacsWiki page for CSharpMode says that the most current version of this package can always be found on github (josteink/csharp-mode).
Maybe you would like to use OmniSharp-Emacs that provides IDE-like features for editing files in C# solutions in Emacs.
See also the article Emacs as a C# development environment.

Related

Where is the snippet for a method's XML summary?

I'm referring to the snippet that's used when typing /// before a method.
I've found something for JavaScript (C:\Program Files (x86)\Microsoft Visual Studio 14.0\JavaScript\Snippets\1033\XML Comments) but changing it didn't affect the C# XML summary.
I'm aware of this question but the accepted answer doesn't really answer this question, and the second answer is outdated.
As requested by OP, not sure if it's an answer - but there doesn't seem to be a better one at the moment, unfortunately...
This may be helpful, this is a User Voice for this and still unresolved as it seems.
As per the #HenkHolterman's comment - that I agree with - I don't think that's a snippet. For the moment it seems to be built into VS (out of curiosity I searched through VS 15 - new version not the 2015, and nothing new in there either - I searched all files for anything resembling XML comments).
There's a VB solution that, as I could see, places a custom .XML file in the specific AppData location - which doesn't work for C#. They describe the process as...
Visual Studio has built-in defaults for the XML skeletons that get
inserted, but when VBXMLDoc.xml is present upon startup, Visual Studio
will use the XML definitions from that file instead
As per a comment above - there's a User Voice request for it. And as per a comment on the User Voice - it can be done in VB but not C#.

Stetic GUI Designer Move to Glade for Gtk#3

I'm currently working at an audiobackend binding for my application. Since I want to use gstreamer, I found out, that I need to use GTK#3, because this is needed by gstreamer-sharp. Since I'm currently working with monodevelop, which uses stetic for GUI design, I wanted to ask, what is the best way, moving towards GTK#3. I see, that it uses .ui files for GUI definition, which can be generated by glade (I also tried a little bit around with glade). But my application has 4 windows with much code, so how can I easily transport this to GTK#3? Has anybody done this already?
Greeting
Sven
GtkBuilder works for both GTK2 and GTK3, Smuxi will eventually go that route and backport the GtkBuilder converted .ui files from Stetic back to GTK2.
The tool to convert the existing stetic UIs can be found here:
https://github.com/xDarkice/stetic2ui
Smuxi was a GTK2 app made with stetic too. When we did a Gnome .NET hackfest recently in Austria they found the problems you are talking about, but eventually solved them by using glade files and some clever approach to still be compatible with GTK2 and GTK3 at the same time, so you might want to look at their commits from September to November of 2013.

C# view source code of a particular .NET class

I browsed through some questions and this one stood out as the better one:
.Net Classes and their source code which pointed me to this place here: Microsoft Reference Source Server.
I tried everything the site says, downloaded a file that I cannot open from there and at some point ended up with a .pdb file in my source folder for the symbol cache that I could not open with a multitude of tools I looked into.
So this is my last resort to find an answer to my question. Out of pure curiosity (and lack of a better way to understand some stuff) I want to open a particular class from Microsoft (namely I wanna look into RichTextBox and maybe the classes it inherits from) but I simply cannot find a way to make this work for me. I want the original source, not a decompiler product because, well because I mainly need to understand some stuff, not see random variable names. I appreciate any help that may get me around my stupidity and clumsiness, as well as the right tools to do so (if any other than VS).
Note that I am using Visual Studio 2012 and yes, I went over a guide covering this specific version instead of the guide on VS 2008.
The "download" links on this page: http://referencesource.microsoft.com/netframework.aspx should work. However try downloading them via Internet Explorer; my Firefox attempted to download an .aspx file instead of the installer itself for some reason. (EDIT: as #ParagMeshram pointed out, just rename the netframework.aspx to netframework.msi as a quick fix if necessary)
In addition, here's a link to the source hosted by dotnetframework.org: http://www.dotnetframework.org/default.aspx/4#0/4#0/untmp/DEVDIV_TFS/Dev10/Releases/RTMRel/wpf/src/Framework/System/Windows/Controls/RichTextBox#cs/1305600/RichTextBox#cs
I can't say for certain if it's the latest greatest, or what you would be compiling against exactly, but should give you a good idea of how it works.

How to write and testing ASP.NET 4 on notepad?

Conditions:
I've been asked to develop a simple ASP.NET 4(C#) project in notepad. I'm completely new to this area.
The completed project should include several .aspx files, one master page, one sitemap and a web.config.
The book I'm using is a beginner cook book, based on using Visual Studio 2010 Express.
Developing it on notepad is a requirement to this school assignment.
Questions:
As what I know now VS2010 has its built-in Development Web Server which notepad doesn't. Should I test .aspx files by opening notepad files in browser? Will tags with runat="server" work?
Is there any helpful site or post that you know?
How should I testing master page?
Forgive my noob questions. The most sites I can find is teaching people how to develop by using VS2010, which is like my book, instead of notepad. The schedule is tight so I need some help here. Thank you for your time. I'll also share my experience when I finish this assignment.
It's a little more complicated than "runat="server"".
To give a little bit of 101, you will need:
A web server. The most natural one to use is IIS. I believe you should be able to use Apache as well if you're feeling adventurous.
The application framework. Guess what, it's .NET! There's also Mono if you're not using IIS. The application framework should also include the compiler. C# is a compiled language, so before you can run the code, you will have to compile it first. This is slightly different when compared to PHP.
The editor. You should be able to use Notepad, but Visual Studio provides you with more than just a fancy text editor. It helps you create the build script (the command that you send to the compiler), it helps you with project organization, and it helps you debugging.
So just using Notepad is doable, but you'll lose so much time for not using a free tool like Visual Studio Express.
Now to actually answer your questions:
No, it doesn't work that way. You will need a web server (see point 1 above) and a compiler (see point 2 above).
That's a little bit too broad. Your book should be a good starting point.
See answer 1.
I have finished that assignment. Here is my experience:
First, to develop an ASP.NET project on notepad or textpad is very unwise, unless you want to test your coding skill or having some other reasons. Because for beginner the best way to test your code is using VS "Ctrl+F5". If you write your code in notepad/textpad and test them in VS, it kind of defeat the original purpose.
There is a few tips, for the beginner like me.
Named your sitemap file "web.sitemap", and put it in the root directory of your project, otherwise you may have to go through complicated configuration process.
P.S. This is not a compulsory requirement, you can change the file name or directory, but you need to add site map provider in "web.config".
2 Choose your solution or project root directory carefully, because it is not easy to redefine it.
P.S. I spent a lot of time to move files around in Windows Explorer because I wanted to change my current solution directory to another folder.
These are the tips I find most useful. I would've saved at least 2 hours if I know these in the beginning.

C# Code Formatter for Linux and/or MonoDevelop

MonoDevelop 1.0 doesn't appear to have a code-formatter like Eclipse does for Java. Is there a preferred shell script (or MonoDevelop add-in?) that you've found to work well?
At the moment, source code formatting in MonoDevelop is marked as a future enhancement:
https://bugzilla.novell.com/show_bug.cgi?id=321946
In the meantime, you may want to check out Artistic Style for C# formatting:
http://astyle.sourceforge.net/
I'm planning to see how this might be wired up as an external tool within MonoDevelop. If I get to that, I will edit my answer with the information. UPDATE: I don't have enough reputation to leave a comment, so I'll make one here: Nice job, Dustin, and patch for MonoDevelop too :-) I wonder how recent the version is that is included with Ubuntu... Either way, I'm glad you found something that works for you.
Thanks, Brandon. I submitted a patch to MonoDevelop. The issue with MonoDevelop add-ins is that there is a mono compiler bug that doesn't handle anonymous delegates correctly. (bug report: https://bugzilla.novell.com/show_bug.cgi?id=394347)
The patch/workaround is to just cast the anonymous delegate to the proper delegate type. (bug report & patch: https://bugzilla.novell.com/show_bug.cgi?id=369538)
I'm running with the patched version now and am able to execute AStyle on the currently edited document by simply creating a new External Tool setting with the following settings:
TITLE: A_Style (put in an underscore _ to enable hotkeys)
COMMAND: astyle
ARGUMENTS: ${ItemPath}
Then, just execute it using Tools->AStyle (or ALT-T, S)
9/25/08 Edit -- I just put up a blog posting on how to patch MonoDevelop 1.0 and get it working with AStyle: http://dustinbreese.blogspot.com/2008/09/auto-formatting-code-in-monodevelop-10.html
It's a nice programming exercise to write your own formatter . I wrote one for C++ , and it was a nice challenge . You could learn a lot by writing it :)

Categories

Resources