473,405 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

FxCop being a bit OTT?

Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception, and
since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that if
a user presses a button if for some reason my code fails the worst case
scenario for the user is either a usefull error message of a generic one
asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave
Jun 23 '07 #1
7 1553
"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
So... who's right here, FxCop or me?
FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #2
Thanks for that. Mostly I was just wondering if there was something I was
missing here. Seemed unlikely but you never know...

Dave

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OZ**************@TK2MSFTNGP06.phx.gbl...
"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
>So... who's right here, FxCop or me?

FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #3
If you read the documentation for this error, you'll find that they
already make an exception for global exception handling and logging
situations much like you are describing.

Jesse

* Dave wrote, On 23-6-2007 14:07:
Thanks for that. Mostly I was just wondering if there was something I was
missing here. Seemed unlikely but you never know...

Dave

"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OZ**************@TK2MSFTNGP06.phx.gbl...
>"Dave" <fa*******@dodo.com.auwrote in message
news:46********@news.comindico.com.au...
>>So... who's right here, FxCop or me?
FxCop is very little more than somebody else's opinion on how they think
your code should be written and structured...

As with all such advice, it's up to you to act on it or not...

I've always viewed FxCop as an interesting exercise - nothing more than
that...

I believe you can turn off the "rules" that you don't agree with... :-)
--
http://www.markrae.net

Jun 23 '07 #4
Dave wrote:
Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception, and
since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that if
a user presses a button if for some reason my code fails the worst case
scenario for the user is either a usefull error message of a generic one
asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave
Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure
that you know what it's founded on and that you know the alternatives.

In this case there is no reason to catch all exceptions in order to
shelter the users from error messages. Just use the
Application.ThreadException event, which fires whenever a thread ends
with an unhandled exception.

--
Göran Andersson
_____
http://www.guffa.com
Jun 23 '07 #5
Thanks for that but the majority of the errors will be in background threads
which I don't want to terminate on an error (need to free resources, send
error messages over the network, etc). Given my understanding of
Application.ThreadException and Applicatoin.UnhandledException I have to
provide the catch all handlers in each thread individually to be able to do
this.

Dave
"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure that
you know what it's founded on and that you know the alternatives.

In this case there is no reason to catch all exceptions in order to
shelter the users from error messages. Just use the
Application.ThreadException event, which fires whenever a thread ends with
an unhandled exception.

--
Göran Andersson
_____
http://www.guffa.com

Jun 23 '07 #6


"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
Dave wrote:
>Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception,
and since in my (apparent) foolishness I'm catching all errors in my user
interface I've got a fair few of these in my code. I'm doing this so that
if a user presses a button if for some reason my code fails the worst
case scenario for the user is either a usefull error message of a generic
one asking them to send in an error log file rather than having the whole
application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave

Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure that
you know what it's founded on and that you know the alternatives.
The problem is that the default settings give so much information, that the
average user (read me) is going to ignore them all. Things like getting a
warning every time you use a string litereal.
Jun 24 '07 #7
JR
Sort by error and ignore those you wish to ignore.

JR

"Ian Semmel" <an****@rocketcomp.com.au???
??????:e7**************@TK2MSFTNGP04.phx.gbl...
>

"Göran Andersson" <gu***@guffa.comwrote in message
news:ON**************@TK2MSFTNGP06.phx.gbl...
>Dave wrote:
>>Hi all,

I'm using FxCop to go through my code and it's showing bad things in my
code. It is saying that you should never ever catch a general exception,
and since in my (apparent) foolishness I'm catching all errors in my
user interface I've got a fair few of these in my code. I'm doing this
so that if a user presses a button if for some reason my code fails the
worst case scenario for the user is either a usefull error message of a
generic one asking them to send in an error log file rather than having
the whole application fall over because I missed a pottential exception.

So... who's right here, FxCop or me? It's possible of course I'm missing
something important...

Dave

Even if FxCop is a bit strict, the advice it gives is well founded. You
can of course break the "rules" if you like, but you should make sure
that you know what it's founded on and that you know the alternatives.

The problem is that the default settings give so much information, that
the average user (read me) is going to ignore them all. Things like
getting a warning every time you use a string litereal.


Jun 25 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Crocker Data Processing | last post by:
Hi. I've written a bunch of custom rules for FxCop version 1.23, and today happened to download and install (separately) the new FxCop 1.321. Arrgghh ! The new introspection stuff is a lot...
5
by: Chua Wen Ching | last post by:
I had use fxcop to check my code. I had 1 confusion here. I would normally call a method by this way in my IAnimal: Example: public void CallFuncA(ushort port); But fxcop says i need to...
0
by: Chua Wen Ching | last post by:
Hi there, I am super confuse on this recommendation by FxCop. 1) http://www.gotdotnet.com/team/fxcop/docs/rules/UsageRules/OperatorEqualsOverridesRequireEqualsOverridel.html First of all,...
3
by: Rasmus | last post by:
I VS 2005 beta 2 i have a solution with - a number of classes - a website - a httphandler - a http module I want to run fxcop on my class files - but cant find out how to enable it. I've...
8
by: hansiman | last post by:
Just beginning using FxCop in my asp.net projects... I get a lot of error messages under the header: AvoidUnusedParameters for funtions and routines lik: Sub isUserAuthenticated(ByVal...
3
by: Velvet | last post by:
I ran FxCop on one of the components for my web site and the security rules what me to add " tags like the ones listed below: This breaks my ASP.NET application. So my question is,...
4
by: Bruce One | last post by:
Given a project with some .cs files, Is there a way to block some of these files to be read by FxCop ?
10
by: Karsten Schramm | last post by:
I would write BaseClass var; ..... if(var is DerivedClass) { DerivedClass derivedVar = (DerivedClass)var; DoSomething(derivedVar); }
5
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message...
3
by: AlexS | last post by:
When I implement Dispose pattern in object implementing IDisposable, current fxcop recommends: Ensure that Wrapper.Dispose():Void is declared as public and sealed. However, if I do as it asks,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.