What Framework Classes Do You Use the Most?

M

Mike Hofer

I could use some feedback from you all in the .NET community. Here's
the question, in a nutshell:

Aside from the data types shown below, what classes in the .NET
Framework do you use most frequently in the applications that you
develop?

The data types and classes I'd like to exclude from this list are:

* Array
* Boolean
* Byte
* Char
* IDbConnection
* DateTime
* Decimal
* Double
* Enum
* Int16
* Int32
* Int64
* List
* Object
* SByte
* Single
* String
* IDbTransaction
* UInt16
* UInt32
* Uint64

Once you've thought about this, I'd like to ask a follow-up question:
When using these objects as parameters to methods or constructors, how
do you typically test them for validity? For example, do you test them
for null, string length, values, status, etc.?

The Why of It All
-------------------------
I'm working on an open source parameter validation framework written
in C#. You can find the thing at www.nvalidate.org. The idea is that
it turns this:

if (null == foo)
throw new ArgumentNullException(foo);
if (string.Empty == foo)
throw new ArgumentException("foo", "string parameter cannot be
empty.");

Into this:

Demand.That(foo, "foo").IsNotNullOrEmpty()

It's already had an alpha release, and provides validators for all the
data types listed above. (There's a test matrix available on the web
site that details the supported test types.) What I'd like to do now,
in the next release, is expand the supported tests to increase its
utility.

I'm already casting my steely gaze on the following Framework classes:

HashTable
* IsNotEmpty
* IsNotNull
* HasCount(int)
* IsFixedSize
* IsNotFixedSize
* IsReadOnly
* IsNotReadOnly
* IsSynchronized
* IsNotSynchronized
* Contains(string key)
* Contains(string key, object value)

Stack
* IsNotEmpty
* IsNotNull
* HasCount(int expectedCount)
* HasCount(int minCount, int maxCount)
* HasMaxCount(int expectedCount)
* HasMinCount(int expectedCount)

DataReaders:
* OdbcDataReader
* Contains(string columnName)
* Contains(string columnName, DbType type)
* Contains(string columnName, DbType type, int length)
* HasFieldCount(int expectedCount)
* HasRows()
* IsNotNull()
* IsOpen()
* OracleDataReader
* Contains(string columnName)
* Contains(string columnName, DbType type)
* Contains(string columnName, DbType type, int length)
* HasFieldCount(int expectedCount)
* HasRows()
* IsNotNull()
* IsOpen()
* SqlDataReader
* Contains(string columnName)
* Contains(string columnName, SqlDbType type)
* Contains(string columnName, SqlDbType type, int length)
* HasFieldCount(int expectedCount)
* HasRows()
* IsNotNull()
* IsOpen()

* Socket
* Is(socket)
* IsAvailable
* IsBlocking
* IsNotBlocking
* IsConnected
* IsNot(socket)
* IsNotConnected
* IsNotNull
* IsValid(addressFamily, protocolType, socketType)
* HasAddressFamily(addressFamily)
* HasLocalEndPoint(endPoint)
* HasProtocolType(protocolType)
* HasRemoteEndPoint(endPoint)
* HasType(socketType)
* HasValidHandle

Streams:
* BufferedStream (Inherits StreamValidator)
* CryptoSream (Inherits StreamValidator)
* Stream
* CanRead
* CanSeek
* CanWrite
* HasLength(int expectedLength)
* HasLength(int minLength, int maxLength)
* IsAtEndOfStream()
* IsAtPosition(int expectedPosition)
* IsAtStartOfStream()
* IsEmpty()
* IsNotEmpty()
* IsNotNull()
* FileStream (Inherits StreamValidator)
* HasName()
* HasValidHandle()
* IsAsync()
* IsNotAsync()
* MemoryStream (Inherits StreamValidator)
* HasCapacity(int expectedCapacity)
* HasMinimumCapacity(int expectedCapacity)
* NetworkStream (Inherits StreamValidator)
* HasDataAvailable()

I think you get the idea. :)

So, the questions stand. What classes do you guys use, and what kinds
of parameter tests do you *actually* perform on them? I'd rather focus
on the classes that get the most use, and the tests that provide the
biggest bang for your buck.

Any help you can provide would be GREATLY appreciated!
Thanks!

Mike Hofer
NValidate Developer
http://www.nvalidate.org
http://www.linkedin.com/in/mikehofer


P.S. If anyone wants to help with this thing, drop me a line!
 
A

AMercer

Aside from the data types shown below, what classes in the .NET
Framework do you use most frequently in the applications that you
develop?

Most common classes and validations are below. Many other types/classes are
used but in only a few places (eg graphics, webrequest, printdocument, etc).

generic collections - occasionally null reference
streams - null reference, try-except for documented exceptions
exception - none (always associated with a try-except block)
stringbuilder - none (always used internally to make large strings)
control (including form, richtextbox, tooltip, font, menu, timer) - null
reference
thread - none
math - range checks on arguments, array dimension checks

My off hand opinion is that the above is not much help to you. Good luck
with your project.
 

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