473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

ObsoleteAttribute Compiler bug?

public decimal Wert
{
get{return this.wert;}
[Obsolete]
set{this.wert=value;}
}

This doesn't compile. It gives me error CS0592 and says that obsolete cannot
be applied to that elemet.
Nov 16 '05 #1
6 1635
That's not a bug - you can't apply attributes to an individual "set" or
"get". Methods can have attributes specified prior to the method header and
prior to individual parameters.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"cody" wrote:
public decimal Wert
{
get{return this.wert;}
[Obsolete]
set{this.wert=value;}
}

This doesn't compile. It gives me error CS0592 and says that obsolete cannot
be applied to that elemet.

Nov 16 '05 #2
You know that set and get accessors *are* individual methods? I see no
reason why I can't put attributes on individual accessor methods.

"David Anton" <Da********@discussions.microsoft.com> schrieb im Newsbeitrag
news:AC**********************************@microsof t.com...
That's not a bug - you can't apply attributes to an individual "set" or
"get". Methods can have attributes specified prior to the method header and prior to individual parameters.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"cody" wrote:
public decimal Wert
{
get{return this.wert;}
[Obsolete]
set{this.wert=value;}
}

This doesn't compile. It gives me error CS0592 and says that obsolete cannot be applied to that elemet.

Nov 16 '05 #3
They are individual methods in the IL, but not at the C# level.
I understand your angst, especially when you *can* do what you want in
VB.NET (!) - that is kind of odd.

"cody" wrote:
You know that set and get accessors *are* individual methods? I see no
reason why I can't put attributes on individual accessor methods.

"David Anton" <Da********@discussions.microsoft.com> schrieb im Newsbeitrag
news:AC**********************************@microsof t.com...
That's not a bug - you can't apply attributes to an individual "set" or
"get". Methods can have attributes specified prior to the method header

and
prior to individual parameters.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"cody" wrote:
public decimal Wert
{
get{return this.wert;}
[Obsolete]
set{this.wert=value;}
}

This doesn't compile. It gives me error CS0592 and says that obsolete cannot be applied to that elemet.


Nov 16 '05 #4
Cody,

Yes, the C# compiler geenrates set and get methods to handle a property.
However, during design time, these methods are called accessors and belong
to a single property. Attributes can only be applied to a class or members
of a class. The property is a member of a class. Accessors are members of
the property, therefore, they cannot have attributes.

Telmo Sampaio
MCT

"cody" <de********@gmx.de> wrote in message
news:uZ**************@TK2MSFTNGP09.phx.gbl...
You know that set and get accessors *are* individual methods? I see no
reason why I can't put attributes on individual accessor methods.

"David Anton" <Da********@discussions.microsoft.com> schrieb im
Newsbeitrag
news:AC**********************************@microsof t.com...
That's not a bug - you can't apply attributes to an individual "set" or
"get". Methods can have attributes specified prior to the method header

and
prior to individual parameters.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"cody" wrote:
> public decimal Wert
> {
> get{return this.wert;}
> [Obsolete]
> set{this.wert=value;}
> }
>
> This doesn't compile. It gives me error CS0592 and says that obsolete cannot > be applied to that elemet.
>
>
>


Nov 16 '05 #5
Really??? So it is really a bug or "missing feature" in the c# compiler.
"David Anton" <Da********@discussions.microsoft.com> schrieb im Newsbeitrag
news:37**********************************@microsof t.com...
They are individual methods in the IL, but not at the C# level.
I understand your angst, especially when you *can* do what you want in
VB.NET (!) - that is kind of odd.

"cody" wrote:
You know that set and get accessors *are* individual methods? I see no
reason why I can't put attributes on individual accessor methods.

"David Anton" <Da********@discussions.microsoft.com> schrieb im Newsbeitrag news:AC**********************************@microsof t.com...
That's not a bug - you can't apply attributes to an individual "set" or "get". Methods can have attributes specified prior to the method
header and
prior to individual parameters.

David Anton
Tangible Software Solutions Inc.
www.tangiblesoftwaresolutions.com
Home of the Instant C# VB.NET to C# converter and the Instant VB C# to
VB.NET converter

"cody" wrote:

> public decimal Wert
> {
> get{return this.wert;}
> [Obsolete]
> set{this.wert=value;}
> }
>
> This doesn't compile. It gives me error CS0592 and says that
obsolete cannot
> be applied to that elemet.
>
>
>


Nov 16 '05 #6
For me it is a bug bcause it prevents me from using attributes with property
accessors. Didn't they think about that? And as someone else said, it is
allowed in VB.NET.

"Willy Denoyette [MVP]" <wi*************@pandora.be> schrieb im Newsbeitrag
news:ue**************@TK2MSFTNGP10.phx.gbl...
Why would it be a compiler bug if the compiler generates a clear error
message?
Obsolete is allowed on "... and Property only" and as you probably know a
'Property accessor' is not the same as a property.

Willy.
"cody" <de********@gmx.de> wrote in message
news:OQ**************@TK2MSFTNGP10.phx.gbl...
public decimal Wert
{
get{return this.wert;}
[Obsolete]
set{this.wert=value;}
}

This doesn't compile. It gives me error CS0592 and says that obsolete
cannot
be applied to that elemet.


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Epler | last post by:
Hello. Recently, Generator Comprehensions were mentioned again on python-list. I have written an implementation for the compiler module. To try it out, however, you must be able to rebuild...
13
by: Bryan Parkoff | last post by:
You may notice that switch (...) is much faster than function that can gain a big improved performance because it only use JMP instruction however function is required to use CALL, PUSH, and POP...
10
by: Bjorn | last post by:
I'm using interfaces in C++ by declaring classes with only pure virtual methods. If then someone wants to implement the interface they needs to inherit from the class. If the implementing class...
7
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I saw cuj's conformance roundup, but the result is quite old. I think many people like me want to know newer c++ standard conformance test...
0
by: rollasoc | last post by:
Hi, I seem to be getting a compiler error Internal Compiler Error (0xc0000005 at address 535DB439): likely culprit is 'BIND'. An internal error has occurred in the compiler. To work around...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
1
by: =?Utf-8?B?ZGxncHJvYw==?= | last post by:
Does anyone know if it’s possible to apply an ObsoleteAttribute to just the Get or Set of part a property in .NET 1.1? From my tests, I don't think you can, but I wanted to make sure. ...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
4
by: AshokG | last post by:
Hi, In .NET there is attribute named ObsoleteAttribute which is derived from System.Attribute Class. This attribute when applied to a target (class or method etc.) gives a compiler...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.