onsdag, augusti 13, 2008

PDC and TestAutomationFx


Great, I'm going to PDC this fall :o)
BTW, the user interface toolkit integrated in Visual Studio that I mentioned before, is now released, TestAutomationFx, test it.

lördag, maj 17, 2008

NUnit runners with memory leak, and the solution

I found amazingly few references to people having problem with the NUnit test runners. We came to a point where the the NUnit test runners consumed over one gigabyte of memory and the same tests run from Resharpers test runner from inside Visual Studio would only consume about 250 megabyte of memory. I also found that the memory was not released between assemblies if you run a NUnit project file with multiple assemblies.

The problem was that a reference to each TestFixture decorated class was kept in the result even if it was unnecessary. Or to be more specific, the Fixture part of the result released it's reference to the tested Fixture class after TestFixtureTearDown, but the TestMethod in the result kept a reference to the very same Fixture...To find out about this I used a nice memory profiler, SciTech's .NET Memory Profiler

I posted a patch to the NUnit project on SourceForge. With this patch the nunit-console test runner use about the same amount of memory as the Resharper one, and I suppose this would be the case for the GUI one too, since this was a change in the core.

måndag, februari 25, 2008

Nice, smart and simple GUI testing

If you would like to test your windows GUI, try this Test Automation Fx.
You will get a new project in Visual Studio 2005 and 2008 and a designer to create your test project.
Then you record some clicks in your application to test. The designer generates C# or VB.NET code.
You can run the test to verify that your application behaves ;o)
It's nice that the output is .NET code so we can make adjustment if we need to. And even better, the recorded clicks doesn't only use stupid coordinates, but it identifies and finds buttons by name :o) So it could handle some changes without breaking the tests.
It works for both native and .NET applications.
It's a beta, but definitely worth looking at.

tisdag, januari 08, 2008

The old find in files error

Sometimes when I try FindInFiles in Visual Studio, I can get this error:
"No files were found to look in.Find was stopped in progress." in Visual Studio 2003, 2005 and now also in 2008
...the solution is to press Control + Scroll Lock.

I used to believe VisualAssist had something to do with it, but in VS 2008 I only use ReSharper, so I suppose Visual Studio itself is the problem?

onsdag, november 07, 2007

Switch between VS 2005 and VS 2008

I have made two small scripts that make it possible to develop using Visual Studio 2008 Beta 2 in a group using Visual Studio 2005.
And I'm sure these scrips could be very usefull if you want to make some other batch search replace on some files.

Surely my scrips don't cover all solution files but I'm sure you could modify them to cover your solutions.
As a base I use RxFind a regular expression search and replace, command line tool I found at CodePlex. To make it more usefull for this case I made a couple of small modifications.
I added the possiblity to take the search and replace expressions from an input file. This makes it easier to handle line breaks and "-characters in the expressions. When you avoid a few of the escape characters, it is much easier to read.

Use it like this.
  • Modify the file name and path in the first rows of the batch files.
  • Open your Visual Studio 2005 solution that should be under version control., in Visual Studio 2008 (Beta 2)
  • Let the conversion wizard do it's job.
  • Let your version control system show which files where modified
  • Try to run: "first time to2005.bat"
  • In the ideal world the solution should now not contain any modifications and it should be possible to open it in VS 2005 like before.
  • Run to2008.bat, it should now be possible to open the solution in VS 2008.
  • Run to2005.bat, if there are some modifications you want to commit, do so.
Runing this back and forth, I found a few small changes that I wanted to do in the project files. Changes that should be there in both the 2005 and the 2008 version of the files.

* If my script and your modifications work you should be able to work like this, using subversion/cvs terminology:

10 Checkout
15 run to2008.bat
20 Use the project in VS 2008
30 Make updates and so on
40 Run to2005.bat build and run the tests (I do this from the command line)
50 commit
60 Goto 15 ;o)

BTW The script are made for C# but could probably be modified for VB very easily, if there are some real VB-hacker out there...
If you have spaces in your solution file name or in the path where you put your tool, you would have to add a few "" in the batch file, but since i didn't need it. I leave it as an exercise for the reader.
One of the benefits I get out of this is that I can avoid conflicts between my favorite VS add in for C++(Visual Assist) which I use in VS 2005 and my favorite/current VS add in for C# (ReSharper) that I use in VS 2008.

