I'm currently working on a library that's to be exposed to COM for use in a legacy project that's being upgraded. I'm creating interfaces that are to be exposed, and they have properties on them with long, int, etc types. Using the DescriptionAttribute, I can get helpstrings generated in the .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 a helpstring generated in the TLB output for properties ?
The [helpstring] attribute specifies a character string that is used to describe the element to which it applies. You can apply the [helpstring] attribute to library, importlib, interface, dispinterface, module, or coclass statements, typedefs, properties, and methods.
What does the AttributeUsage do in MVC4 11 Cascading the effect of an attribute to overridden properties in child classes 4 C# Attribute inheritance not working as I would expect
Last Updated : 05 Dec, 2018 Attributes are one of the key features of modern C++ which allows the programmer to specify additional information to the compiler to enforce constraints (conditions), optimise certain pieces of code or do some specific code generation.
In order for the DescriptionAttribute to return a localized string, it requires a resource key and, ideally, /// a type reference as the base-key for the ResourceManager. A DescriptionAttribute could not provide this information without /// a reference to it's target type.
You have to put the attribute on the getter and setter individually. 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 clumsy, but also required in IDL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With