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:
:------------------------------------------------------------------------------------------------------------------:
//... SKIP USING (I THINK IT IS NOT IMPORTANT FOR MY EXAMPLE)

public class TeachMe : UserControl
{
        //..... SKIP EVERYTHING ELSE FOR EXAMPLE

        [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.
mcdonatpAsked:
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)...
0
 
caner_elciCommented:
One more thing.. You can read http://blogs.msdn.com/ericgu/archive/2004/01/16/59467.aspx for more details.. Search ICompilationAttribute and http://www.resolvecorp.com/products.htm for an add-in that does what you wanna do..
0
 
mcdonatpAuthor Commented:
caner_elci,

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.
0
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.

 
caner_elciCommented:
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..
0
 
Z_BeeblebroxCommented:
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.

http://discuss.develop.com/archives/wa.exe?A2=ind0108D&L=DOTNET&P=R29897

Zaphod.
0
 
caner_elciCommented:
I hope it changes in the next version.. but anyway, they may not want us to get in touch with the compiler thou..
0
 
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 http://www.icsharpcode.net

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
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcondesign-timeattributesforcomponents.asp

Thank you in Advance
0
 
caner_elciCommented:
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?
0
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.