I've got some winforms partial classes marked [Obsolete]. Unlike when applying this to methods, I get no warning after building. Is this because it's set on a partial class? I can't set it in the designer too, because that code can/will be regenerated. Anything I can do about it with attributes? I don't want to throw an exception or something similar.

Recommended Answers

All 6 Replies

You normally should at least get a warning if some code from obsolete code is used. Is the main partial form part missing?

I can't set it in the designer too, because that code can/will be regenerated.

If the class is obsolete, why would you be changing it such that the generated code is updated? Last I checked, generated code was only updated when you changed the form from the designer.

Is the main partial form part missing?

Nothing is missing.

why would you be changing it

Not me, others here that may not look closely at the code. I just want a compiler warning in the error list.

Am I correct that [Obsolete] isn't working for const either?

I would do a little re-design there. Whilst const ought to be flagged by Obsolete, I would redesign and make a public property that returns your const. Mark the property as obsolete and it should flag it.

Yeah, I know I should, but I doubt it's worth it in this case. Am hoping nobody is going to touch the code in the meantime. Just wanted confirmation, so thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.