473,796 Members | 2,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attributes on interface property not enforced on concrete class

I added a property to an interface like this:
<code>
public interface ISimpleAddress
{
[Bindable(Bindab leSupport.Yes)]
[EditorBrowsable (EditorBrowsabl eState.Always)]
string CarrierFax{ get; set; }
}
</code>

I was disappointed to see that when I implemented the interface:
1) Visual Studio Refactoring-Auto-Implement tool didn't add the attributes
2) If I omitted the attributes from the concrete class the compiler didn't
complain.

Why do interfaces allow attributes if they won't be enforced?

Anyone know?
Jan 20 '08 #1
1 1697
On Jan 19, 11:07 pm, "Steve K." <no...@nowhere. comwrote:
I added a property to an interface like this:
<code>
public interface ISimpleAddress
{
[Bindable(Bindab leSupport.Yes)]
[EditorBrowsable (EditorBrowsabl eState.Always)]
string CarrierFax{ get; set; }}

</code>

I was disappointed to see that when I implemented the interface:
1) Visual Studio Refactoring-Auto-Implement tool didn't add the attributes
2) If I omitted the attributes from the concrete class the compiler didn't
complain.

Why do interfaces allow attributes if they won't be enforced?

Anyone know?
Attributes on an interface member aren't part of the interface
contract, they're modifiers for the member as *part of that
interface*. For example, you might use an attribute to affect whether
CarrierFax is displayed in the IntelliSense list for an ISimpleAddress
variable.

Jesse
Jan 20 '08 #2

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

Similar topics

50
6384
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong def foo(self, data): self.attr1=data self.attr2.append(data) The initialization of attr1 is obviously OK, all instances of Father redefine it in the method foo. But the initialization of attr2 is wrong
5
454
by: Doug Holland | last post by:
Often you see code where an empty interface is used to indicate something about the class that realizes it. In the .NET world this can be done with custom attributes too, so which is better: public class SomeClass : IEmptyInterface or
3
3371
by: Davide M3xican Coppola | last post by:
Hi, I would realize an interface (interface) for a pair of concrete classes (concrete & concrete2), but I have a problem because I have to access to a third class (element) and if I try to declare interface class as friend, I obtain this (right) error: main2.cpp: In member function `virtual void concrete::method(element&)': main2.cpp:8: error: `int element::a_int' is protected main2.cpp:31: error: within this context
1
8515
by: Microsoft | last post by:
Hello there, I have following situation , how can I solve this puzzle in C#. I have interface called IVendor with some custom attributes applied to it interface IVendor {
7
1919
by: tron.thomas | last post by:
Please consider the following code: class Abstract { public: virtual ~Abstract() {} virtual void Method() = 0; }; class Concrete : public virtual Abstract
5
1349
by: Eric | last post by:
Hi, I am kind of new to OO and I have the following problem : I have a class containing a huge list of functions for accessing an SQL database. Public Class Transaction #region "Client" Public function GetClientInfos() as Dataset ... Public sub InsertClientInfos() ...
0
1571
by: mvanroshum | last post by:
Hi, I have the following problem: The DataSource of a DataGrid can be set to an IList. The DataGrid nicely lists the objects in the IList, showing all the public properties of the objects as the columns of the datagrid... The public properties with a primitive type are shown The public properties with userdefined types are also shown, using the eventually overridden ToString method.
5
3672
by: florin | last post by:
hi Is there a "simple" way to add attributes to a class/property at runtime? What I try to do is set the default editor for a class/property at runtime (I know I can set this very easy by decorating the class/ property code), but I would like to do this at runtime. Is there another way to tell the PropertyGrid what editor to use for a
26
1910
by: tjhnson | last post by:
Hi, With properties, attributes and methods seem very similar. I was wondering what techniques people use to give clues to end users as to which 'things' are methods and which are attributes. With ipython, I use tab completion all the time, but I can rarely tell from the names alone whether it is an attribute or method. Tips? Ideas? Best practices?
0
9680
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
9528
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
10230
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9052
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
7548
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
5442
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...
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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.