Well, not really. Have you ever wanted to test a snippet of code without having to go through the whole process of creating a new Visual Studio.NET project though?
Well, now you can. Just compile the attached code, run the program, write the code and run it. It works with C# and VB.NET, just choose which one you want from the menu.
I'm not terribly gifted in the art of developing my own ideas for programs so I should mention that someone else has done this before. It is called the SnippetCompiler (http://www.sliver.com/dotnet/SnippetCompiler/).
The program attached here is meant to be a no frills edit and run program so there is no syntax highlighting or printing or even editable references or compiler options yet. It does allow you to open and save snippets as well as redirect the output of the snippet to an output window within the application. If there are compiler errors double clicking them will bring you to the line that caused the error too.
Check it out if you are interested. I should mention that it comes with some prebuilt snippets and has been tested with a number of examples from the Framework SDK.
I've fixed some bugs and added some new features.
Just to highlight some of the new stuff, you can now choose which version of the framework to target, including 2.0, as long as the target version is installed. You can set a couple of compiler options and edit the references, including custom references to assemblies you may have written. Many of the settings will also be saved for use the next time the program runs (uses reboot's AppSettings (http://www.xtremevbtalk.com/showthread.php?t=131671) class). Multiple instances can now be opened without affecting each other [Note: The last one closed wins as far as saved settings are concerned].
Feel free to PM me with questions, comments, suggestions, or bug reports.
Here is the change log:
- Running a new snippet could cause a previously opened file to be overwritten. Fixed
- Console.ReadLine doesn't work for C# when commented out. Fixed for single line comments only
- Ctrl+V shortcut for Paste doesn't work. Fixed
- User can select which version of the framework to target.
- Console.ReadLine warning will now bring you to the identified spot in the editor when you click cancel.
- Added an options dialog.
- Settings get saved for the following items:
- Redirect output
- Framework version
- VB Options
- CS Options
- Tested to work with version 2.0 of the .NET framework.
- Multiple instances can now be used without interfering with each other.
- Removed the "~\out" directory and replaced it with a temporary folder in the PC's temp directory under a new GUID. This folder is removed when the application terminates without error.
- User can edit option explicit and option strict settings for VB compiler
- User can allow/disallow unsafe code for C#
- User can edit references to both built-in assemblies and custom assemblies.
Here is an updated version of my quick snippet program. I've fixed a couple of bugs and added some new features to make it more usefull. Note that this uses a custom control (source included) for the treeview explorer style navigation of saved snippets so you will need to build that before you can run the main program.
Here is the change log:
- redirect standard output will hang if too much data is written to standard output.
- the warning for the Console.ReadLine should not be case sensetive for VB.
- Allow saving of built assembly (build & save)
- Allow the snippet to be built as a console or windows app or class library (build & save only)
- Use a Treeview for easier navigation of saved snippets
- Changed error window to use a listview instead of a textbox
- Save window size, position, state, and size of left and bottom sections.
If you find any problems let me know.
10-12-2005, 12:16 PM
What does this program do? It looks intereseting.
It allows you to store, access, and test snippets of VB.NET or C# code without having to open Visual Studio, or even have it installed on your machine. It is tested to work with all versions of .NET from 1.0 to 2.0 Beta.
It comes in really handy for me when posting an answer to a question here because I can easily test the code snippet before posting.
This is basically just one of those things I developed for myself and decided to share if anyone else was interested.