Friday, September 16, 2005

Shadows a VB Field with CodeDOM

Follow up on my post for help on sgdotnet, I'll post my findings here as well to share with all.

I've got myself the answer from the book "Applied Microsoft .NET framework programming", a good book to read on the foundamentals of .NET framework, at page 176, says:

CLR Term: Newslot
C# Term: new
VB Term: Shadows
Method should not override a virtual method defined by its base type; the method hides the inherited method. Applies only to virtual methods.

So to say, my code should look like this:

Dim spPreExecuteEvent As New CodeMemberEvent
spPreExecuteEvent.Attributes = MemberAttributes.Public Or MemberAttributes.[New]

However, after the CodeDom compile unit generate the code out, I still didn't find my Shadows keyword on the line. Basically, there's an event from the base class that I want this generated class to shadows on, and upon the generation, the codes appear with warning in visual studio saying that a shadows is recommended there.

Anyway, the code still works, but just doesn't look that nice, it isn't perfect!

Let me know if you have any light on this.


ps: it takes me one whole day to find this thing out, now I know how important search technology is, while Google is still the best, here comes the problem of how to search, what keyword to use, etc. If Google had indexed that book, I would have found it 20 hours ago!

No comments: