Running FxCop on VB.net can be very annoying
I built a very small application which only shows information from a table in a standard DataGrid. Nothing special, other than I had to do it in VB.Net 1.1. I have just finished testing it, and am now running FxCop on the code to see what problems I still have to fix before checking it into source safe.
The code contains a DataGridTextBoxColumn class which inherits from System.Windows.Forms.DataGridTextBoxColumn. Again, nothing particularly special. I override the Edit method to make sure no one gets to edit the line like this:
Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, _
ByVal isReadOnly As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
isReadOnly = True
End Sub
FxCop tells me the following about this method:
"Change parameter name 'isReadOnly' of method DataGridTextBoxColumn.Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean):Void to 'readOnly' in order to match the identifier as it has been declared in DataGridColumnStyle.Edit(CurrencyManager, Int32, Rectangle, Boolean, String, Boolean):Void."
Now I'm used to doing that in C#. No problem there. But when you do that in VB.Net, guess what:
C:\Projects\LogViewer\1.0\Helpers\DataGridTextBoxColumn.vb(22) :
error BC30284: sub 'Edit' cannot be declared 'Overrides' because it does not override a sub in a base class.
C:\Projects\LogViewer\1.0\Helpers\DataGridTextBoxColumn.vb(23) :
error BC30181: Specifiers valid only at the beginning of a declaration.
C:\Projects\LogViewer\1.0\Helpers\DataGridTextBoxColumn.vb(24) :
error BC30203: Identifier expected.
Great huh, three compiler errors for the price of one! Makes sense of course, as ReadOnly is a VB.Net keyword to indicate a property is read-only and VB.Net is case insensitive. But it's behavior like this that can stop people from using FxCop. And that's a pity, because on other issues the remarks made by FxCop are valid.