By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Help! How to make overridden method sealed using the CodeDom?

P: n/a
How can I make the CodeDom generate the following C# method?

protected sealed override void Test()
{
}

I've tried using:

domMethod.Attributes = MemberAttributes.Override |
MemberAttributes.Family | MemberAttributes.Final;

but I just can't get the CodeDom to produce the "sealed" keyword...

Thanks,
- Lee

Jul 1 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
An overriden method is assumed to be virtual. An overriden method is not
considerred a new method but simply a redefinition of the original method it
is not allowed to change such information. Allowing such a change to occur
would logically break many things.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
<le**********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
How can I make the CodeDom generate the following C# method?

protected sealed override void Test()
{
}

I've tried using:

domMethod.Attributes = MemberAttributes.Override |
MemberAttributes.Family | MemberAttributes.Final;

but I just can't get the CodeDom to produce the "sealed" keyword...

Thanks,
- Lee

Jul 1 '06 #2

P: n/a
There's nothing wrong with sealing a virtual method. (See
http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
specifically do you see breaking when I seal a virtual method?

Anyway, does anyone know how to seal a virtual method using the
CodeDom?

- Lee
Greg Young wrote:
An overriden method is assumed to be virtual. An overriden method is not
considerred a new method but simply a redefinition of the original method it
is not allowed to change such information. Allowing such a change to occur
would logically break many things.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
<le**********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
How can I make the CodeDom generate the following C# method?

protected sealed override void Test()
{
}

I've tried using:

domMethod.Attributes = MemberAttributes.Override |
MemberAttributes.Family | MemberAttributes.Final;

but I just can't get the CodeDom to produce the "sealed" keyword...

Thanks,
- Lee


Jul 1 '06 #3

P: n/a
Greg Young wrote:
An overriden method is assumed to be virtual. An overriden method is not
considerred a new method but simply a redefinition of the original method
it is not allowed to change such information. Allowing such a change to
occur would logically break many things.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
<le**********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
How can I make the CodeDom generate the following C# method?

protected sealed override void Test()
{
}

I've tried using:

domMethod.Attributes = MemberAttributes.Override |
MemberAttributes.Family | MemberAttributes.Final;

but I just can't get the CodeDom to produce the "sealed" keyword...

Thanks,
- Lee


Hi Greg,

You can seal an overridden method (with the 'sealed' keyword), in order to
stop further overriding of the method by derived classes, but remember, if
you override a method, you can still call the base class' implementation,
by means of the base.<MethodName>() syntax, inside that method... so
it /sort of/ is a new method.

--
Hope this helps,
Tom Spink
Jul 1 '06 #4

P: n/a
I apologize too early in the morning ..
<le**********@googlemail.com> wrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
There's nothing wrong with sealing a virtual method. (See
http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
specifically do you see breaking when I seal a virtual method?

Anyway, does anyone know how to seal a virtual method using the
CodeDom?

- Lee
Greg Young wrote:
An overriden method is assumed to be virtual. An overriden method is not
considerred a new method but simply a redefinition of the original method
it
is not allowed to change such information. Allowing such a change to
occur
would logically break many things.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
<le**********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
> How can I make the CodeDom generate the following C# method?
>
> protected sealed override void Test()
> {
> }
>
> I've tried using:
>
> domMethod.Attributes = MemberAttributes.Override |
> MemberAttributes.Family | MemberAttributes.Final;
>
> but I just can't get the CodeDom to produce the "sealed" keyword...
>
> Thanks,
> - Lee
>

Jul 1 '06 #5

P: n/a

No problem. :-) Thanks for trying to help anyway.

- Lee

Greg Young wrote:
I apologize too early in the morning ..
<le**********@googlemail.com> wrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
There's nothing wrong with sealing a virtual method. (See
http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
specifically do you see breaking when I seal a virtual method?

Anyway, does anyone know how to seal a virtual method using the
CodeDom?

- Lee
Greg Young wrote:
An overriden method is assumed to be virtual. An overriden method is not
considerred a new method but simply a redefinition of the original method
it
is not allowed to change such information. Allowing such a change to
occur
would logically break many things.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
<le**********@googlemail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
> How can I make the CodeDom generate the following C# method?
>
> protected sealed override void Test()
> {
> }
>
> I've tried using:
>
> domMethod.Attributes = MemberAttributes.Override |
> MemberAttributes.Family | MemberAttributes.Final;
>
> but I just can't get the CodeDom to produce the "sealed" keyword...
>
> Thanks,
> - Lee
>


Jul 1 '06 #6

P: n/a
I expect that you will find this is a CodeDOM limitation. There are many
items which cannot be expressed in codedom (even some very basic concepts
like switch statements and while loops.

Cheers,

Greg

<le**********@googlemail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...

No problem. :-) Thanks for trying to help anyway.

- Lee

