Notice something funny on the previous post? Take a look at the first screen shot and the first imported method.  The method signature is:

 

public virtual sealed void BindData(…)

 

Now this comes straight out of Reflection by checking the methods’ IsFinal and IsVirtual flags. It appears that this doesn’t make sense, after all how can a method be both virtual and sealed at the same time. It turns out for once, MSDN actually documents this somewhat odd behavior:

 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionmethodbaseclassisfinaltopic.asp

 

To determine if a method is overridable, it is not sufficient to check that IsVirtual is true. For a method to be overridable, IsVirtual must be true and IsFinal must be false. For example, a method might be non-virtual, but it implements an interface method. The common language runtime requires that all methods that implement interface members must be marked as virtual (Overridable in Visual Basic); therefore, the compiler marks the method virtual (Overridable in Visual Basic) final. So there are cases where a method is marked as virtual (Overridable in Visual Basic) but is still not overridable.

 

In this case BindData() does implement an interface method which automatically makes the method virtual by way of the compiler intervening. Fine, but what is forcing the method at the same time to become sealed?

 

public class wwWebTextBox : System.Web.UI.WebControls.TextBox,IwwWebDataControl

{

      /// <summary>

      /// Binds the control to the control BindingSource.

      /// </summary>

      /// <param name="WebForm">Pass in the WebForm or container that
      /// contains the control source
</param>

      public void BindData(Control WebForm)

      {

            wwWebDataHelper.ControlBindData(WebForm,this);

      }

}

 

Sure, I’m not explicitly marking it virtual and I would actually expect the class to be sealed but the above seems to suggest differently.

 

Odd…

 

The same sort of logic applies to Abstract and Virtual which are set at the same time. There are a few others as well, and it’s starting to get messy to get this data out consistently. <g>