C# Collection Initializers via Extension Methods

An interesting C# feature that I just stumbled across by accident: You can provide a custom collection initializer for any IEnumerable<T> using an extension method. It allows you to turn something like this:

into this:

by simply providing the Add method that is required for collection initializers as an extension method:

Definitely not something for everyday use, but I can imagine it could clean up some data-heavy bits of code a lot. It appears that this was introduced in C# 6.0, along with indexer initializers.

Read more …

Duality has Moved

As of July 21, Duality has move from google code to GitHub. Although google code and SVN provided a great platform for “personal” Open Source projects, Git(Hub)s focus on collective development and decentralized version control eventually convinced me to move. Although Git and GitHub seem to be quite popular these days, both were pretty new to me and I had no idea where to start; so I did a lot of superficial google research and forum inquiries.

Read more …

Debugging comfort

Nobody does as much Duality-related debugging as I do, so I recently explored ways to make this task a little more comfortable. As I discovered, there is more than one way to achieve that.

Read more …

Dynamic Lighting Test

As I’m experimenting with the “custom Rendering” capabilities of Duality there happens to be a new tech demo for you to download and play around with. It features per-pixel lighting using directional, ambient, spot and point lights.

Note that I didn’t touch any Duality code to implement the dynamic lighting technique – it’s all done inside the plugin.

–> Download Lighting Test <–

Read more …

A custom PropertyGrid

I’m working on some kind of custom PropertyGrid Control right now. You might have spottet it in some of the Screenshots that I’ve previously posted. .Net does have an existing PropertyGrid which is customizable to some degree and I could just have used it – but after doing that in Nullpunkt and not being very happy with the results I’m now trying a different approach.

Read more …

C# 4.0 powers, ACTIVATE!

When I began to write ZweiDe back in 2007, the target framework was .Net 2.0. The third framework version was already released, but I assumed it would severely impact compatibility to require the newest stuff available. As it took years to bring ZweiDe anywhere near release, it was of course irrelevant. I didn’t care much since I had no practical idea of what I was missing anyway. In Duality, calculating with an estimated development time of forever, I figured out it might be worth a try targeting .Net 4.0 right from start.

Read more …

Picking Colors

Have you ever used the .Net Color Picker Dialog? I did for a while but wasn’t quite content with it. For the Duality Editor, I don’t need any dialog-internal predefined colors and the additional clicks to define and choose a custom color reduce its usability. Also, there is no way to select a color with alpha channel support. After evaluating some other .Net ColorPicker modules out there, I decided to write my own. You can see the result on the right. If you need something similar, feel free to download its source code (Visual Studio Solution) and use it in your own project.

Read more …


There’s really nothing much to say about logging. I just thought, I’d share some code that might spare you some time writing it yourself. Basically a Log class. Create an instance for each separate Log type (e.g. Game, Core, Editor, …) and assign n ILogOutput instances to each of them. There are ILogOutput classes for System.Console or a TextWriter in general (any Stream).

Read more …