Description Attribute vs. <summary> for properties

I am writing a class library in C # under VS 2005 (I know, I get it with modern times, but we are here with a limited budget).

It seems to me that if I use the "final" tag in the XML documentation, my users can see this information through Intellisense and tooltips, etc., but not in the Properties window in Studio.

To get something in this window, I seem to need to use the [Description("This is it")] attribute.

Am I right about this? If so, then it seems to me that I need to duplicate the description information :-(

Or is there a better way? Thanks!

+4
source share
3 answers

Yes this is correct. These two methods have different goals.

  • Comments /// <summary></summary> are used to create XML documentation for your project at compile time, which Visual Studio also parses for its IntelliSense database.

  • [DescriptionAttribute] contains the description text that is used in the designer, especially at the bottom of the properties window.

In Microsoft Windows Forms, the library is littered with both of these.

I don’t know how to merge these two, but think about whether you really want them to be exactly the same. In my own class libraries, I often want to display a little bit of information in the designer than I want to include in my technical documentation.

As a simple example, I could make it clear in the designer that this property is not supported in certain versions of Windows, but cancel this information in the <remarks> section in my technical documents:

 /// <summary> /// Gets or sets a value indicating whether a shield should be displayed /// on this control to indicate that process elevation is required. /// </summary> /// <remarks> /// The elevation-required shield is only supported under Windows Vista /// and later. The value of this property will be ignored under earlier /// operating systems. /// </remarks> [Category("Appearance")] [Description("Displays a shield to indicate that elevation is required. " + "(Only applies under Windows Vista and later.)")] public bool ShowShield { get; set; } 
+7
source

The XML doc summary tag and description attribute are two completely different things .

The summary tag is for use in DOCUMENTATION for a component.

The description attribute is part of the contols component model and is available internally at runtime . This means that the information is compiled into your binary assembly file. Potentially, the contents of the description attribute are even visible to the end users of your application (for example, when using the PropertyGrid control).

If you are looking for documentation, use only an XML document. If you want to create a reusable component, you can also use the Description attribute.

+1
source

I understand that you are right. However, you can automate most of this work with GhostDoc , which has a free version that you can configure to add to your Description attribute.

0
source

Source: https://habr.com/ru/post/1346583/


All Articles