How do you create an attribute that appends to IntelliSense like Obsolete does with [deprecated]?

Would anyone be kind enough to post a tutorial or point me in the right direction on how to:

Create a Custom Attribute that appends to IntelliSense Like the Obsolete Attribute Does since the
ObsoleteAttribute class cannot be inherited and I have no idea on how it works.

You know how if you use the Obsolete Attribute will add [deprecated] in front of IntelliSense.
I am wanting to do something like that.

Here is some code For Example:

public class TeachMe : UserControl

        [Obsolete("This Is A ObsoleteAttribute Message")]
        public void HowDoesObsoleteWork()
           //I  know that if you use a Obsolete Attribute that it will not compile or generate an error

         [NewAttribute("This is new to this version")]
         public void ToBeLikeObsolete()
            //I don't really care about generating a error or making a project not compile
            //with my Attribute.
            //I just want it to append and show my own custom text like Obsolete does with
            // [deprecated] in IntelliSense when you type in the period

          public classs NewAttribute : Attribute {
                //Here is where I need the help and a example
               //To make my Attribute append [my own message] in IntelliSense
               //like the Obsolete Attribute appends [deprecated]
Now if I  place the Control I created called TeachMe on a form it would be named TeachMe1.

In Code View I  type TeachMe1.HowDoesObsoleteWork the IntelliSense shows

[deprecated] void TeachMe.HowDoesObsoleteWork()
Again in Code View I try IntelliSense my Custom Attribute

I type TeachMe1.ToBeLikeObsolete and IntelliSense shows

void TeachMe.ToBeLikeObsolete()
I would like IntelliSense to showing something like Obsolete did for example.

[New to version 1.5] void TeachMe.ToBeLikeObsolete()

Thank you in advance for any and all help.
Who is Participating?
caner_elciConnect With a Mentor Commented:
As far as I know, ObsoleteAttribute is a built-in attribute.. which is recognized by compiler at compile-time and processed.. Compiler uses its Message property to get the message and IsError property to understand if this is an error (otherwise it's a warning)...
One more thing.. You can read for more details.. Search ICompilationAttribute and for an add-in that does what you wanna do..
mcdonatpAuthor Commented:

I looked at your blog and did not really understand it so I did not find it very usefull to me.

I also looked at the free XC# version 1.2 the add-in that you talked about (I assume that you didn't mean I had to use version 2.0) and did not seem to find what I was looking for in any of there examples.

From a quick look at the Documentation for XC# I found that it did not offer much help to my question.

Did you mean I would need to write my own compilation attribute using the XCSharp.Interface.ICompilationAttribute interface and respond to compiler events?

I don't know how to do this I am just beginning C#.

Would you be kind enough to post some code using XC# to a achieve a Attribute like the ObsoleteAttribute where IntelliSense shows something like [deprecated] when using Obsolete?

Thank you in Advance.
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

If you want some attributes those act like ObsoleteAttribute you will need to write your own compiler or use some add-ins like XC#.. Because ObsoleteAttribute is a known attribute by C# compiler.. That's why it gives some warnings or errors using that attribute.. I don't know much about XC#, I just found that while searching if it's really possible.. And yes, even XC# doesn't give you what you want..
It's said that it's not possible to add custom attribute classes like ObsoleteAttribute.. But there must be a way to let compiler know that we want to give a warning or error, or interact with IntelliSense to add some info... Unless they hardcoded "ObsoleteAttribute" name in the compiler.. I'll be searching..
According to this person (who claims to be on the Visual C++ compiler team, so probably would know), it is hardcoded, therefore you cannot emulate this functionality without writing some kind of add-in or compiler as caner_elci mentioned.

I hope it changes in the next version.. but anyway, they may not want us to get in touch with the compiler thou..
mcdonatpAuthor Commented:
Is there any other way we can minupulate IntelliSense other than with the C# XML Documentation?

So the problem is in the NET Framework SDK with the compiler and not the IDE like Microsoft's Visual Studio or freeware IDE's like SharpDevelop from

caner_elci does C# have any other predefined attributes that might help me?

Does anyone know where all of the predefined attributes are listed?

I don't see where Microsoft has them all listed just a few

Thank you in Advance
Sorry mcdonatp, I don't think there are any other attributes or a way to write your own attributes those interact with the compiler or designer.. ObsoleteAttribute is cought by compiler and shown as a warning or error.. and other attributes you mentioned about are some designer attributes. You can code some attributes like them, but VS.NET designer will not care about them. Only you can implement them in your own controls and classes..
Anyway, we know that you can do it by writing some add-ins to VS.NET, but I think it's not what you want?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.