469,336 Members | 5,494 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

Marking code deprecated

How do I mark a method or class in my library as deprecated, so that when it
is used by some other application, the compiler will issue a warning?
Jun 14 '07 #1
9 22954
Michael,

You want to add the Obsolete attribute to it.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"michael sorens" <m_********@newsgroup.nospamwrote in message
news:1A**********************************@microsof t.com...
How do I mark a method or class in my library as deprecated, so that when
it
is used by some other application, the compiler will issue a warning?

Jun 14 '07 #2
Hi,

Yes, just as Nicholas pointed out, you may use ObsoleteAttribute for this
task. Actually, .Net Base Class Library also uses ObsoleteAttribute to mark
obsolete classes or methods. For example, if you search
AppDomain.AppendPrivatePath Method in .Net2.0 MSDN, you will see the
following:
[ObsoleteAttribute("AppDomain.AppendPrivatePath has been deprecated. Please
investigate the use of AppDomainSetup.PrivateBinPath instead.
http://go.microsoft.com/fwlink/?linkid=14202")]
public void AppendPrivatePath (
string path
)

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 15 '07 #3
Thank you. I will give that a try...
Could I also ask where I might find an overview article on attributes? I
have had occasion to use a few now and then (this one, with nunit, and
others) but I would like to learn a bit more about them, including which ones
are available (like the ObsoleteAttribute).

Jun 17 '07 #4
On Jun 14, 11:43 am, michael sorens <m_j_sor...@newsgroup.nospam>
wrote:
How do I mark a method or class in my library as deprecated, so that when it
is used by some other application, the compiler will issue a warning?
It might be a good idea to use the EditorBrowsableAttribute as well.
Intellisense uses this attribute to decide whether or not to display
the member.

Jun 18 '07 #5
Hi Michael ,

Yes, Attribute is an essential mechanism of .Net. You may read the 2 links
below to understand the Attribute feature in .Net:
"Attributes Tutorial"
http://msdn2.microsoft.com/en-us/lib...54(VS.71).aspx
"Designing With Custom Attributes"
http://msdn.microsoft.com/msdnmag/is...asicInstincts/

Since all the .Net BCL Attribute classes inherited from System.Attribute
class, you may search and examine the "Attribute Hierarchy" below to find
any useful attribute in .Net BCL:
http://msdn2.microsoft.com/en-us/lib...96(VS.80).aspx

However, as you can see, the "Attribute Hierarchy" is really a big table,
there is no quick way to understand them all in a short time.

If you still have anything unclear, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 18 '07 #6
Hi Michael,

Have you reviewed my last reply to you? Does it make sense to you? If you
still need any help or have any concern, please feel free to tell me,
thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 20 '07 #7
Very cool--thank you, Brian.

"Brian Gideon" wrote:
On Jun 14, 11:43 am, michael sorens <m_j_sor...@newsgroup.nospam>
wrote:
How do I mark a method or class in my library as deprecated, so that when it
is used by some other application, the compiler will issue a warning?

It might be a good idea to use the EditorBrowsableAttribute as well.
Intellisense uses this attribute to decide whether or not to display
the member.

Jun 20 '07 #8
Your links are quite helpful. Even allowed me to quickly look up the
EditorBrowsableAttribute that Brian Gideon mentioned in another reply to this.

Jun 20 '07 #9
Hi Michael,

Thank you for the confirmation. Ok, if you need further help, please feel
free to post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 21 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Spartanicus | last post: by
1 post views Thread by Hafeez | last post: by
45 posts views Thread by Matt Parkins | last post: by
3 posts views Thread by Ben Rush | last post: by
4 posts views Thread by SenthilVel | last post: by
78 posts views Thread by Jeremy J Starcher | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.