Download scripts

Download updated source for RxFind

lördag, oktober 06, 2007

Silverlight

I rebuilt my CCTray for XPS with the latest code from subversion so now it works connecting through .NET remoting (original CCTray). It should use much less of the continous integration server resources than if you and all of you co-developers connect through http. Uppdate: New .NET XPS LightFX SDK

And I would like to mention that me and Truls will hold a Silverlight seminar in Göteborg, Linköping and Stockholm November 8 and 9. We have already done it twice in Malmö. See Dotway.se for more info.

And BTW don't miss Øredev

onsdag, maj 23, 2007

Update for CCTray for XPS

I found a little bug in the last version of my CCTray version for XPS. The LEDs were shut off during build. So I updated the files. You can download them from the same place:New .NET XPS LightFX SDK

fredag, maj 18, 2007

New .NET XPS LightFX SDK

Dell has released a new version of their XPS LightFX SDK. This version includes different dll's for Windows XP / Vista and their 32- and 64-bit versions. I have improved my managed wrapper, to support not only the SetEffect function, but also SetLEDSettings. I didn't care about backward compatibility, but changed the way you use the wrapper to be more simple.

This XPS thing is a Dell laptop model, I use a XPS M1710.

If you run the LedsExample program please copy the correct version of GamingSDK.dll to the folder, I added the Vista 32-bit version.

Download my wrapper: .NET XPS LightFX SDK

I made a simple hard coded version of CCTray(binary), which shows the summary build status on the XPS LED's. My XPS for CCTray patch(source)

Howto use the managed wrapper:
using Björn.Carlsson.XPSLeds;
namespace Leds
{
public partial class Form1 : Form
{
XPSLeds m_XPSLeds;
LED_USER_SETTINGS m_Settings;

public Form1()
{
InitializeComponent();
m_XPSLeds = new XPSLeds();
FormClosing += Form1_FormClosing;
}

void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
m_XPSLeds.Close();
}


private void btnSet_Click(object sender, EventArgs e)
{
m_Settings.Intensity = LED_INTENSITY.MAX;
m_Settings.Zone1 = LED_COLOR.KUNZITE;
m_Settings.Zone2 = LED_COLOR.PERIDOT;
m_Settings.Zone3 = LED_COLOR.TANZANITE;
m_Settings.ColorTouchPad = LED_COLOR_TOUCHPAD.RUBY;

m_XPSLeds.SetLEDSettings(m_Settings, false);
}
}

söndag, maj 06, 2007

Mono - Silverlight

I have signed up to two Google groups and one mail list today, with the intent to join the development of a Mono version of Silverlight with the cool name: Moonlight.

For a "Windows developer" like myself it would feel much more familiar to start develop a web application using what I call Silverlight .NET (Silverlight 1.1 Alpha with a CLR), than to use the more traditional web application frameworks. It's more or less just like building a WPF application. You even have isolated storage.

Why should I contribute to the Moonlight development:
  • I really like the WPF design,
  • The world needs Silverlight for Linux.
  • I am curios to, how the collaboration in such an ambitious open source project as Mono works.
  • What better way to really learn the fundamentals of WPF?
BTW: I just love one idea from the Silverlight team, which would also be great in Compact Framework: Pay for play: They build a small core, with everything unnecessary stripped out, and if you miss something, you should be able to add it, and pay the price. So you don't have to yell out: WHY DID THEY STRIPP THAT OUT!

måndag, april 30, 2007

Mindblowing at MIX07 - Silverlight .NET

Today Microsoft releases Silverlight 1.1 Alpha with a full CLR inside the browser, cross platform. They also releases a open source version of Ruby called IronRuby, should be released at Codeplex. But I have not found it yet. Scott also promised Silverlight for Mobile devices. Downloads and stuff at: silverlight.net

fredag, april 06, 2007

Partition and Burn

I was about to shrink my old XP partition. And I have read about a free partitioning program GPartedLiveCD, but first I confused it with GNU Parted the difference is that GParted adds a GUI.
There are instructions to boot GParted from an USB stick, but that didn't work at the first try. And I didn't want to spend hours rebooting to get it working. So I decided to make a LiveCD instead. I have not installed any CD burning program in Vista, since the operating system should be able to handle it on it's own. But how to burn an iso image?
I found a really small and nice download (378 kB) - ISO Recorder.
That adds a context menu command for ISO files that starts a simple wizard too burn the image.

