473,396 Members | 2,018 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,396 software developers and data experts.

CS0617: read-write attribute properties

Hi,

is there a reason for C# to require attribute arguments (properties) to be
read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won't work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #1
12 2003
Jens,

I believe it's an attempt on the part of the designers of the language
to enforce good design (the thinking being when would you write a value and
not be able to read it?).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

is there a reason for C# to require attribute arguments (properties) to be
read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won't work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!

Nov 16 '05 #2
Well,

isn't it my part to decide how I retrieve something from an attribute? In
this case, it's an int[] array, which was also the original design until it
turned out that the current VB.NET can't handle array attribute properties.

I think that this is an unnecessary design restriction, and both the VB and
C++ teams didn't follow this. Do you know a way to suggest this to the
"language designers"?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Jens,

I believe it's an attempt on the part of the designers of the language
to enforce good design (the thinking being when would you write a value and not be able to read it?).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

is there a reason for C# to require attribute arguments (properties) to be read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won't work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ Replace MSDN with my first name when replying to my email address!


Nov 16 '05 #3
http://msdn.microsoft.com/vcsharp/te...k/default.aspx

Have you considered using the constructor of the attribute to pass in your
array?

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Well,

isn't it my part to decide how I retrieve something from an attribute? In
this case, it's an int[] array, which was also the original design until it turned out that the current VB.NET can't handle array attribute properties.
I think that this is an unnecessary design restriction, and both the VB and C++ teams didn't follow this. Do you know a way to suggest this to the
"language designers"?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Jens,

I believe it's an attempt on the part of the designers of the language
to enforce good design (the thinking being when would you write a value and
not be able to read it?).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
Hi,

is there a reason for C# to require attribute arguments (properties)

to be read-write while VB and C++ are happy with only a setter?

Simplified Example:

public sealed class FooAttribute : Attribute
{
private string s;
public string Data { set { s = value; } };
}
[Foo(Data="bar")] won't work in C#, but in VB.NET and C++.

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ Replace MSDN with my first name when replying to my email address!



Nov 16 '05 #4
Oh, and you might want to checkout this video before sending feedback :)
(he's the guy you'll be emailing)

http://channel9.msdn.com/ShowPost.aspx?PostID=6186

"Andy Gaskell" <pubb AT hotmail DOT com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
http://msdn.microsoft.com/vcsharp/te...k/default.aspx

Have you considered using the constructor of the attribute to pass in your
array?

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Well,

isn't it my part to decide how I retrieve something from an attribute? In
this case, it's an int[] array, which was also the original design until

it
turned out that the current VB.NET can't handle array attribute

properties.

I think that this is an unnecessary design restriction, and both the VB

and
C++ teams didn't follow this. Do you know a way to suggest this to the
"language designers"?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/ Replace MSDN with my first name when replying to my email address!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote

in
message news:Oj**************@TK2MSFTNGP10.phx.gbl...
Jens,

I believe it's an attempt on the part of the designers of the language to enforce good design (the thinking being when would you write a

value and
not be able to read it?).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jens Thiel" <MS**@Thiel.de> wrote in message
news:uX**************@tk2msftngp13.phx.gbl...
> Hi,
>
> is there a reason for C# to require attribute arguments (properties)

to
be
> read-write while VB and C++ are happy with only a setter?
>
> Simplified Example:
>
> public sealed class FooAttribute : Attribute
> {
> private string s;
> public string Data { set { s = value; } };
> }
>
>
> [Foo(Data="bar")] won't work in C#, but in VB.NET and C++.
>
> Jens.
>
> --
> http://ManagedXLL.net/ | http://jens-thiel.de/ |

http://QuantLib.net/
> Replace MSDN with my first name when replying to my email address!
>
>



Nov 16 '05 #5
"Andy Gaskell" <pubb AT hotmail DOT com> wrote
http://msdn.microsoft.com/vcsharp/te...k/default.aspx

Have you considered using the constructor of the attribute to pass in your
array?


Yes, but I didn't check if this works with VB.NET. I need two of these
properties, min and max array lengths in multiple dimensions, both of them
optional. I now use a string "slices x rows x columns" (which is splitted
and parsed internally) and provide a dummy getter for C#.

Will check out the ask.... link and the video tomorrow. Thanks.

Jens.

--
http://ManagedXLL.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #6
Hi Andy,

