Syndication

News

     

Archives

Miscelaneous

Programming

February 2009 - Posts

ILMerge is one of those little-known gems that are an absolute must-have once you know how to apply them effectively to scenarios you didn't even think about.

Specifically, whenever you work on a multi-project solution that may also use external projects in turn, forcing your users to add (say) five assembly references just to your "entry point" library is clearly a bad experience. One example that comes to mind is Enterprise Library, where you add a minimum of 3 (IIRC) assembly references to use just about *any* block in isolation. If you use more than one, it quickly becomes quite a big list. Wouldn't you want to just give your users a single EnterpriseLibrary.dll?...

Read full article

Posted by Daniel Cazzulino
Filed under: ,

The question of how to mock extension methods comes up frequently enough that I though I might give my opinion and solution to it (which does NOT include using TypeMock ;)).

A first differentiator is whether you control the definition of the extension methods or not. The latter case would be, for example, the built-in Linq extension methods (First, Count, etc. on IEnumerable<T>) and there's no way to mock them unless you use TypeMock. The former would be your own logic that you decide to place in extension methods for whatever reason, and that can be mocked using the technique I'll explain in this post....

Read full article

Posted by Daniel Cazzulino
Filed under: ,

I just couldn't resist going for the brand new beta which is being praised quite a bit when I got my new Lenovo X200.

I used a trick I got from Pablo on how to quickly install Windows 7 from a pendrive (quickly as in <15'!!!), and was up and running pretty fast. Right out of the box I got LAN connectivity, and installing all remaining updates I was in pretty good shape. A few drivers missing, but nothing critical, except for the ***WiFi*** drivers!

See, the page for the Lenovo X200 shows you the Intel WiFi Link 5100 and 5300 as options (which I used to built mine), but the Lenovo ...

Read full article

Posted by Daniel Cazzulino
Filed under: ,

Rather than typical code like:

private static MethodInfo GetFirstMethodWithReturnType(Type type)
{
    return
        type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
            .Where(method => !method.Name.StartsWith("get_") && !method.Name.StartsWith("set_") && 
!method.Name.StartsWith("add_") && !method.Name.StartsWith("remove_")) .FirstOrDefault(method => (method.ReturnType != typeof(void))); } ...

Read full article

Posted by Daniel Cazzulino
Filed under: ,

Even now that Atom 1.0 has been approved and official for some time, there's a feed every now and then that still uses Atom 0.3 (i.e. Google News! http://news.google.com/?ned=us&topic=w&output=atom).

The .NET APIs for feeds, System.ServiceModel.Syndication, handles RSS 2.0 and Atom 1.0 fine, and you just have to make a single call to load a feed regardless of its format:

SyndicationFeed.Load(xmlReader);

I searched the web looking for an easy answer, but I couldn't find any that would let me seamlessly plug into the .NET APIs to do the feed format upgrade on the fly. So I put one together myself :)...

Read full article

Posted by Daniel Cazzulino
Filed under: ,

Now that there's an official installer of Live Writer that works on x64, I updated my plugin that allows you to cross-post a blog entry to a second WLW account, optionally summarizing the entry and always linking back to the source blog. I summarized the reasons why you might need to do this as well as the feature set in How to cross post entries across blogs from Windows Live Writer.

The plugin options are still the same:

image

And after you posted successfully your original entry, cross-posting to the selected account is one click away:...

Read full article

Posted by Daniel Cazzulino
Filed under: ,

Note: this entry has moved.

Context: invocation represents a method invocation, has a method and the array of arguments passed-in. We want to render the call such as: MyClass.MyMethod(1, true, null, "foo"). Note how null values should render as the string "null", and string values should be enclosed in quotes.

Here you go:

return
	invocation.Method.DeclaringType.Name + "." +
	invocation.Method.Name + "(" +
	String.Join(", ",
		(from x in invocation.Arguments
		 select x == null ?
			"null" :
			x is string ?
				"\"" + (string)x + "\"" :
				x.ToString())
		.ToArray()
	) + ")";
Posted by Daniel Cazzulino

From my friend Pablo:

I just got an email from Miguel Angel Saenz confirming the date of the next biggest Microsoft event in Buenos Aires Argentina, "MSDN briefing", which will take place on March 25th.

They are now accepting proposals or suggestions for possible sessions in the event, or to give an specific name to event itself :).

If you are interested in participating, check out this website.

Hope to see some of you there!

Posted by Daniel Cazzulino
Filed under: ,

Over the past few days, I spent some time recording the experience of building a dependency injection container using test driven development. It was a cool experience for me, and I hope you find the screencasts useful.

Here are all the episode links:

  1. Part I: selecting a high performance approach and building the basics with few lines of code. View | Download
  2. Part II: adding support for passing constructor arguments to resolved instances. View | Download
  3. Part III: adding named services and refactoring to improve code. View | Download
  4. Part IV: add support for instance reuse. View | Download
  5. Part V: adding support for container hierarchies. View | Download
  6. Part VI: adding deterministic disposal of container hierarchies and instances created by them. View | Download
  7. Part VII: polishing a fluent API. View | Download
  8. Part VIII: adding support for initializer functions. View | Download
  9. Part IX: how well does it perform really? View | Download

 

Funq is by no means a revolutionary concept to DI, I’m well aware of that. But it’s one that takes a minimalistic approach to keep the performance impact of DI to a bare minimum. One of the project core requirements was to perform very well on the Compact Framework, as part of its inclusion in the upcoming Mobile Client Software Factory v2 from patterns & practices.

I hope this series serves to understand the inner workings of this fully functional yet extremely simple DI container.

 

Posted by Daniel Cazzulino
Filed under: ,
More Posts