Prevent developers from using certain methods of the core .NETclasses?

M

mlanza

Our shop wants to enforce standards and sometimes we write an
extension methods meant to be used in place of another method. For
example, we have our own version of DataTable.Select named SelectRows
that helps us enforce certain standards.

Is there a way to provide a compile time warning on the use of the
method we wish to deprecate? The obsolete attribute works for classes
we wrote ourselves, but I'm not sure if it can be applied to the
methods of the core .NET classes.

We want to use the native classes like DataTable, etc. We don't want
to create an inherited version of such classes in order to hide/
deprecate certain methods.

Thanks,
Mario T. Lanza
2009.05

PS. It was recommended that I find a more appropriate group for this
post.
Originally posted: microsoft.public.dotnet.general
 
P

Pavel Minaev

Our shop wants to enforce standards and sometimes we write an
extension methods meant to be used in place of another method.  For
example, we have our own version of DataTable.Select named SelectRows
that helps us enforce certain standards.

Is there a way to provide a compile time warning on the use of the
method we wish to deprecate?  The obsolete attribute works for classes
we wrote ourselves, but I'm not sure if it can be applied to the
methods of the core .NET classes.

There isn't any way to force the compiler to do what you want. But you
can use something like FXCop (and you probably should, anyway), and
write an extension for it that checks your own rules.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top