Kodefu

Hone your software combat skills with kodefu.
ref on Reference Type?!
I recently came across a piece of code that had almost every parameter for every method marked with the ref keyword. This keyword is primarily used to pass a value type by reference, but this one even had reference types marked with the keyword. This made me wonder, why exactly would you ever want to pass a reference type as a ref parameter? Read More...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Friday, June 12, 2009 4:30 PM | Feedback (2)

Refactor to Array Initializer
Taking advantage of language features can make sleeker, easier to maintain code. One of these language features are array initializers. Have you ever created an array, then assigned each element in the array? This incurs many lines of code with no tangible benefit. Check out this code from the NameMangler class in LINQ to XSD. Read More...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Wednesday, June 10, 2009 12:39 PM | Feedback (0)

Structs Structs Structs
It appears that my blog post on Friday wasn't saved. This is kind of bizarre. You can catch back up on it at my website. Stop Using Structs Everywhere And I posted a follow-up today: More On Structs
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, June 08, 2009 1:31 PM | Feedback (0)

DynamicAttribute
We've all been told to think of a dynamic object as a regular object but with dynamic behavior. Kevin Hazzard peeked behind the curtain to show that the compiler is actually doing a lot with that keyword; it isn't just an object. It does change the type to an object, but then it builds CallSites everywhere that object is referenced. These CallSites handle the calls to the dynamic language runtime. That's great, but we have an object. How does a consumer of your class library know that a property...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Thursday, June 04, 2009 5:18 PM | Feedback (0)

PDF From Web in AxAcroPDF
If you've ever needed to host a PDF in a windows form application, the easiest way to do so is by using the ActiveX control provided by Adobe Acrobat. Accessing it is easy: Right click the toolbox, select Choose Items, select COM Components, then check Adobe PDF Reader. The Adobe PDF Reader control now shows up in your toolbox under the General tab. You can move this to a different tab by dragging and dropping. If you drag this to your Windows Form, it now acts like a regular control. Its default...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Wednesday, June 03, 2009 5:52 PM | Feedback (1)

Edit Object in Properties Pane
When creating a designer for Visual Studio, you may want to allow editing in the properties pane. This took me a while to figure out how to do, because the terminology wasn't quite what I expected it to be. Here's how I accomplished this task. The window pane that hosts the designer implements IVsWindowPane. This interface contains a method called SetSite, which will provide a pointer to an object that implements IServiceProvider. I instantiate a ServiceProvider and assign this to a ServiceProvider...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, June 01, 2009 7:05 PM | Feedback (1)

Visual Studio 2010 Beta 1 Available Today
Mike Ormond has announced that Visual Studio Beta 1 (including .NET Fx 4.0) will be available to MSDN subscribers later today. He also posted a few screenshots. I admit that I'm somewhat saddened by the removal of the triangles...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Monday, May 18, 2009 9:35 AM | Feedback (0)

GacUtil, MPF, and CSProj
Yesterday, I wrote about running GacUtil from within the AfterBuild target, due to some constraints with MPF and T4. I discovered that the path I provided was wrong. It's the only GacUtil.exe under the Microsoft.NET folder, but it won't register the assembly. Since I wasn't sure which path I should be using, I used the GacUtil task from MSBuild Community Tasks. Here is the relevant code it uses to retrieve the path to gacutil.exe: protected override string GenerateFullPathToTool() { return ToolLocationHelper.GetPathT...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Thursday, April 30, 2009 11:13 AM | Feedback (1)

GacUtil from Project File
Due to circumstances involving a MPF package and Text Templating (t4), I had to add an assembly to the GAC after compiling if I wanted to be able to run the generator in the VS Experimental. So, I added the following line to the AfterBuild target of the csproj file: <Exec Command="gacutil /i $(TargetPath)"/> Unfortunately, I received the following error when I compiled: Error 155 The command "gacutil /i [PathToDll]" exited with code 9009. C:\Projects\AperioVisualStu...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Wednesday, April 29, 2009 5:51 PM | Feedback (0)

Team System 2010 Overview
Brian Harry has posted a list of features that will be in the upcoming beta 1 of Visual Studio 2010 Team System. Unfortunately, the date of release for beta 1 has not been announced yet. Architecture (http://blogs.msdn.com/came... Architecture Explorer Layer diagram Use case designer Activity designer Component diagram Logical class designer Sequence diagram Modeling project system UML Model explorer Architecture validation during build Development & Database (http://blogs.msdn.com/habi...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Posted On Tuesday, April 21, 2009 9:32 AM | Feedback (0)

Full Kodefu Archive