Jon Skeet said:
I can see the benefits, but I think a compiler should be sticking to
the language specification - and the language spec *certainly*
shouldn't be talking about format specifiers and the like, IMO. That's
the business of the library being used, not the language.
I know. I know. But we are talking about THE library.
The call IS syntactically correct, and therefore, beyond the job
description of a compiler, but since Console.WriteLine and all of it's
similar cousins are part of the CLR (and commonly used), it would be
helpful to have some means of validating all recognizable format strings
at compile time (or at least before the program ships).
A compiler switch for csc.exe would be nice, but I would be fine with a
separate command line tool.
There's nothing language specific about this - I think it would be
quite possible for a tool to run through a built assembly and check
for string literals which are used for format strings. As well as a
knowledge of the current methods taking format strings, you could also
add a decorator attribute to a parameter to specify that it should be
a format string, so that the tool could validate the use of your own
methods as well.
You have a point, I could probably sit down and write something that
does exactly what I was asking Microsoft to give me for free :^)
Of course, if I wrote it, far fewer people would have access to it (and
it would have a greater chance of being half-assed).
Oh well
Thanks for the input
Bill