Contents tagged with Code Snippets

  • Code Blog

    I've just uploaded a set of unit tests for a sorting algorithm.  Anyone is welcome to flesh out the failing stup implementation and make the tests pass.  You can compile the code and run the tests online.  Once all tests pass you are free to give your submission a title and post to the Code Blog.  To see other people's submissions you can subscribe to the feed.

  • Who Needs VB.NET Macros?

    Prototyping addins can be frustrating. If you don't fancy learning VB.NET just to write macros, you're forced to work with a full blown addin. This is anoying if all you want is a quick spelunk inside the VS automation model. This is why I've added another test target. If you select 'Run With... VS.NET', your tests will run inside the current VS.NET process. I've made the DTE object accessable using AppDomain.Current.GetData("DTE").

  • Code 2 Html

    Nauman Leghari writes "I am looking for an addin which can convert code to html from the VS.NET IDE".  I've been thinking about this recently too.  It would be easy to adapt the NUnitAddin code to do this.  Look for AddControl("Code Window", 3) in the source.  You could use the SgmlReader to filter the code (after copying it to the clipboard).  It does copy as a kind of HTML, but with lots of horrible Office and style tags (look the the HTML of any if the snippets I have posted).

  • Command Line Parsing with XmlSerializer

    Duncan Mackenzie commented about a command line switch parser he found. Has anyone thought of doing command line parsing using (my current favorite class) the XmlSerializer? The code that follows can handle strings, ints, uints, bools, enums and arrays. Best of all it's only a page of code!  The code you are about to see was designed using Ad Hoc tests.  The '_verbose' category is a hint to dump the object's fields and properties.  You can find more information about point and click testing here.

  • Immediate - Ad Hoc Tests

    Okay, as promised I've implemented Ad Hoc tests in the latest build. The idea is to allow any method to be used as an Ad Hoc test. If the class the method belongs to implements a constructor or the IDisposable interface, these will be used to set up and tear down the test (unless the method is static). If the method returns an object, its fields and properties will be displayed (in a similar format the the Immediate window).