Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / January 2008

Tip: Looking for answers? Try searching our database.

C# compiler misses unused parameter in function parameter list

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ronnie Smith - 03 Jan 2008 20:01 GMT
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
WenYuan Wang [MSFT] - 04 Jan 2008 08:19 GMT
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.
Ronnie Smith - 05 Jan 2008 00:52 GMT
Hello Wen,

Thanks for the info. After some research on your post I discovered
that Code Analysis is not available for VS 2005 Professional - just
the Team Edition.

It seems that FX-cop provides this functionality though - but I'm not
sure how.

Thanks for pointing me in the right direction.

Ronnie

> Hello Ronnie,
>
[quoted text clipped - 33 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 07 Jan 2008 08:30 GMT
Hello Ronnie,
Thanks for your reply.

As you may seen, VS 2005 provides IDE with FxCop. But this great feature is
only available for VS 2005 Team Edition.
For Professional Edition, we can still use FxCop. But, we lose the feature
supported by IDE. You may get FxCop at http://www.gotdotnet.com/team/fxcop/

Below is a document describes how to Analyze the managed .NET code with
FxCop
therhttp://www.gotdotnet.com/team/fxcop/gotdotnetstyle.aspx?url=FxCop.html
[Quick Start Guide to FxCop]

Hope this helps, let me know if there is anything unclear. It's my pleasure
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.
Ronnie Smith - 07 Jan 2008 16:40 GMT
Thank you Wen for your assistance.
FxCop was what I needed.
Thanks again,
Ronnie

> Hello Ronnie,
> Thanks for your reply.
[quoted text clipped - 19 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
WenYuan Wang [MSFT] - 08 Jan 2008 06:33 GMT
You are welcome, Ronnie.
I am glad to be of assistance. :)

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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.