سؤال

I want to create an extension to recognize specific comments in my code. I will use this to signal code smells by using the //@ comment prefix. One feature of this extension will be to generate warnings for each comment encountered while compiling the code. Is it possible to do this?

هل كانت مفيدة؟

المحلول

I don't think you can hook into the compiler to generate warning. However, the "Error List" view aggregates errors, warnings and messages from multiple sources. Would it be good enough for you to simply append to that list?

Here's a link I could find on the subject : http://www.mztools.com/articles/2008/MZ2008022.aspx

نصائح أخرى

There is a sample called CodeSweep that detects certain strings in comments (it is written to look for mild swear words) that adds tasks to your Task List. http://code.msdn.microsoft.com/Code-Sweep-3bfb7bb5 Reading this code could help you write your own extension if you can't use it as-is.

You could also use the existing task functionality and add your own keywords (like the out-of-the-box //HACK and //TODO - you could add //SMELL) which is quicker but gives you less control. http://msdn.microsoft.com/en-us/library/zce12xx2(v=VS.100).aspx. This may be all you need.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top