Based on my understanding, you want to pass int array into attribute.

As I tried, this can be done in C#, but it seems that it will result in
error in VB.net. I will spend some time on this issue to find the reason
for you.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #7
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote
Hi Andy,

Based on my understanding, you want to pass int array into attribute.

As I tried, this can be done in C#, but it seems that it will result in
error in VB.net. I will spend some time on this issue to find the reason
for you.


Hi Jeffrey,

it's me, Jens, who asked the original question. I know that it can be done
in C#, but it is not supported in VB.NET (see the specs on attribute
properties). I heard that the Whidbey release will support it but I can't
tell my customers to wait that long. I already replaced the int[] with a
string that is parsed into an array internally.

The original topic was the CS0617 that you get when you try to set a
write-only property (see example in original post). I think it is an
unnecessary restriction to demand that an attribute property is read-write -
at least I can not see a reason why it is forced by C#, while VB.NET and
C++.NET are happy without it.

As Andy suggested, I emailed Eric Gunnerson. Don't know if he has time to
read his emails though. My suggestion would be to relax the "read-write
attribute property" requirement in a future release.

I'm otherwise happy and do not require a solution or workaround.

Jens.

--
http://ManagedXLL.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #8
Hi Jens,

Thanks for your feedback.

Yes, VB.net can not do this, I think this is the limitation of the
language.

For your originally concern of needing read-write property for attribute in
C# language, I will help you forword this to the our product group.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #9
Hi Jens,

I have got a reply from Eric Gunnerson, the PROGRAM MANAGER of Visual C#.

As he said, It's a deliberate choice.
http://blogs.msdn.com/csharpfaq/arch...11/130236.aspx

But, I think this does not resolve the write-only problem. I have consulted
him for write-only property issue. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #10
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote

I have got a reply from Eric Gunnerson, the PROGRAM MANAGER of Visual C#.

As he said, It's a deliberate choice.
http://blogs.msdn.com/csharpfaq/arch...11/130236.aspx

But, I think this does not resolve the write-only problem. I have consulted him for write-only property issue. Thanks


Thanks Jeffrey, as I mentioned in my previous post I had already contacted
Eric on this. I received his blog link, but it's a misinterpration of the
issue. Eric is already aware of it.

Jens.
--
http://ManagedXLL.net/
Replace MSDN with my first name when replying to my email address!
Nov 16 '05 #11
Hi Jens,

Yes, that blog article only talks about the read-only issue, which did not
resolve write-only issue. So I contacted Eric for the write-only property
issue.

Today, I got the feedback from him, that is:
"In general, I'd expect that most attribute classes are just containers for
information and don't have any real logic in them, and that's why the
design is the way it is."

So the answer for this issue is that: This is an expected behavior, the
Visual C# development team choose this type of design.

Also, I have asked Eric about why VB.net allow write-only property. The
answer is these 2 languages are developed by different teams, and VB.net
team just choose another different design for it.

I hope all these makes sense to you. But if you still have any concern,
please feel free to feedback here, I will assist you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #12
Hi Jens,

Does my reply make sense to you? Do you still have concern on this issue?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 16 '05 #13

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

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys! I have some datas that I must check everytime a visitor comes to my site What is better to do: 1- Read data from a file or 2- Read data from a mysql db Thank you
11
by: Sebastian Krause | last post by:
Hello, I tried to read in some large ascii files (200MB-2GB) in Python using scipy.io.read_array, but it did not work as I expected. The whole idea was to find a fast Python routine to read in...
2
by: Gunnar | last post by:
Hello, I've just written a CPP program that reads integers from a binary file, and used this code while (my_ifstram.read( (char* ) &number, sizeof(int)) { // do something with number } My...
4
by: francis70 | last post by:
Hi, I have these 2 problem? Is there a way in Oracle to read UNCOMMITED data. i.e. in Oracle the normal behaviour is that a user's updates to a table are visible to other users ONLY when the...
11
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
6
by: Steve | last post by:
Hi, I'm trying to convert a file reading loop into one using streams. The BSD OS read API returns the number of bytes read, but istream::read returns itself. How can I find out the number of...
12
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
2
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
4
by: Ollie Cook | last post by:
Hi, I am having some difficulty with read(2) and interrupting signals. I expect I am misunderstanding how the two work together, so would appreciate some guidance. I am trying to 'time out' a...
0
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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.