Matlus
Internet Technology & Software Engineering

Tagged With: CodeGen

C# to Html Syntax Highlighter using Roslyn

Ever since Roslyn was announced I’ve had a few ideas about what I’d want to do with Roslyn. Primarily there are two things I’d love to use Roslyn for:
  1. Code generation – Generating code in such a way that I would have more semantic information about the existing code and thus be able to generate code in a “smarter” way.
  2. C# to Html syntax highlighting – There are a few solutions out there but for one reason or another, I’m just not happy with them.
At the time of this writing the Roslyn project does not support attributes or partial methods[...]

Data Access Layer CodeGen

In an earlier article (DataReader Wrappers – Type Safe) I talked about using a DbDataReader wrapper class that allowed you to use a DbDataReader in a strongly typed way giving you the following additional benefit: The ability to use a DbDataReader as an IEnumerable<T>, giving is a performance advantage over other options because there is only ever one instance of the wrapper class created no matter how many records you've got[...]

DataReader Wrappers - TypeSafe

DataReaders (), in .NET give you the fastest access to your data. There is nothing that beats the speed of DataReaders. However, there are a few drawbacks to using them
  1. No Type Checking
  2. If field ordering or field name changes in your stored procedures or queries will likely break your code
  3. Code that uses DataReaders tends to be not so clear to read
Here is a example of what the typical code looks like: Lets say we have a blog item record that has the following fields: [...]

Razor Engine Host

The new Razor View Engine that is part of ASP.NET MVC 3 can be hosted outside of any Web related stuff. In other words, the Razor Engine is not dependent on IIS and can be sued in a non-Web application such as a GUI or console app. This makes a whole lot of things possible, since you can use the Razor syntax in any kind of template and generate some text output. This output could be a mail-merged text document or a code file that in turn is compiled into your application[...]