473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Identifing Deprecated Functions via reflection

Hi,

I'm trying to recognise whether a function is deprecated or not when
reflecting a method.

eg.

[Obsolete ("This function will error",true)]

or

[Obsolete]

Am I right in saying that the attributes value
(System.Reflection.MethodAttributes) is 6278? - is this a safe assumption?,
I guess the value could vary which is why I'm a bit worried.

I've been looking through the example on MSDN

http://msdn.microsoft.com/library/de...classtopic.asp

and created a sample app, but there doesn't look to be any difference. Is
there any way of telling via reflection that the obsolete method has the
true parameter?

Many thanks

Rich

Using the sample on MSDN, and reflecting an assembly with these two methods

[Obsolete ("This function will error",true)]
public string UsingDeprecatedFunction(string aString)
{
}

public string UsingaNormalFunction(string aString)
{
}

The results are
UsingDeprecatedFunction

(System.String aString)

Attributes :

PrivateScope

FamANDAssem

Family

Public

HideBySig

ReuseSlot

UsingaNormalFunction

(System.String aString)

Attributes :

PrivateScope

FamANDAssem

Family

Public

HideBySig

ReuseSlot
Nov 17 '05 #1
1 1893
Am I right in saying that the attributes value
(System.Reflection.MethodAttributes) is 6278? - is this a safe assumption?,
No

and created a sample app, but there doesn't look to be any difference. Is
there any way of telling via reflection that the obsolete method has the
true parameter?


Just use MethodInfo.GetCustomAttributes and check if the
ObsoleteAttribute is present. If so, check the IsError property.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian Donovan | last post by:
Hi all, Is there a way to identify the current function. For example: class A: def B(self): print current_function_name
99
by: David MacQuigg | last post by:
I'm not getting any feedback on the most important benefit in my proposed "Ideas for Python 3" thread - the unification of methods and functions. Perhaps it was buried among too many other less...
2
by: gf gf | last post by:
I read that lower() is deprecated. Unfortunately, I can't find the preferred way of lowercasing a string. What is it? Thanks PS Please cc me on all responses.
5
by: Jeffrey Schwab | last post by:
Under what cicumstances is the keyword "static" (?:not)? deprecated?
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...
9
by: Robert | last post by:
Hi, Currently I am using argument.callee.caller.arguments to get the arguments of the caller function, but Firefox complains that arguments (of Function) is deprecated. Is there a way to get...
32
by: Marcus | last post by:
We all know that the "gets" function from the Standard C Library (which is part of the Standard C++ Library) is dangerous. It provides no bounds check, so it's easy to overwrite memory when using...
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...
2
by: rehevkor5 | last post by:
I am trying to use the reflection API in PHP 5 to execute the functions in a class which looks like: class Meow { function context() { function a() { }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.