Since the partition I shrunk, was the startup one, I was not suprised when I had to put in the installation disk to make a repair to make Vista boot again. I did physically move the Vista partition. And after the quick repair of the boot info, it worked fine.

måndag, mars 26, 2007

Office eller OpenOffice

Att nu leva utan Office? Försöker ju använda det så lite som möjligt, så det borde väl inte vara så svårt? Installerade OpenOffice igår och avinstallerade Office 2007 idag. Redan innan jag avinstallerade Office, började jag känna av lite problem. Satt på ett möte och diskuterade ett Word-dokument, jag hade öppnat det i OpenOffice - det visades ganska ok. Men någon av sidorna blev något längre, så jag hade inte samma radbrytning som de andra. De hänvisade till en sida och jag satt och bläddrade lite desperat fram och tillbaka.
Men på eftermiddagen råkade någon på .NET Rocks! nämna viewers för Office-dokument, inget nytt, men jag hade inte tänkt på dem.
Så nu har jag installerat:
Trevligt små nätta applikationer om man jämför med en stor officeinstallation. Och med FileFormatConvertern för 2007-formaten, så känner jag mig mer redo än de flesta "vanliga" Officeanvändare att ta mig an de flesta dokument som folk kan tänkas attackera mig med.
Min egen produktion i dokumentväg blir ju förstås ifrån OpenOffice och kanske i de flesta fallen som PDF:er för bästa möjliga flyttbarhet. PDF:er som givetvis bör läsas med Foxit-reader så mycket snabbare än orginalbesten. Men ett problem kvarstår, kunden jag jobbar åt använder Microsoft Exchange Server, och vad jag har lyckats hitta, så finns det bara ett alternativ till Outlook här, och det är Novell Evolution. Evolution är fämst avsett för Linux men finns även för Windows. Men än så länge bara för XP. Och pigg på att installera som jag är, så kör jag givetvis Vista sen länge.

söndag, januari 28, 2007

PowerShellProvider

Jag har nu skapat en PowerShellProvider. Man skulle kunna jämföra det med ett virtuellt filsystem för PowerShell. Redan från början innehåller PowerShell ett antal providers:
PS F:\/> Get-PSProvider

Name Drives
---- ------
Alias {Alias}
Environment {Env}
FileSystem {C, E, F, D...}
Function {Function}
Registry {HKLM, HKCU}
Variable {Variable}
Certificate {cert}

Som t.ex. Registry innehåller ju då naturligtvis registret, och man kan då komma åt registret med samma kommando som man är van att använda på filsystemet. Dir för att visa innehållet, cd för att navigera i strukturen mm. Dir t.ex. är ett alias för cmdlet:en Get-ChildItem och cd är ett alias för Set-Location.

Jag skapade MyProvider som ärvde av NavigationCmdletProvider, överlagrade följande funktioner:
  • InitializeDefaultDrives
  • NormalizeRelativePath
  • GetChildItems
  • IsItemContainer
  • GetItem
Jag hade då skapat ett standard interface in mot applikationen.
Kunde navigera bland applikationens objekt med cd och titta på dem med dir. Jag kan tilldela ett av applikationens objekt till en PowerShell-variabel och komma åt värden på t.ex. Properties.
Jag läste sedan om PowerGadgets, en samling datavisualiseringskomponenter, som visarinstrument, diagram o.dyl. och plötsligt kunde jag enkelt visa egenskaper i mitt program med standardkomponenter. Dessutom kan jag naturligtvis skriva skript som interagerar med mitt program.

Jag gjorde följande:
cd MyProvider:
$s = Get-Item "Server 1/System/Time/Second"
$s.Attributes[3].ClrValue | Out-Gauge

Out-Gauge är en cmdlet i PowerGadgets som nu visade värdet av en property i objektet Second. Det fjärde attributet (
Attributes[3]) som råkar vara aktuell sekund uvarande minut.

Där finns mer att göra, implementera kopiering, radering, skapa nya objekt. Men inte heller det verkar vara mycket jobb. Mer om hur man skapar interface mot PowerShell

En intressant artikel om datadrivna tester med Excel och PowerShell

