David,
I was doing some reading and found that C# supports a #line directive that will change the line number reported by the compiler. So, as a quick example, let's say we force a compiler error by creating a macro with just this statement (mispelled Console intentionally):
- Code: Select all
Concole.WriteLine("");
When you execute this macro, the compiler will report the error on line 10. As I previously said, that's because of overhead in how the macro is incorporated into a compileable class module. However, if you add a #line directive, like this:
- Code: Select all
#line 1
Concole.WriteLine("");
Now the compiler will report the error on line 1. The #line directive resets the line number reference, so any errors occurring from that point on will correctly point to the macro line, without consideration for the other overhead. This still gets complicated if your macro includes an #Events tag. That's because there's no way to eliminate the overhead lines between the main macro body and the statements which follow the #Events tag. So, in this example:
- Code: Select all
#line 1
Console.WriteLine("No error here");
#Events
private static void SyntaxError() { Concole.WriteLine(); }
The compiler now reports the error as happening on line 5, even though it's on the third line of the macro file. There are two lines of overhead that can't be ignored.
This is not supported in the Visual Basic compiler.