473,652 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Reflect ion.MethodAttri butes) 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 UsingDeprecated Function(string aString)
{
}

public string UsingaNormalFun ction(string aString)
{
}

The results are
UsingDeprecated Function

(System.String aString)

Attributes :

PrivateScope

FamANDAssem

Family

Public

HideBySig

ReuseSlot

UsingaNormalFun ction

(System.String aString)

Attributes :

PrivateScope

FamANDAssem

Family

Public

HideBySig

ReuseSlot
Nov 17 '05 #1
1 1909
Am I right in saying that the attributes value
(System.Reflec tion.MethodAttr ibutes) 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.GetC ustomAttributes and check if the
ObsoleteAttribu te 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
1330
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
5880
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 important changes, so in this thread I would like to focus on that issue alone. I have edited the Proposed Syntax example below to take out the changes unecessary to this discussion. I left in the change of "instance variable" syntax (...
2
3202
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
1671
by: Jeffrey Schwab | last post by:
Under what cicumstances is the keyword "static" (?:not)? deprecated?
45
11670
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 Edition Beta (free download from MS - hooray!), and everything works fine, except I get warnings back on the use of some functions, strlen() for example, saying that the function has been deprecated - although they do still work (which is I guess...
9
3332
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 the arguments of the calling function in a non-deprecated way?
32
3790
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 it, and impossible to guarantee that it won't happen. Therefore, i think it's surprising that this function has not been deprecated. The C++98 Standard keeps it from the C89 standard. The C99 Standard has kept it :-o.
3
13646
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 Visual Studio .NET 2003\Vc7\atlmfc\include\atlwin.h(2027) : warning C4995: 'wsprintfA': name was marked as #pragma deprecated C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlwin.h(2211) : warning C4995: 'wsprintf': name...
2
1470
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
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8467
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.