Get XMLDoc for Constructor called in IObjectCreationExpression Follow
Suppose I have a statement:
var o = new MyObject();
when the cursor is on the MyObject() call, I have a context action that is looking for the XML Documentation of the called constructor.
So when I see the element is an IObjectCreatinExpression, I use the following code:
var reference = creationExpression.ConstructorReference;
if (reference == null) return false;
var resolveResult = reference.CurrentResolveResult;
if (resolveResult == null) return false;
var declaredElement = resolveResult.DeclaredElement;
if (declaredElement == null) return false;
var xmlNode = declaredElement.GetXMLDoc(true);
xmlNode is always null, even when I know there is XML documentation on the constructor.
I can see the XMLDocId is there, and the method above works when calling it on an IInvocationExpression.
Is there a reason it is returning null, or a better way to get the documentation?
Is it possible to get it by XmlDocId?
Please sign in to leave a comment.
Hi Mike. The XmlDocId is always there - it's generated from the type or type member name, and doesn't touch the xml docs at all.
With the test you're using - can you just confirm that the xml doc is on the constructor and not on the type? Are you trying to get the XML docs for a constructor declared in source, or in a compiled assembly?
Could you tell me what type the declaredElement is, please?
And finally, is this ReSharper 8 or 9?
Thanks
Matt