RE: C# compiler misses unused parameter in function parameter list -
01-04-2008
, 03:19 AM
Hello Ronnie,
According to your description, you have a concern on that VS IDE compiler
is not detecting an unused parameter in the function parameter list,
correct? If I misunderstood anything here, please don't hesitate to correct
me.
I'm afraid to say VS IDE compiler doesn't check the parameter in the
function parameter list, even though you set the warning level to 4. But
the rule CA1801 defined in Code Analysis addressed this issue. If you'd
like to get such unused parameter error, you can enable the Code Analysis
as the following steps.
#1 Right-click on your C-Sharp Project, and click on the "Property" in the
context menu.
#2 Navigate to the "Code Analysis" page
#3 Check the "Enable Code Analysis (defines CODE_ANALYSIS Constant)"
checkbox.
After that, if you build your project again, VS IDE will throw a Warning
message like below
"CA1801 : Microsoft.Usage : Parameter 'a' of Class1.test(Int32):Object is
never used. Remove the parameter or use it in the method body."
By the way, you can also clear all the checkboxs in the "Rules" panel, and
then only check the rule "CA1801".
Hope this helps. If you have any more concern, please feel free to update
here again. We are glad to assist you.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights. |