So, this morning I began laying down a DAL against a massive legacy database and came face-to-face with bug that I'd been in denial about for some time:
Inflector.ToPascalCase() doesn't work.
This really isn't a surprise, as Phil Haack had annotated it back in February with the following unambiguous comment:
//TODO: What is this supposed to do? It doesn't convert "This Is My Word" to "ThisIsMyWord" -P.H. 2007.02.16
Phil is absolutely correct. But this creates an ugly dilemma: It doesn't do what it's supposed to do currently, but making it work the way it should could break a lot of applications. Let's talk specifics:
This method is designed to perform name transformations for cases where a table or column name is comprised of multiple words, separated by underscores or spaces. By convention, all generated property and class names are passed through this transformation. While the space do ultimately get removed downstream by other methods, the fact that they aren't done within this method means that casing is never handled the way it should be.
A few examples:
| Table Name |
Remove Underscores? |
The way it works now |
The way it should work |
| order history |
false |
Order history |
OrderHistory |
| order history |
true |
Order history |
OrderHistory |
| order_history |
false |
Order_history |
Order_History (?) |
| order_history |
true |
OrderHistory |
OrderHistory |
| Order_History |
false |
Order_History |
Order_History |
| Order_History |
true |
OrderHistory |
OrderHistory |
| ORDER_HISTORY |
false |
ORDER_HISTORY |
Order_History |
| ORDER_HISTORY |
true |
ORDERHISTORY |
OrderHistory |
| ORDERHISTORY |
false |
ORDERHISTORY |
Orderhistory |
| ORDERHISTORY |
true |
ORDERHISTORY |
Orderhistory |
| orderhistory |
false |
Orderhistory |
Orderhistory |
| orderhistory |
true |
Orderhistory |
Orderhistory |
So you can see the problem. I'd love your feedback on this one. Can we all collectively bite the bullet on this one and make a one time correction? Or is the sinking feeling in my stomach that we're going need a configuration option to support "legacy behavior" well founded?