472,800 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,800 software developers and data experts.

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 23181
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Spartanicus | last post by:
How to get help from this group, and how to construct a minimised test case: http://www.spartanicus.utvinternet.ie/help_us_help_you.htm -- Spartanicus
1
by: Hafeez | last post by:
I am having real trouble compiling this code http://www.cs.wisc.edu/~vganti/birchcode/codeHier/AttrProj.tgz The attachment shows errors when compiled using the current version of g++ in a...
45
by: Matt Parkins | last post by:
Hi, (I realise this probably isn't precisely the right group for this - could someone direct me to the appropriate group to post this question? - thanks !) I'm using Visual C++ 2005 Express...
3
by: Deano | last post by:
Thought it might be a cool feature to allow my users to click a button, and connect to a webpage that would tell them if a more recent version was available. I can create a button that opens a...
3
by: Ben Rush | last post by:
When I compile my solution I get the following output - NET 2003\Vc7\atlmfc\include\atlwin.h(2027) : warning C4995: 'wsprintf': name was marked as #pragma deprecated C:\Program Files\Microsoft...
4
by: SenthilVel | last post by:
Hi I am in a conversion project of Code from .Net 1.1 -->.Net 2.0 . 1. I am going to build all my projects with NAnt RC4 version and also with VS2005 to check the affected Areas. 2. I have...
4
by: sicapitan | last post by:
I have this code snippet: updateProps snippet: if (mycheckbox.checked == '1') ? $('mycheckbox').checked = true : $('mycheckbox').checked = false; content = $('mydiv').innerHTML;
0
by: Nokao | last post by:
I'm having a lot of severe errors in my db2diag.log, (DB2 v9.1.0.0). Googling I don't fin any information :( What can I do? I attach the first reports...: 2007-11-19-17.50.26.379948+060...
78
by: Jeremy J Starcher | last post by:
(Request for Discussion) I've put together a guide that I hope will help novice coders avoid the same hair pulling that I went through. I'm open for comments about it. Have I missed the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.