OpenSource CSV Reader on Nuget

I did some volunteer work a few years ago that required processing lots of CSV files. So I solved the problems by writing a C# CSV reader, which I wanted to share here. The basic features here are: be easy to use read and write CSV files (and support tab and “|” delimiters too) create…

5

RTS Battle simulation with IronPython

I used Python to simulate Age of Empires archer battles.  I wanted to be able to answer questions like: If 12 archers attack 10 archers, what will the margin of victory be? If two armies of the same size attack each other, how do different strategies affect the outcome? This also led to some practical…

7

Why is System.Diagnostic.Debugger class compiled in retail?

There’s a good reason that methods on a “System.Diagnostics.Debugger” class are still compiled in retail builds, although this occasionally surprises folks. Here’s why…   Background: The System.Diagnostics.Debugger class provides some useful low-level debugging APIs such as: Debugger.Break() – causes the app to break under the debugger when executed. This is used for VB’s “Stop” statement…

0

Paradigms around Debugging Memory leaks

In native code, memory is explicitly managed by the program calling Malloc()/Free() (or comparable APIs). In managed code, there’s a garbage collector (GC). A GC does not mean that you no longer get memory leaks. It just means that runtime calls Free() for you at some arbitrary point after the runtime detects that the object…

2

Foreach codegen

Do you know how the following C# code compiles? foreach (int i in c) { Console.WriteLine(i); }   In addition to the obvious branching opcodes, this can also emit try/finally, a call to IDisposable, unboxing opcodes.   It turns out it really depends on the type of C. There are 4 interesting cases: If C…

5

Setting transparency in an image

Just as Jackie Chan does his own stunts; I do my own image drawing. Some of my “art”:   (The yellow arrow here). The shapes in my Silverlight 1.1 app: The astute observer probably noticed that all of my work is very primitive and done in MS Paint (yup, “%windir%\system32\mspaint.exe”) . Paint is fast. It’s…

7

Building and Debugging Powershell cmdlets in the VS IDE

Here’s how you can get a sweet Visual Studio development experience for building and debugging your own PowerShell cmdlet:– It has Wizard support for initially creating the cmdlet, – intellisense– F5 build support which also registers your cmdlet– provides the full power of the VS debugger including Edit-and-Continue when debugging your cmdlets. David Aikens has…

9

Some tips for P/invoke

Here are some tips I’ve learned the hard way after wrapping some nasty things into managed code (including wrappers for the native debugging API and reading minidumps): Use resources like Pinvoke.net and Fxcop (which may have some useful marshalling checking rules).   Beware of 32-bit vs. 64-bit. One thing I note is that http://pinvoke.net has a…

2