Liskovs Substitution Violation in the real world

I was creating an integration between my own users table (or document since I use RavenDB) with the membershipprovider in ASP.NET. I’m using the default SQL provider.

When doing so I noticed that my code was failing all the time in the register action in the account controller (ASP.NET MVC3). The error message saying “An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator“.

var user = _userRepository.Create(model.UserName, model.Email, model.DisplayName);
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, user.Id, out createStatus);

User.Id is a string. I took a look at the createStatus which is returned from CreateUser and it said InvalidProviderUserKey. MSDN did not help to discover why the error was returned (no indication for the enum value nor in the CreateUser documentation).

So I started to google after implementations of the SqlMembershipProvider. The first one that I found was the one in Mono. It had the following logic:

if (providerUserKey != null && ! (providerUserKey is Guid)) {
    status = MembershipCreateStatus.InvalidProviderUserKey;
    return null;
}

Why the (s)hell did they do that?” was my first though. A clear violation of LSP since the contract says object and all they support is a simple Guid. Come on. At least support string.

So I started to search for the MS implementation and found the sample provider in MSDN: http://msdn.microsoft.com/en-us/library/6tc47t75.aspx

So the design decision was Microsofts own. Next time, please document “features” like that.