Getting the helpstring attribute applied to C # properties opened through COM interfaces

I am currently working on a library that will work with COM for use in an outdated project that will be updated. I am creating interfaces that should be open, and they have properties with long, int, etc. Using DescriptionAttribute, I can get helpstrings generated in .tlb for interfaces, classes and methods, but for some reason it doesn't seem to want to work for properties. Is there anyway to get the helpstring generated in the TLB output for the properties?

+6
source share
1 answer

You must put the attribute in getter and setter separately. Like this:

using System; using System.ComponentModel; using System.Runtime.InteropServices; namespace ClassLibrary1 { [ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IFoo { int property { [Description("prop")] get; [Description("prop")] set; } } } 

Repeating the description is inconvenient, but also required in the IDL.

+8
source

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


All Articles