This page contains useful free cryptographic software code that David Ireland has written or adapted in Visual Basic and ANSI C. It's updated frequently, so keep checking.
Ramblings of a Software Engineer, Amusements of a Geek, Cacophony of a Guitarist, An Entropy Admirer's and an Interesting Character's Musings..
Thursday, 27 November 2008
Wednesday, 26 November 2008
Tools for everyday development
1. Process Explorer
2. Debug View
- Win32 OutputDebugString
- Kernel-mode DbgPrint
- All kernel-mode variants of DbgPrint implemented in Windows XP and Server 2003
- Works with C#, VB.Net languages. Supports all project types that ships with Visual Studio 2005 including web sites and web application projects.
- A preview window to show changes.
- Finds other instances of the text being replaced in the project automatically.
- Lists existing resources by their similarity level to the text being replaced.
- Automatically replaces hard coded string with a reference to resource entry.
FxCop
The Visual Studio Code Analysis Team Blog
StyleCop
Introducing StyleCop on legacy projects
Ghost Doc
Resource Refactor
Thursday, 20 November 2008
Unit Testing Silverlight Apps
Inarguably SL2 applications are a whole new experience of developing cross platform applications from managed code environments.
Unit Testing becomes very vital while developing for cross browser enterprise class applications. Visual Studio's tight integration of the Unit Testing framework is such an invaluable tool in the code production pipeline. Now, with the release of a unit testing framework for SL2 applications, the same experience can be leveraged. SL2 applications can be developed in a test driven fashion now. It perfectly suits an agile team. A team which is constantly driven by change and is delivering on a constant basis, almost every day in some cases. Much like a team which does not have a release model. (Check out Jeff Wilcox's blog). I guess the Silverlight test framework was itself developed using an agile methodology.
The SL Unit testing framework has proved to be an invaluable tool personally for me. It allows me to test SL applications on 3 different browsers (cheap guess if you are thinking which browsers ) even though i target IE mainly. :P. I'll write about it with a test application soon in my next blog. Till then, check out these links..
Some Links:
Silverlight Toolkit - You can find components like dockpanel, treeview etc for SL 2, themes and of course the source code for controls with unit tests and the unit test framework itself.
Jeff Wilcox - The guy who develops actively on the SL unit test framework at MS.
Scott Gu's small demo program on SL unit testing - (If you don't know this man, you are not worth living, jump off a building NOW!)
MS Silverlight Unit Test Framework - MS unit test framework for SL 2.
Wednesday, 19 November 2008
A Simple Multi-threaded Logger
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.IO;
namespace SudhirMurthy.Logger {
public interface ILog {
void LogToDisk(string msg);
}
interface ILoggerService {
ILog ILog {
get;
}
}
public class LogFile : ILog {
static List<string> messages;
//WriteToDisk delegate
private delegate void WriteToDisk(object sender, string fileName);
//WriteToDisk event
private static event WriteToDisk writeToDisk;
public static void WriteLog(string fileName) {
//Raise the event
writeToDisk(new object(), (fileName));
}
public void SendToDisk(object sender, string fileName) {
StreamWriter sw = File.CreateText(fileName);
foreach (string s in messages) {
sw.WriteLine(s);
}
sw.Close();
}
public LogFile() {
messages = new List<string>();
WriteToDisk mydelegate = new WriteToDisk(SendToDisk);
writeToDisk = new WriteToDisk(SendToDisk);
}
public List<string> Messages {
get {
return messages;
}
}
#region ILog Members
public void LogToDisk(string msg) {
Monitor.Enter(this);
messages.Add(msg);
Monitor.Exit(this);
}
#endregion
}
public class LoggerService : ILoggerService {
//TODO: Need to make it threadsafe..
private static ILog logInstance = null;
public LoggerService() {
logInstance = new LogFile();
}
#region ILoggerService Members
public ILog ILog {
get {
return logInstance;
}
}
#endregion
}
public class LoggerClient1 {
LoggerService logService;
public LoggerClient1() {
logService = new LoggerService();
}
public void Log() {
logService.ILog.LogToDisk(string.Format(
"I am Logging: {0}", this.ToString()));
}
}
public class LoggerClient2 {
LoggerService logService;
public LoggerClient2() {
logService = new LoggerService();
}
public void Log() {
logService.ILog.LogToDisk(string.Format(
"I am Logging: {0}", this.ToString()));
}
}
public class TestApp {
LoggerClient1 a;
LoggerClient2 b;
public TestApp() {
a = new LoggerClient1();
b = new LoggerClient2();
}
public void logClient1() {
for (int i = 0; i < 1000000; i++) {
a.Log();
}
}
public void logClient2() {
for (int i = 0; i < 1000000; i++) {
b.Log();
}
}
}
class Program {
static void Main(string[] args) {
TestApp app = new TestApp();
Thread t1 = new Thread(new ThreadStart(app.logClient1));
Thread t2 = new Thread(new ThreadStart(app.logClient2));
try {
t1.Start();
t2.Start();
} catch (Exception) {
throw;
}
t1.Join();
t2.Join();
//The main thread should technically wait until
//t1 and t2 should have finished and then execute
//the following
LogFile.WriteLog("log.txt");
}
}
}
If you try removing the Monitor.Enter(this) and Monitor.Exit(this) lines from the above code, you end up getting weird line numbers in your log.txt file. (enable line no's in visual studio and see log.txt). i.e the count of the log will never be as expected (2 million in the above case). By putting the above lines back, you get the expected value which is 2million lines of log. :). It takes about 5-6 seconds on my dual core for threads t1 and t2 to finish logging and the main thread to write to disk. :). A bloated 93.4 MB file!!
My thread on MSDN Forums.