söndag, januari 14, 2007

Kompakta databaser i .NET

Till sist kom jag till skott med att testa SQLite. System.Data.SQLite var en trevlig bekanskap. Det är en ADO .NET 2.0 databasprovider för SQLite, med själva SQLitemotorn inbyggd. Man har tagit C-källkoden från standard SQLite och byggt med den i assemblyt. Den kommer i versioner för ARM processorer - dvs Compact Framework - Itanium, X64 och den gamla hederliga x86.
Jag roade mig med att jämföra lagringsutrymmet som krävdes för en SQLite-databas och en motsvarande för SQL Server 2005 Compact, utrymmesmässigt vann SQLite.
Jag har utökat mina magra SQLkunskaper lite de senaste dagarna, men jag är fortfarande en nybörjare på området.
Jag hade en tabell med tre kolumner:
CREATE TABLE TestTable (Id INTEGER PRIMARY KEY AUTOINCREMENT, Time DATETIME, Value BIGINT)
Tabellen för
SQL Server 2005 Compact skapade jag med designern i VS 2005 och sen försökte jag göra samma sak med kod för SQLite. Jag fick fram en tabell, men det visade sig att SQLite inte hade en egentlig kolumntyp för DateTime, men det kan hanteras, och BIGINT bluffade den lite med också.
Jag antog att detta skulle ta åtminstone 4 + 8 + 8 byte. För SQLite tog det ca 22 byte per record och för SQL Server 2005 Compact tog det mellan 29 och 45 byte per record, beroende på vilka properties jag valde på id-kolumnen, om den skulle vara unik, identity etc. Jag körde testet på min bärbara i Vista, och första testet att lägga in 100 000 rader med standardinställningar och utan transaktioner, då var SQL Server 2005 Compact 100-tals gånger snabbare.
Det gjorde mig lite orolig. Men eftersom jag den här gången var ute efter en utrymmessnål databas som dessutom kunde användas i Linux, så gick mina tester vidare med enbart SQLite, och genom att gruppera mina inserts i transaktioner och på så sätt ge databasen tillåtelse att inte skriva varje ändring direkt till disk så blev mina testprestanda även med SQLite 100-tals gånger bättre. Jag tror att jag skapade 100 000 rader jag skapade vid det tillfället, men utan transaktioner tog det ca 14 minuter och med tog det bara några få sekunder.

Jag lärde mig även att SQLite är en lite annorlunda databas, som kan tillåta att man lagrar olika typer av data i samma kolumn. Den har bara följande lagringstyper:

  • NULL.
  • INTEGER. lagras i 1 till 8 byte beroende på storleken på talet.
  • REAL. flyttal 8-byte IEEE.
  • TEXT. Textsträng, lagring enligt inställning för databasen (UTF-8, UTF-16BE or UTF-16-LE). Jag rekommenderar UTF-8.
  • BLOB.

Detta var ju lite av förklaringen till varför SQLite var så snål i jämförelse med SQL Server 2005 Compact, eftersom många av mina testvärden var små heltal, Den senare jobbar förmodligen med fasta storlekar på fälten. Och det bör kunna ge bättre prestanda vid uppdateringar antar jag.
Kolumnerna i SQLite kan sedan vara av typen:
  • TEXT
  • NUMERIC
  • INTEGER
  • REAL
  • NONE
Om man väljer Numeric så försöker databasmotorn först att tolka värdet som en int eller real, om inte det går så lagras värdet som text. Med None är tolkningen ännu mer liberal den gör så gott den kan även när det gäller NULL- och BLOB-värden. Jag testade att lagra heltal, flyttal och text i samma kolumn. Det fungerade men Query Analyzern SQLiteQA3 blev lite förvirrad. Om första raden i tabellen innehöll ett heltal, så försökte den tolka övriga rader som heltal också. Vilket omvandlade "Kalle Kula" till en simpel nolla :o)
men följande kod fick jag ut de rätta värdena:

