Is there a way to get a list of interface members? I know about System.Reflection.MemberInfo, but it includes everything in an object, not just a certain interface.
Here is the program, I'm not sure how to get you the interface as I didn't write it, but it is part of the Ascom Standard (http://ascom-standards.org).
public static void Test1()
{
Console.WriteLine("mark1"); // this shows up...
var type = typeof(Ascom.Interface.ITelescope);
var members = type.GetMembers();
Console.WriteLine(members.Count); // gives 0
foreach (var member in members)
{
Console.WriteLine(member.Name); //nothing from here
}
Console.WriteLine("mark4"); // ...as well as this
}
Interface members are public by default, and you can explicitly specify accessibility modifiers, such as public , protected , internal , private , protected internal , or private protected . A private member must have a default implementation.
The default access level for all interface members is public . Interfaces may not declare instance constructors, destructors, or fields.
Interfaces can't have private members. By default all the members of Interface are public and abstract. The interface will always defined with the help of keyword 'interface'. Interface cannot contain fields because they represent a particular implementation of data.
From MSDN:
typeof(IList).GetMembers()
Gets the members (properties, methods, fields, events, and so on) of the current Type.
If it is a COM interface, then you should disable "Embed Interop Types", otherwise it will only insert used members in the assembly. I guess you don't use any methods/properties from that interface in the assembly, that's why they never get inserted, so you can list them with reflection. (Thx OWO)
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