Monatsarchiv für Dezember 2008
Programming quotes
Dienstag, den 30. Dezember 2008I discovered a cool web page which has a collection of programming quotes on it. You’ll find there quote diamonds like the following:
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”
- Brian Kernighan
or
“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”
- Bjarne Stroustrup
http://www.hackification.com/2008/12/23/a-double-handful-of-programming-quotes/
Pictures of the war in Afghanistan
Dienstag, den 23. Dezember 2008I stumbled over a set of pictures which shows the US and allied troops in Afghanistan. The webpage I found shows a photo collection of coalition troops over the course of the last seven years in the country. I think the pictures are quite impressiv!
PartCover Integration in CruiseControl
Montag, den 22. Dezember 2008Some time ago we were moving from ncover to partcover because ncover is now a commercial product and also we had a lot of problems on our cruise control server. Here are the scripts and also transformations that I made to make the partcover report look like the ncover report. This is presented without much explanation. Contact me if you have any questions.
NAnt Buildscript
<property name="partcover.exe" value="C:/Program Files/Gubka Bob/PartCover .NET 2/PartCover.exe" /> <target name="coverage" description="compute coverage statistics for all unit tests defined in project.nunit" depends="create-nunit"> <property name="date" value="${datetime::now()}" /> <property name="acceptable" value="75" /> <mkdir dir="${results.dir}" unless="${directory::exists(results.dir)}" /> <exec program="${partcover.exe}" failonerror="true"> <arg value="--target=${nunit.exe}" /> <arg value="--target-work-dir=${project.dir}" /> <arg value="--target-args=project.nunit /exclude:${unit_test_exclusions}" /> <arg value="--include=[Project.*]*" /> <arg value="--exclude=[*Test*]*" /> <arg value="--exclude=[*Other]*" /> <arg value="--output=${results.dir}/project.coverage.xml" /> </exec> <style style="..\path\PartCover-NCover-Like.report.xslt" in="${results.dir}/project.coverage.xml" out="${results.dir}/coverage-report.html"> <parameters> <parameter name="DateTime" namespaceuri="" value="${date}" /> <parameter name="ProjectName" namespaceuri="" value="${project.name}" /> <parameter name="Acceptable" namespaceuri="" value="${acceptable}" /> </parameters> </style> <!-- This generates the extension data which is needed for cruise control, the attribute "in" is just used for validation reason --> <style style="..\path\PartCover-Extension.xslt" in="${results.dir}/project.coverage.xml" out="${results.dir}/project.coverage.ext.xml"> <parameters> <parameter name="DateTime" namespaceuri="" value="${date}" /> <parameter name="ProjectName" namespaceuri="" value="${project.name}" /> <parameter name="Acceptable" namespaceuri="" value="${acceptable}" /> </parameters> </style> </target>
Download
The Simpsons and their apple parody
Donnerstag, den 11. Dezember 2008This is one piece of a cool video. Check it out:
JetBrains released TeamCity 4.0
Samstag, den 6. Dezember 2008JetBrains (the once who also developed the fabulous product ReSharper) released a new version of their distributed build management and continuous integration server. I have never had the possibility to test this integration server but it seems to me a fairly cool product. Especially the web interface is a lot more advanced than cruisecontrol.net.
The professional and opensource version is free of charge. Here is the licensing overview:
http://www.jetbrains.com/teamcity/buy/index.jsp
You can check out installation videos and live demos on this site:
http://www.jetbrains.com/teamcity/documentation/index.html
Fastest build feedback in the industry
Adaptive tests re-ordering, on-the-fly test results reporting, configurable notifications, and even making build artifacts accessible before the build is ready — TeamCity keeps you in the know with the most recent build updates and intermediate results, and shows how well your changes integrate into the project sooner. Learn more about TeamCity Continuous Integration.
Faster builds, better scalability — with grid computing
Distributed build management helps optimize your hardware resources utilization by parallelizing product builds within the build agents grid. With build chains support, you can even break down a single build procedure into several parts to run them on different build agents — both in sequence and in parallel — using the same set of sources in all of them. Learn about TeamCity Build Grid.
Clean and error-free code base
TeamCity automates over 600 Java code inspections, code coverage and duplicates search — out of the box. It also builds, checks and runs automated tests on the server even before committing your changes — keeping your code base clean at all times. Learn more about Pre-tested Commit.
First-rate control over large-scale environments
Administer your large-scale build infrastructure from a central Web 2.0 interface. Monitor your team performance and track responsibilities. Easily manage all your builds and hardware resources with detailed statistics and trends reports. Quickly add more build agents, when needed. Learn more about Build Management and Administration.
Easy setup and adoption
TeamCity is at home everywhere. It supports both Java and .NET development. Setup is quick and easy under any platform, and offers out of the box integration with the most popular IDEs, build tools, testing frameworks and version control systems. Installation is a breeze — only 3 minutes from free download to a fully deployed and functional server.
Extensibility
TeamCity encourages improvements by providing Java API for all sorts of user modifications, from integration with other version control systems and build tools, to creating specific Web UI elements and custom reports. Learn more about developing TeamCity plugins.
Linq to SQL is announced dead…
Mittwoch, den 3. Dezember 2008Now it’s almost official:
[...]
We’re making significant investments in the Entity Framework such that as of .NET 4.0 the Entity Framework will be our recommended data access solution for LINQ to relational scenarios. We are listening to customers regarding LINQ to SQL and will continue to evolve the product based on feedback we receive from the community as well.
Tim Mallalieu
Program Manager, LINQ to SQL and Entity Framework
ConfigurationSectionHandler the easy way
Montag, den 1. Dezember 2008Have you ever had the need to develop your own configuration section handler for application configuration files (app.config) in C#. Everybody that has been doing this lately knows how tedious this can be. But there is a quick and easy way to implement simple configuration section handlers in C#. This post shows you how…
Sample
In the sample we are going to implement a simple configuration section handler which will input an enumeration and a simple string constant. I quickly define the interface:
1 2 3 4 5 6 7 | public interface ITracelightConfigurationSectionHandler : IConfigurationSectionHandler { LanguageEnumeration Language { get; } string SomeInput { get; } } |
And the enumeration. Now here comes the first trick into the play. We are going to define our enumeration as a DataContract with the DataContractAttribute from the System.Runtime.Serialization namespace. Every enumeration member that we want to be able to serialize must be marked with the EnumMemberAttribute. This allows us later to transparently deserialize the enumeration from the application configuration file.
1 2 3 4 5 6 7 8 9 | using System.Runtime.Serialization; [DataContract] public enum LanguageEnumeration { [EnumMember] German, [EnumMember] English, } |
Next we need the concrete class which implements our configuration section handler interface. The class itself are we going to mark as DataContract with the DataContractAttribute. Important here is the Namspace property in the DataContractAttribute must be set to “” (see Line 7). In the Create Method from the IConfigurationSectionHandler interface we are going to use the DataContractSerializer and instantiate it with our concrete class (which implements the ITracelightConfigurationSectionHandler interface). In Line 19 we specify that we want to read the object out of the serializer and must also specify false as second parameter (this surpresses name checking while deserialization). Then we can read the properties out of the configSection instance. Set it on the properties on the instance and return a reference to ourself (this). And we are done!
You only have to remember to set the DataMemberAttribute on every property you want to serialize or deserialize. With the datamember property you can also define how the name looks like in the configuration. If you don’t define a name, the configuration file section must be exactly named as the property.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | ... using System.Configuration; using System.Runtime.Serialization; using System.Xml; ... [DataContract(Namespace = "")] public class TracelightConfigurationSectionHandler : ITracelightConfigurationSectionHandler { // From IConfigurationSectionHandler public object Create(object parent, object configContext, XmlNode section) { var xs = new DataContractSerializer(typeof(TracelightConfigurationSectionHandler )); XmlNodeReader xnr = new XmlNodeReader(section); try { var configSection = xs.ReadObject(xnr, false) as TracelightConfigurationSectionHandler; if (configSection != null) { Language = configSection.Language; SomeInput= configSection.SomeInput; } return this; } catch (Exception ex) { string s = ex.Message; Exception iex = ex.InnerException; while (iex != null) { s += "; " + iex.Message; iex = iex.InnerException; } throw new ConfigurationErrorsException( "Unable to deserialize an object of type \'" + GetType().FullName + "\' from the <" + section.Name + "> configuration section: " + s, ex, section); } } // Automatic property for the language [DataMember(Name = "language", Order = 1)] public LanguageEnumeration Language { get; private set; } // Automatic property for the input, which can be omitted. [DataMember(Name = "input", Order = 2, IsRequired = false)] public string SomeInput { get; private set; } } |
And how looks the App.config file?
<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="tracelightsection" type="Fully.Qualified.Namespace.TracelightConfigurationSectionHandler, MyAssemblyNameWithoutDllExtension"/> </configSections> <tracelightsection> <language>German</language> <input>SomeTextualInput</title> </tracelightsection> </configuration>
And how can the data be read from the configuration file? That’s pretty easy…
var configSection = (ITracelightConfigurationSectionHandler)ConfigurationManager.GetSection("tracelightsection");
This works even with complex collections. All you need to now is how to handle the data with the DataContractSerializer. But this is fearly simple to learn.
Remarks:
When you see strange behaviour such as the data is not deserialized althoug set in the configuration file you need to specify the order property (especially if you are using non required properties or default values with EmitDefaultValue…).

