473,785 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2027
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.co m

"Jens Thiel" <MS**@Thiel.d e> wrote in message
news:uX******** ******@tk2msftn gp13.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.c om> wrote in
message news:Oj******** ******@TK2MSFTN GP10.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.co m

"Jens Thiel" <MS**@Thiel.d e> wrote in message
news:uX******** ******@tk2msftn gp13.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.d e> wrote in message
news:OP******** ******@TK2MSFTN GP09.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.c om> wrote in message news:Oj******** ******@TK2MSFTN GP10.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.co m

"Jens Thiel" <MS**@Thiel.d e> wrote in message
news:uX******** ******@tk2msftn gp13.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******** ********@TK2MSF TNGP09.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.d e> wrote in message
news:OP******** ******@TK2MSFTN GP09.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.c om> wrote

in
message news:Oj******** ******@TK2MSFTN GP10.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.co m

"Jens Thiel" <MS**@Thiel.d e> wrote in message
news:uX******** ******@tk2msftn gp13.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.mi crosoft.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

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

Similar topics

10
5332
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
9035
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 arbitrary ascii files, to replace Yorick (which I use right now and which is really fast, but not as general as Python). The problem with scipy.io.read_array was, that it is really slow, returns errors when trying to process large files and it...
2
9004
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 question is now, where can I find a manual that describes what the read method does with the ifstream object? I'm sitting here with my Linux/Debian machine, but I have not found any
4
40277
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 user commits. But in Informix there is this thing called ISOLATION LEVELS. For example by setting the ISOLATION LEVEL to DIRTY READ, a user will read dirty data, i.e. the last uncommited updated value of a field by some other user. Is
11
12722
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 read the new date. So process B starts "select ..." but does not get the previously inserted row. The timespan between commit and select is very short. (NOTE: two different sessions are used) Questions: 1.) Does commit when returning from call...
6
3477
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 bytes actually read? What the code fragment should do is read up to 1000 bytes into a buffer, or finish early if reading failed. Just your average read loop. I have: (this is a simplified version; I know there's no detailed error
12
11666
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 currently have as a test for using std::ifstream::read(). Is there anything wrong with the way I'm getting the file? #include <vector> #include <iomanip> #include <fstream> #include <iostream>
2
3092
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 this by aggregating new content from all databases into a single indexed database and then saving a timestamp in the account database (for the current user) that tells me when the user last read items in the aggregated database.
4
3847
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 socket read after a certain delay. The logic is (I will provide a test program below): - create and connect socket
0
4757
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 the client application establish a connection, and send data, which appears in plain, de-crypted text on the server - this works.
0
9646
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9484
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8983
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7505
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5518
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.