From: Scott M. on
I refer to them as compiler attributes because the compiler turns them into
assembly metadata to then use as necessary.

http://ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html

-Scott


"Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message
news:erLUEDKNKHA.3412(a)TK2MSFTNGP04.phx.gbl...
> On 2009-09-13, Scott M. <s-mar(a)nospam.nospam> wrote:
>> The are markers that delinate a compiler "attribute", which is basically
>> a
>> special instruction just for the compiler. They are a way to mark, not
>> only
>> a Sub (you can use them on almost all class members), with extra
>> information
>> that the compiler needs to know.
>>
>> -Scott
>>
>
> Hmmm.. While there are some attributes that affect compile time behavior
> (for
> example, ObsoleteAttribute) - most attributes are processed at runtime.
> They
> are markers that can be used by other classes to gain additional
> information
> about the class, property, or method. For instance, the attributes that
> you
> can place on the properties of a class to influence the behavior of the
> PropertyGrid.
>
> One place I use them is for mapping object properties to fields in a
> dataset
> at runtime - sort of a simplified ORM tool.
>
> --
> Tom Shelton


From: Tom Shelton on
On 2009-09-13, Scott M. <s-mar(a)nospam.nospam> wrote:
> I refer to them as compiler attributes because the compiler turns them into
> assembly metadata to then use as necessary.
>
> http://ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html
>
> -Scott
>

Ok... that's true. They are put into the metadata of the assembly - but, I was
mostly refering to your remarks about them being special instructions for
the compiler.

There are very few attributes that are recognized to have meaning to the
compiler - beyond informing it to store the metadata. It seems a little
unclear to describe a mostly runtime concept this way - at least it did to me,
hence my comments :)

--
Tom Shelton
From: Scott M. on
But, technically, they are all instructions for the compiler. They tell the
compiler to store this metadata about the type.

I get what you are saying as far as what the attribute actually does for/to
the type, but it is the compiler that creates this metadata in the first
place.

-Scott

"Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message
news:erk1gLNNKHA.5072(a)TK2MSFTNGP05.phx.gbl...
> On 2009-09-13, Scott M. <s-mar(a)nospam.nospam> wrote:
>> I refer to them as compiler attributes because the compiler turns them
>> into
>> assembly metadata to then use as necessary.
>>
>> http://ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html
>>
>> -Scott
>>
>
> Ok... that's true. They are put into the metadata of the assembly - but,
> I was
> mostly refering to your remarks about them being special instructions for
> the compiler.
>
> There are very few attributes that are recognized to have meaning to the
> compiler - beyond informing it to store the metadata. It seems a little
> unclear to describe a mostly runtime concept this way - at least it did to
> me,
> hence my comments :)
>
> --
> Tom Shelton
>


From: Jack Jackson on
Sure, but:
x = 1
is an instruction to the compiler to generate some IL. By your
definition, how is that different from what an attribute does, except
that one affects metadata and the other IL.

On Sun, 13 Sep 2009 22:14:11 -0400, "Scott M." <s-mar(a)nospam.nospam>
wrote:

>But, technically, they are all instructions for the compiler. They tell the
>compiler to store this metadata about the type.
>
>I get what you are saying as far as what the attribute actually does for/to
>the type, but it is the compiler that creates this metadata in the first
>place.
>
>-Scott
>
>"Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message
>news:erk1gLNNKHA.5072(a)TK2MSFTNGP05.phx.gbl...
>> On 2009-09-13, Scott M. <s-mar(a)nospam.nospam> wrote:
>>> I refer to them as compiler attributes because the compiler turns them
>>> into
>>> assembly metadata to then use as necessary.
>>>
>>> http://ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html
>>>
>>> -Scott
>>>
>>
>> Ok... that's true. They are put into the metadata of the assembly - but,
>> I was
>> mostly refering to your remarks about them being special instructions for
>> the compiler.
>>
>> There are very few attributes that are recognized to have meaning to the
>> compiler - beyond informing it to store the metadata. It seems a little
>> unclear to describe a mostly runtime concept this way - at least it did to
>> me,
>> hence my comments :)
>>
>> --
>> Tom Shelton
>>
>
From: Scott M. on
Well sure, but attributes are a *different* way to talk to the compiler.
Saying x =1 is using the main programming language. Attributes do not.

From the article I referenced earlier:

"You may wonder why attributes are used on the .NET platform and why they
are not simply implemented as language elements. The answer comes from the
fact that attributes are stored as metadata in an assembly, rather than as
part of its executable code. As an item of metadata, the attribute describes
the program element to which it applies and is available through reflection
both at design time (if a graphical environment such as Visual Studio .NET
is used), at compile time (when the compiler can use it to modify,
customize, or extend the compiler's basic operation), and at runtime (when
it can be used by the Common Language Runtime or by other executable code to
modify the code's ordinary runtime behavior)."

-Scott


"Jack Jackson" <jjackson-nsp(a)cinnovations.net> wrote in message
news:r17ua519ce3bnavp93aseh968gbdp9s54p(a)4ax.com...
> Sure, but:
> x = 1
> is an instruction to the compiler to generate some IL. By your
> definition, how is that different from what an attribute does, except
> that one affects metadata and the other IL.
>
> On Sun, 13 Sep 2009 22:14:11 -0400, "Scott M." <s-mar(a)nospam.nospam>
> wrote:
>
>>But, technically, they are all instructions for the compiler. They tell
>>the
>>compiler to store this metadata about the type.
>>
>>I get what you are saying as far as what the attribute actually does
>>for/to
>>the type, but it is the compiler that creates this metadata in the first
>>place.
>>
>>-Scott
>>
>>"Tom Shelton" <tom_shelton(a)comcastXXXXXXX.net> wrote in message
>>news:erk1gLNNKHA.5072(a)TK2MSFTNGP05.phx.gbl...
>>> On 2009-09-13, Scott M. <s-mar(a)nospam.nospam> wrote:
>>>> I refer to them as compiler attributes because the compiler turns them
>>>> into
>>>> assembly metadata to then use as necessary.
>>>>
>>>> http://ondotnet.com/pub/a/dotnet/excerpt/vbnut_8/index1.html
>>>>
>>>> -Scott
>>>>
>>>
>>> Ok... that's true. They are put into the metadata of the assembly -
>>> but,
>>> I was
>>> mostly refering to your remarks about them being special instructions
>>> for
>>> the compiler.
>>>
>>> There are very few attributes that are recognized to have meaning to the
>>> compiler - beyond informing it to store the metadata. It seems a little
>>> unclear to describe a mostly runtime concept this way - at least it did
>>> to
>>> me,
>>> hence my comments :)
>>>
>>> --
>>> Tom Shelton
>>>
>>