Why is this a C2327?

  • Thread starter Thread starter Noah Stein
  • Start date Start date
N

Noah Stein

I'm getting a C2327 on something along the lines of this:

public ref class A
{
public:
virtual property String ^ DisplayName { String ^ get() override; }

[System::ComponentModel::DisplayName("Type")]
property Object ^ Type { Object ^ get(); }
};


I can't see why C2327 should apply. I'm guessing it falls into the category
explained by example b. I'm wondering why this shouldn't be allowed. Where
is the ambiguity?

This has some fairly big repurcussions if this is intentional. Does this
mean that I now have to avoid using any name as a property that might appear
as an attribute? How can I possibly know what attributes MS plans to add in
the future? What about 3rd party attributes? If I use a 3rd party library
that uses attributes, am I then supposed to go through my entire codebase
changing property names to eradicate the conflict?


Thanks,
Noah
 
Noah Stein said:
I'm getting a C2327 on something along the lines of this:

public ref class A
{
public:
virtual property String ^ DisplayName { String ^ get() override; }

[System::ComponentModel::DisplayName("Type")]

have you tried using DisplayNameAttribute spelled out?
 
Ben Voigt said:
Noah Stein said:
I'm getting a C2327 on something along the lines of this:

public ref class A
{
public:
virtual property String ^ DisplayName { String ^ get() override; }

[System::ComponentModel::DisplayName("Type")]

have you tried using DisplayNameAttribute spelled out?

That works fine. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top