Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

compile-time error generating custom attributes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Picho - 24 Jun 2006 23:34 GMT
hi all,

can I create my own compile-time attributes?
e.g. an attribute applied to a method and that will generate a compile time
error if the method has the wrong signature?

I was hinted twords 'Intellisense API' but cant seem to find it at all...

thanx,
Picho
Gaurav Vaish (www.EduJini.IN) - 26 Jun 2006 02:25 GMT
New/Custom attributes that you created would not be understood by Visual
Studio / Compiler..

Specific to your case, where do you wish to apply this attribute -- checking
the method signature?

Signature

Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------

> hi all,
>
[quoted text clipped - 6 lines]
> thanx,
> Picho
Picho - 26 Jun 2006 08:06 GMT
thanx for the reply.

I would like to avoid run-time errors caused by objects that apply my
attributes to their class members.

I could have used simply interfaces but I need more info on the members such
as descriptions, and other things.

plus I wish to avoid the need of implementing my interface AND applying
attributes.

when I apply an attribute that is defined to target a method to a property,
i get a compilation error right?

cant I extend this and create attributes that will validate certains
constrains and produce compile-time errors?

> New/Custom attributes that you created would not be understood by Visual
> Studio / Compiler..
[quoted text clipped - 12 lines]
>> thanx,
>> Picho
Ben Voigt - 26 Jun 2006 14:56 GMT
> thanx for the reply.
>
[quoted text clipped - 6 lines]
> plus I wish to avoid the need of implementing my interface AND applying
> attributes.

You probably do want both... method calls through interfaces are many times
faster than reflection on attributes and a reflected call.

> when I apply an attribute that is defined to target a method to a
> property, i get a compilation error right?
[quoted text clipped - 19 lines]
>>> thanx,
>>> Picho
Gaurav Vaish (www.EduJini.IN) - 28 Jun 2006 18:59 GMT
> I could have used simply interfaces but I need more info on the members
> such as descriptions, and other things.

Define interfaces.
Define attributes.... do both.

The implementation class can be discovered dynamically using reflection (say
from config files).
Use the reference to the implementation for all uses. Whenever required,
reflect on the class to find attribute values.

Signature

Happy Hacking,
Gaurav Vaish | http://www.mastergaurav.org
http://www.edujini.in | http://webservices.edujini.in
-------------------


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.