Wednesday, February 22, 2012

NuGet Project Uncovered: SpecificationExtensions.[MSTest | NUnit | Xunit]

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

NOTE: this project is one I created and as it turns out this has now become it’s introductory post.

The SpecificationExtensions.[MSTest | NUnit | Xunit] are a set of NuGet packages that add C# fluent specification extensions to your test project. I first blogged about this in early 2009 and have had a set of these that I take with me for every project I work on.

There are a number of other options out there for specification extensions, but since I first created my original set, I haven’t used anything else (although I should as I might be able to learn a little from each).

image_thumb10_thumb

Tuesday, February 21, 2012

NuGet Project Uncovered: EventAggregator.Net

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

NOTE: this project is one I created and as it turns out this has now become it’s introductory post.

EventAggregator.Net is a single C# file that can provide a basis for a simple in memory Pub/Sub event aggregator.

I extracted this out of my StatLight project as I found that I often wanted a similar one and kept finding myself copy/pasting this into projects. I figured a single location for this project would be better and I use StatLight as the first dog bowl when I need to dog food the project.

If you’re familiar with the…

Install-Package Caliburn.Micro.EventAggregator

…then you know probably know what this project is like.

Its history starts a few years ago when I read Jeremey Miller’s Braindump on Event Aggregator Pattern and decided I wanted rip out StatLight’s usage of the Prism event aggregator and replace it with a similar one to the one found in StoryTeller. It’s gone through quite a few revisions inside of StatLight since then and eventually made its way into its own project.

Some thanks have to go out to the great feedback and pull requests from Jake Ginnivan who found this project on his own (before I publicized it).

If you’re interested in using it, I’d recommend checking out the source’s test project and the SampleUsage project. The SampleUsage project demonstrates how you can configure the tool to publish events in an async mode.

One concept introduced in this EventAggregator is taking the IEventAggregator interface and breaking it up into two interfaces (IEventPublisher and IEventSubscriptionManager). This proved extremely useful when trying to diagnose components that did both aggregator subscription management vs ones that only published events. It even helped to easily diagnose components that did not correctly unregister objects.

Monday, February 20, 2012

NuGet Project Uncovered: DumpToText

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

NOTE: this project is one I created and as it turns out this has now become its introductory post.

DumpToText is a single C# extension I wrote a little while back. The inspiration from this came from the need to view the values of an object graph quickly and easily during a TDD session.

Have you ever been doing TDD and something isn’t working quite as expected? Would it be nice to just dump out the values of an object quickly without having to spin up the debugger?

The inspiration for this project came from an amazing feature of LINQPad. If you have ever used LINQPad then you’re aware of the amazing ability for it to take any object and create a view of it’s data. Take the simple anonymous type below.

image_thumb2_thumb

Now wouldn’t it be great to have that “.Dump()” extension method at hand anywhere in your code and during a TDD session?

That’s why I create DumpToText.

Now if I have a test as follows and want to see it’s data. I can use the ‘.DumpToText()” extension method to have it print out an ASCII based representation of the object graph.

image_thumb4_thumb

image_thumb6_thumb

By default this just uses the System.Diagnostics.Trace(…) to write the output to, but you can override the “write” implementation by giving your own delegate as shown below.

image_thumb8_thumb

The below shows an example of a nested object that also has an array of items.

image_thumb14_thumb

image_thumb13_thumb1

Anyone out there using ApprovalTests? (You can get it on NuGet)

I’ve not taken the chance to use ApprovalTests yet in a project, but I have a strong feeling that my DumpToText helper could be very useful when leveraged in conjunction with ApprovalTests. If anyone out there is using ApprovalTests, I’d love to hear how it’s going, and if you think that DumpToText would be useful there.

Sunday, February 19, 2012

NuGet Project Uncovered: Nancy

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

Nancy is another project founded by an elegant coder. Andreas has blogged about it a number of times here on ElegantCode.

Nancy is a lightweight HTTP framework for building web services and sites. The framework runs on both the .net framework and Mono.

I have not used this project myself, but as I started to look it over I think I might have to spin up a site quickly just to try it out.

Saturday, February 18, 2012

NuGet Project Uncovered: Extended.Wpf.Toolkit

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

Extended.Wpf.Toolkit is a project that should not need an introduction, and if you follow this blog you’ve probably heard Brian talk about it. If not, check out some of the posts on the Extended WPF Toolkit!

This project is one of the most download on codeplex, discussed on Channel9, Coding4Fun, and is being leveraged by Telerik in their Open Access ORM product.

Below is a sample of some of the controls you can find in the toolkit:
(but make sure you check out the project site for the full list of controls)
  • BusyIndicator
  • Calculator
  • ChildWindow
  • ColorCanvas
  • ColorPicker
  • DateTimePicker
  • Magnifier
  • MultiLineTextEditor
  • PrimitiveTypeCollectionEditor
  • RichTextBox
  • SplitButton
  • WatermarkTextBox
  • Wizard

Friday, February 17, 2012

NuGet Project Uncovered: TranslatorService.Speech

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

TranslatorService.Speech is a small little wrapper around the Bing text to speech API. You will need to get a Bing api key to leverage this.

Below is a sample usage of the library.

SpeechSynthesizer speech = new SpeechSynthesizer(APP_ID);   


// To obtain a Bing Application ID, go to http://msdn.microsoft.com/en-us/library/ff512420.aspx  

string text = "Have a nice day!";
string language = "en";

using (Stream stream = speech.GetSpeakStream(text, language))
{
using (SoundPlayer player = new SoundPlayer(stream))
player.PlaySync();
}



I threw that into a quick test and was quite impress with how fast it worked.



Unfortunately I tried to translate a larger “paragraph” or so of text and saw.




System.Net.WebException : The remote server returned an error: (400) Bad Request.



at System.Net.HttpWebRequest.GetResponse()

at TranslatorService.Speech.SpeechSynthesizer.GetSpeakStream(String text, String language)


at NuGetTestProject.Sample.SampleTest() in Class1.cs: line 14




I didn’t take the time to diagnose why, whether it’s a Bing problem or this library.



Some other observations:




  • + It supports some Async methods as well


  • - The Async methods don’t support the standard APM so I couldn’t easily wrap a task around. (I know there are some ways to make it work, but it’s not out of the box easy…)

Thursday, February 16, 2012

NuGet Project Uncovered: JsValidator

If you are coming to this series of posts for the first time you might check out my introductory post for a little context.

JsValidator, on first glance, is a down right awesome gem of a NuGet. I’ve heard of Google’s Closure Compiler before, but have never used it. This NuGet makes it a snap to use inside Visual Studio.

When you first install the package:

Install-Package JsValidator;

This NuGet tool automatically updates your project so it will execute the tool on compilation. Awesome if you are not an MSBuild expert as it just configures itself for you straight from the package install.

Once installed, run a build on your solution. On first build you get an error. You’re probably thinking '”How can this tool be erroring, we just added it to the project”. This error is a good thing. It’s telling you that you now have a manual step to configure it correctly.

Go check out the codeplex site as it will explain more on how to use it.

I just might consider this on my next new javascript project in Visual Studio.net.

 

Copyright 2008 All Rights Reserved - Revolution Theme - by Brian Gardner. Converted into Blogger Template by Bloganol dot com