And what about IProject? It seems that CSharpElementFactory has a GetInstance method that takes an IProject. Can I create that too? Basically, I would like to create a ICSharpFile to use as a a test object...
And what about IProject? It seems that CSharpElementFactory has a GetInstance method that takes an IProject. Can I create that too? Basically, I would like to create a ICSharpFile to use as a a test object...
CSharpElementFactory.GetInstance(null).CreateFile(@" enum MyEnum { First, Second } ");
But I get a null ref exception inside GetInstance(). From what I can tell with Reflector it seems to be due to the project.GetSolution() call in the CSharpElementFactoryImpl .ctor.
But I get a null ref exception inside GetInstance(). From what I can tell with Reflector it seems to be due to the project.GetSolution() call in the CSharpElementFactoryImpl .ctor.
I'm sorry, but your answer contradicts your previous one. Perhaps there's a misunderstanding. I'll rephrase my question: given a string:
string classText = @"using System;
public class MyClass { public int Number = 5; } ";
How can I turn this text to an instance of an IFile, without (known) ISolution/IProject. Furthermore, this should happen during an external unit test, not while the plugin is runnig.
I was wrong saying it is safe to pass 'null' :( All ReSharper utility methods require valid solution/projects to be opened. If you would like to access ReSharepr services in your tests, then you need to open some empty solution in the memory, for example:
var solution = SolutionManager.Instance.CreateSolution(...) vap project = solution.CreateProject(...)
-- Eugene Pasynkov ReSharper Technical Lead JetBrains, Inc. http://www.jetbrains.com "Develop with pleasure!"
I'm sorry, but your answer contradicts your previous one. Perhaps there's a misunderstanding. I'll rephrase my question: given a string:
>
string classText = > @"using System; > > > public class MyClass > { > public int Number = 5; > } > ";
>
How can I turn this text to an instance of an IFile, without (known) ISolution/IProject. Furthermore, this should happen during an external unit test, not while the plugin is runnig.
Use CSharpElementFactory.CreateFile method
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
"Igal Tabachnik" <no_reply@jetbrains.com> wrote in message
news:18057083.201233740951684.JavaMail.clearspace@app4.labs.intellij.net...
>
>
>
And what about IProject? It seems that CSharpElementFactory has a GetInstance method that takes an IProject. Can I create that too? Basically, I would like to create a ICSharpFile to use as a a test object...
You can pass "null" there
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
"Igal Tabachnik" <no_reply@jetbrains.com> wrote in message
news:8854187.17201233877062086.JavaMail.clearspace@app4.labs.intellij.net...
>
Hi Eugene,
Here's how I'm interpreting what you are saying:
But I get a null ref exception inside GetInstance(). From what I can tell with Reflector it seems to be due to the project.GetSolution() call in the CSharpElementFactoryImpl .ctor.
No, you can't pass 'null' here.
You should get valid IPsiModule for any project in your solution
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
"jbuedel" <no_reply@jetbrains.com> wrote in message
news:20832618.11101234650333180.JavaMail.clearspace@app4.labs.intellij.net...
>
>
>
I'm sorry, but your answer contradicts your previous one. Perhaps there's a misunderstanding.
I'll rephrase my question: given a string:
How can I turn this text to an instance of an IFile, without (known) ISolution/IProject. Furthermore, this should happen during an external unit test, not while the plugin is runnig.
Thanks,
Igal.
I was wrong saying it is safe to pass 'null' :( All ReSharper utility
methods require valid solution/projects to be opened.
If you would like to access ReSharepr services in your tests, then you need
to open some empty solution in the memory, for example:
var solution = SolutionManager.Instance.CreateSolution(...)
vap project = solution.CreateProject(...)
--
Eugene Pasynkov
ReSharper Technical Lead
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
"Igal Tabachnik" <no_reply@jetbrains.com> wrote in message
news:13663024.8101234911432599.JavaMail.clearspace@app4.labs.intellij.net...
>
>
>
>