I use the IVsObjectList2.GetCategoryField2
method to retrieve different information of a type.
Now I wonder how I can retrieve C# specific information like abstract
or internal
modifier of a type?
The Object Browser can displays this informations.
Update 1:
I have made another attempt to get this information. Via the DynamicTypeService
and the IVsHierarchy
(of the project) I can get the TypeResolutionService
. This can then return the Type
I'm are looking for, and form the Type I get the infomrations (internal, abstract, etc.)
Unfortunately, this only works with .NET Framework projects. .NET Core projects don't work. The assumption is that .NET core projects cause problems when resolving, because the VS add-in (or Visual Studio SDK) run under .NET Framework.
var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;
var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte);
IVsSimpleObjectList2 objectList;
....
objectList.CountSourceItems(index, out var vsHierarchy, out var itemid, out var pcItems);
DynamicTypeService dynamicTypeService = (DynamicTypeService)serviceProvider.GetService(typeof(DynamicTypeService));
var typeResolutionService = dynamicTypeService.GetTypeResolutionService(hier);
var type = typeResolutionService.GetType("ObjectBuilder.ObjectBrowserTestTypes.AbstractTestClass");
More Infos here: Visual Studio Extension get all classes and interfaces metadata
I'm still looking for a solution. Does anyone have another idea?