HighTechTalks DotNet Forums  

C# compiler misses unused parameter in function parameter list

Visual Studio.net (IDE) microsoft.public.vsnet.ide


Discuss C# compiler misses unused parameter in function parameter list in the Visual Studio.net (IDE) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Ronnie Smith
 
Posts: n/a

Default C# compiler misses unused parameter in function parameter list - 01-03-2008 , 03:01 PM






Using C# in VS2005 with SP1, the compiler is not detecting an unused
parameter in the function parameter list.

It spots an unused parameter declared locally in the same function - but not
one in the parameter list.

Is this normal?

I have warning level set to 4.

Thanks,

Ronnie

Reply With Quote
  #2  
Old   
WenYuan Wang [MSFT]
 
Posts: n/a

Default 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.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.