hi all,
i'm trying to develop a new custom rule which will help me in checking the exception handling in FxCop.....
The first one is about checking whether the custom exception derives from application exception.The system exception derived are excluded for CLR. How do i make any headway into this rule
The other exception handling rule is about checking whether any destructor is throwing any exception from inside. if yes, the CLR stops executing and pass the exception to the base class destructor. if there is no base class, then the destructor's discarded.

Custom rules again.....
cschaeff
The easiest way to do this is to walk a type's BaseType member and examine its full-name, until your reach System.Object. If you encounter "System.ApplicationException" during the traversal, you've hit a type that extends that class. You could also acquire a reference to System.ApplicationException and use the IsAssignableTo helper.
Below is a helper we currently use to determine whether a method is a finalizer. I'm not sure, though, that it's current for the new code emit in C++ v2.0. This helper is likely to go away in the future. We're publishing the code in these cases for people who would still like to make use of it.
static public bool IsFinalizer(Method method)
{
if (method == null) throw new ArgumentNullException("method");
// {dtor} == some flavors of c++ return (
!method.IsStatic
&& !method.IsAbstract
&& !method.IsPublic
&& method.ReturnType == SystemTypes.Void
&& method.Parameters.Length == 0
&& (method.Name.Name == "Finalize" || method.Name.Name == "{dtor}")
);
}
diablo_xix
hi all,
my query is related to the 1st part of the above post. in order to do this check, i've used the following check method:
public
override ProblemCollection Check(TypeNode pobjType){
if (pobjType == null) return null;if
(pobjType.NodeType == NodeType.Class){
string
strClassName = pobjType.Name.Name;if
(pobjType.IsAssignableTo(SystemTypes.Exception)){
string
strBaseTypeName = pobjType.BaseType.FullName;if
(strBaseTypeName != "System.ApplicationException"){
Problems.Add(
new Problem(GetResolution(strClassName), strClassName));} } } }
But this doesn't give any warning for any child class whose parent class is not inheriting from System.ApplicationException........
Can anyone tell me how to go back to the parent class and check its inheritance from ApplicationException class or SystemException class
Thanks,
ThunderRock