Difference between [RunInstaller(true)] and [RunInstallerAttribute(true)]

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

I can't find any good information on the
relation/difference between
[RunInstaller(true)] and [RunInstallerAttribute(true)]
attributes in the code. Please advise.
 
K Viltersten said:
I can't find any good information on the
relation/difference between
[RunInstaller(true)] and [RunInstallerAttribute(true)]
attributes in the code. Please advise.

Almost no difference at all. From the C# 3.0 spec, section 17.2:

<quote>
By convention, attribute classes are named with a suffix of Attribute.
An attribute-name of the form type-name may either include or omit this
suffix. If an attribute class is found both with and without this
suffix, an ambiguity is present, and a compile-time error results. If
the attribute-name is spelled such that its right-most identifier is a
verbatim identifier (§2.4.2), then only an attribute without a suffix
is matched, thus enabling such an ambiguity to be resolved.
</quote>
 
I can't find any good information on the
relation/difference between
[RunInstaller(true)] and [RunInstallerAttribute(true)]
attributes in the code. Please advise.

Almost no difference at all. From the C# 3.0 spec, section 17.2:

<quote>
By convention, attribute classes are named with a suffix of Attribute.
An attribute-name of the form type-name may either include or omit this
suffix. If an attribute class is found both with and without this
suffix, an ambiguity is present, and a compile-time error results. If
the attribute-name is spelled such that its right-most identifier is a
verbatim identifier (§2.4.2), then only an attribute without a suffix
is matched, thus enabling such an ambiguity to be resolved.
</quote>

Great info. Thanks!

For some reason VS2005 will suggest the name
sans the suffix when using autogenerated code.
i almost got punched today for using the
suffix while a colleague insisted on not to.
 
K Viltersten said:
Great info. Thanks!

For some reason VS2005 will suggest the name
sans the suffix when using autogenerated code.
i almost got punched today for using the
suffix while a colleague insisted on not to.

I think omitting the suffix is idiomatic - I certainly don't include it
myself.
 
K said:
I can't find any good information on the
relation/difference between
[RunInstaller(true)] and [RunInstallerAttribute(true)]
attributes in the code. Please advise.
For some reason VS2005 will suggest the name
sans the suffix when using autogenerated code.
i almost got punched today for using the
suffix while a colleague insisted on not to.

VS and your colleague are right. If you write
FoobarAttribute, then you will have all the maintainers
of your code searching for FoobarAttributeAttribute !

Arne
 
Arne Vajhøj said:
VS and your colleague are right. If you write
FoobarAttribute, then you will have all the maintainers
of your code searching for FoobarAttributeAttribute !

Oh yes, XmlAttributeAttribute certainly did teach us that sort of thing,
didn't it... :)
 
I can't find any good information on the
relation/difference between
[RunInstaller(true)] and [RunInstallerAttribute(true)]
attributes in the code. Please advise.
For some reason VS2005 will suggest the name
sans the suffix when using autogenerated code.
i almost got punched today for using the
suffix while a colleague insisted on not to.

VS and your colleague are right. If you write
FoobarAttribute, then you will have all the maintainers
of your code searching for FoobarAttributeAttribute !

How can we explain that the code provided by
MS on in the help uses the suffix, then? Is
it a mistake? A special case? Please advise.
 
K Viltersten said:
How can we explain that the code provided by
MS on in the help uses the suffix, then? Is
it a mistake? A special case? Please advise.

It is _allowed_ to both provide and omit the suffix, so it's not a mistake.
On the other hand, Microsoft samples in MSDN have never been particularly
good as far as coding style is concerned - they often don't even follow
Microsoft's own style guide. Overall, vast majority of hand-written C# code
I've seen omits the suffix - after all, that was why it is allowed to do so
in the first place.
 
How can we explain that the code provided by
It is _allowed_ to both provide and omit the suffix, so it's not a
mistake. On the other hand, Microsoft samples in MSDN have never been
particularly good as far as coding style is concerned...

Got it. Thanks!
 
Back
Top