How to resolve type name
Hi!
I was struggling with this for over 6 hours and I can't figure out how to do this. Suppose I have a type name like 'InvalidOperationException'. I want to resolve that string to be able to get a qualified CLR name. I'd like to get something like IDeclaredType to be able to call GetCLRName().
Can you show me how to do this?
I tried:
var type = new DeclaredTypeFromCLRName(new CLRTypeName("InvalidOperationException"), declaration.DeclaredElement.Module);
type.Resolve();
but with no luck.
Thanks in advance for your help.
Bartek.
Please sign in to leave a comment.
Hello Bartek,
I don't know if this blog post will be any help - it depends if you have
a fully qualified type name and not just a partial.
http://agentjohnsonresharper.blogspot.com/2008/09/tip.html
--Jakob
Am I right saying that you'd like to get all classes with short name
"InvalidOperationException" visible from solution?
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
<no_reply@jetbrains.com> wrote in message
news:4718851.21221222377607160.JavaMail.jive@app4.labs.intellij.net...
>
>
>
>
>
I would rather say that I want resolution in the context of current file.
Regards,
Bartek.
Please clarify, what do you mean "in context of cuurent file".
Does this mean "at the exact point of the file, using all
imports/namespaces"?
if so, the use the following:
var type = CSharpTypeFactory.CreateType ("InvalidOperationException",
....some point in file......) as IDeclaredType
if (type != null)
{
var typeElement = type.GetTypeElement();
if (typeElement != null)
....use.... typeElement.CLRName
}
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
<no_reply@jetbrains.com> wrote in message
news:9440223.1441224063470116.JavaMail.jive@app4.labs.intellij.net...
>I would rather say that I want resolution in the context of current file.
>