tags:

views:

33

answers:

1

I just had this throw a compilation error while refactoring some legacy (hence VB.NET) unit tests, where I wanted to just comment out one of the sample inputs to MBUnit:

<RowTest> _
'<Row("Something")> _
<Row("SomethingElse")> _

Which gave:

Attribute specifier is not a complete statement. Use a line continuation to apply the 
attribute to the following statement.

Is it actually treating the whitespace/commented-out line as an actual line? Generally, when I gripe about VB.NET, I preface it with, "Now, I wouldn't want to be the guy writing their grammar, but..." This seems like one of those cases where I don't know the answer, if I'm right. But I do know want to know the answer, in this case.

+2  A: 

Yes, as far as I understand it, the problem is that your first line continuation adds the commented out line as part of the first line, and then the line continuation character on the commented out line is ignored since it's part of a comment so it ends up being:

<RowTest> '<Row("Something")> _  <-- this line continuation character is ignored since it's commented out.
<Row("SomethingElse")> _

What would be needed to support this would be a way to end a comment other than a newline, but as it's usually not a problem and I think it would affect the compiling speed etc quite a bit since it would make it have to parse all comments I suppose it's not seen as worthwhile.

ho1
Hm, this seems in keeping with: http://msdn.microsoft.com/en-us/library/aa711641(VS.71).aspx, which agrees that line continuations are treated as normal whitespace. I'm not a VB.NET programmer, and my knowledge is mostly anecdotal. I was treating it more as a, "this statement is not done" than a, "Preprocessor: remove the following newline." Thanks! (I agree with the parser speed comment)
Marc Bollinger