Greg Young wrote:
I apologize too early in the morning ..
<le**********@googlemail.com> wrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
> There's nothing wrong with sealing a virtual method. (See
> http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
> specifically do you see breaking when I seal a virtual method?
>
> Anyway, does anyone know how to seal a virtual method using the
> CodeDom?
>
> - Lee
>
>
> Greg Young wrote:
>> An overriden method is assumed to be virtual. An overriden method is
>> not
>> considerred a new method but simply a redefinition of the original
>> method
>> it
>> is not allowed to change such information. Allowing such a change to
>> occur
>> would logically break many things.
>>
>> Cheers,
>>
>> Greg Young
>> MVP - C#
>> http://codebetter.com/blogs/gregyoung
>>
>>
>> <le**********@googlemail.com> wrote in message
>> news:11**********************@d56g2000cwd.googlegr oups.com...
>> > How can I make the CodeDom generate the following C# method?
>> >
>> > protected sealed override void Test()
>> > {
>> > }
>> >
>> > I've tried using:
>> >
>> > domMethod.Attributes = MemberAttributes.Override |
>> > MemberAttributes.Family | MemberAttributes.Final;
>> >
>> > but I just can't get the CodeDom to produce the "sealed" keyword...
>> >
>> > Thanks,
>> > - Lee
>> >
>

Jul 1 '06 #7

P: n/a
Really!? No switches or while loops? Looks like I need to abandon the
CodeDom then. You'd think I'd learn and give up trying to use these
inextensible frameworks...

Thanks,
- Lee
Greg Young wrote:
I expect that you will find this is a CodeDOM limitation. There are many
items which cannot be expressed in codedom (even some very basic concepts
like switch statements and while loops.

Cheers,

Greg

<le**********@googlemail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...

No problem. :-) Thanks for trying to help anyway.

- Lee

Greg Young wrote:
I apologize too early in the morning ..
<le**********@googlemail.com> wrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
> There's nothing wrong with sealing a virtual method. (See
> http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
> specifically do you see breaking when I seal a virtual method?
>
> Anyway, does anyone know how to seal a virtual method using the
> CodeDom?
>
> - Lee
>
>
> Greg Young wrote:
>> An overriden method is assumed to be virtual. An overriden method is
>> not
>> considerred a new method but simply a redefinition of the original
>> method
>> it
>> is not allowed to change such information. Allowing such a change to
>> occur
>> would logically break many things.
>>
>> Cheers,
>>
>> Greg Young
>> MVP - C#
>> http://codebetter.com/blogs/gregyoung
>>
>>
>> <le**********@googlemail.com> wrote in message
>> news:11**********************@d56g2000cwd.googlegr oups.com...
>> > How can I make the CodeDom generate the following C# method?
>> >
>> > protected sealed override void Test()
>> > {
>> > }
>> >
>> > I've tried using:
>> >
>> > domMethod.Attributes = MemberAttributes.Override |
>> > MemberAttributes.Family | MemberAttributes.Final;
>> >
>> > but I just can't get the CodeDom to produce the "sealed" keyword...
>> >
>> > Thanks,
>> > - Lee
>> >
>


Jul 1 '06 #8

P: n/a
Here are a few of the things that can't be expressed
http://blogs.msdn.com/bclteam/archiv...16/396915.aspx

Cheers,

Greg
<le**********@googlemail.com> wrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Really!? No switches or while loops? Looks like I need to abandon the
CodeDom then. You'd think I'd learn and give up trying to use these
inextensible frameworks...

Thanks,
- Lee
Greg Young wrote:
I expect that you will find this is a CodeDOM limitation. There are many
items which cannot be expressed in codedom (even some very basic concepts
like switch statements and while loops.

Cheers,

Greg

<le**********@googlemail.com> wrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>
> No problem. :-) Thanks for trying to help anyway.
>
> - Lee
>
> Greg Young wrote:
>> I apologize too early in the morning ..
>>
>>
>> <le**********@googlemail.com> wrote in message
>> news:11**********************@m79g2000cwm.googlegr oups.com...
>> > There's nothing wrong with sealing a virtual method. (See
>> > http://msdn2.microsoft.com/en-us/library/ms173150.aspx) What
>> > specifically do you see breaking when I seal a virtual method?
>> >
>> > Anyway, does anyone know how to seal a virtual method using the
>> > CodeDom?
>> >
>> > - Lee
>> >
>> >
>> > Greg Young wrote:
>> >> An overriden method is assumed to be virtual. An overriden method
>> >> is
>> >> not
>> >> considerred a new method but simply a redefinition of the original
>> >> method
>> >> it
>> >> is not allowed to change such information. Allowing such a change
>> >> to
>> >> occur
>> >> would logically break many things.
>> >>
>> >> Cheers,
>> >>
>> >> Greg Young
>> >> MVP - C#
>> >> http://codebetter.com/blogs/gregyoung
>> >>
>> >>
>> >> <le**********@googlemail.com> wrote in message
>> >> news:11**********************@d56g2000cwd.googlegr oups.com...
>> >> > How can I make the CodeDom generate the following C# method?
>> >> >
>> >> > protected sealed override void Test()
>> >> > {
>> >> > }
>> >> >
>> >> > I've tried using:
>> >> >
>> >> > domMethod.Attributes = MemberAttributes.Override |
>> >> > MemberAttributes.Family | MemberAttributes.Final;
>> >> >
>> >> > but I just can't get the CodeDom to produce the "sealed"
>> >> > keyword...
>> >> >
>> >> > Thanks,
>> >> > - Lee
>> >> >
>> >
>

Jul 1 '06 #9

P: n/a

<le**********@googlemail.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...
Really!? No switches or while loops? Looks like I need to abandon the
CodeDom then. You'd think I'd learn and give up trying to use these
inextensible frameworks...
CodeDom supports only features that are part of every language it can
generate, so it's rarely the best choice when you want to generate code only
in a specific language. It's a shame, because some of its features, like
being able set set indentation and brace conventions for the generated
source, are very handy.
Jul 2 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.