m_Cmd.CommandText = String.Format("SELECT Id, Value FROM [{0}]", TrendName);
SQLiteDataReader reader = m_Cmd.ExecuteReader();
while (reader.Read())
{
object id = reader.GetValue(0);
object value = reader.GetValue(1);
Console.WriteLine(id.ToString() + value.ToString());
}
m_Connection.Close();
Jag ändrade föresten min tabellskaparkod till:
m_Cmd.CommandText = String.Format("CREATE TABLE {0} (Id INTEGER PRIMARY KEY, Time INTEGER, Value NONE)", TrendName);
Sen skapade jag en trigger för att begränsa storleken på mina tabeller, men det får jag skriva om en annan dag.
Det är trevligt att Microsoft lyssnade på sina kunder och gav oss rätten att distribuera SQL Server 2005 Compact, så att man kan använda samma databaskod i sin desktopapplikation som i den tillhörande Compact Frameworklösningen, detta och möjligheten att installera med click once, är ju möjligheter som gäller för båda de nämnda databaserna. Det finns mycket mer att säga. Det finns uppenbara fördelar med båda databaserna, men nu börjar mina ögonlock att bli tunga. Så är det någon som undrar mer om det så skriv en kommentar. Godnatt.


torsdag, november 09, 2006

All Sysinternals tools in one download

Life has become a bit easier.
All the tools from Sysinternals in a single download. Sysinternals Suite
all of their wonderful tools in a 8 MB download. And this includes 68 executables, help files and some other files.

onsdag, november 08, 2006

XPS LightFX SDK under Vista

I tried to install and test XPS LightFX SDK under Vista RC2. First nothing happened, no flashing leds, but after installing Dell QuickSet Application (you have to run the installation in Windows XP sp2 compatibility mode), then my .NET wrapper for this SDK works on Vista too. :o)

The new tool from Sysinternals is released

Sysinternals / Microsoft have finally released Process Monitor which has the functionallity from the old Filemon and Regmon and adds a lot of nice features.
Perhaps the best improvement is non-destructive filters. So you can play around testing different filter settings, whithout destroying the log.
I just made a quick test, but it was nice. What are your system doing? Run process monitor, and it shows all registry and file activity...

tisdag, oktober 24, 2006

.NET XPS LightFX SDK

Now I have created a first version of a .NET wrapper for the XPS LightFX SDK from Dell. And it does work a lot better than the C++ sample Delll shipped with the SDK. I don't know if Dell offers any way to contribute to their source code. If they do I have made their C++ sample more robust too. :)
The code includes a simple sample, but you do need a XPS M1710 or XPS M170.
I have only tested with XPS M1710 on XP, please report any problems. This version only supports one of the two ways to control the LEDs, the sequence read from XML file. Not the direct control. But hopefully I will find some time to implement the rest also. But otherwise you are welcome to help.

Here you have my XPSLeds Download, have fun!

måndag, oktober 23, 2006

Driver Verifier

Tittade på några av Mark Russinovich (ny blogadress)- Sysinternals framträdande på Tech Ed tidigare i år - i går. Man undrar ju var Process Monitor blir av. Vid framträdandet i juni sa Mark att det skulle släppas om ett par veckor. Men tyvärr har väl affären med Microsoft bromsat processen. Jag hoppas iallafall att den kommer så småningom. Process Monitor skulle alltså vara en kombination av Filemon och Regmon och lite till. Jag lärde mig ett och annat, man kan spara vilka program som autostartas i Autoruns. Det kan vara bra att göra innan man installerar ett program. Man kan sen jämföra före och efter, och de nya raderna blir gröna. Man kan dessutom göra samma sak utan att spara genom att ha Autorun startat under installatioonen och sen bara uppdatera vyn med F5.

Hur många känner till det inbyggda Microsoft verktyget Driver Verifier (system32\Verifier.exe)?

Om man installerar eller för all del själv utvecklar en driver, så kan man med Driver Verifier göra inställningar så att drivern kontrolleras hårdare. Det ger sämre prestanda, och blåskärm såfort drivern gör något otillåtet. Men alternativet kan vara att drivern lyckas skriva sönder minnet för en annan driver, som sen felaktigt kan få skulden för kraschen. Mark rekommenderar att man väljer alla inställningar utom Low resource simulation. Efter blåskärmen får man analysera kraschen med WinDbg....
Idag råkade jag snbbla över XPS LightFX SDK , så nu ska jag börja leka med dioderna på min Dell XPS M1710.
Det blir förmodligen en .NET applikation kanske en extension till Mediaspelaren eller en blinkande indikering när jag har fått mejl. Någon som har en bra idé?