Can't reverse SourceProjectContent.LoadForFile

SyntaxEditor .NET Languages Add-on for Windows Forms Forum

Posted 8 years ago by Brook Hunter
Avatar
Hello,

I am using the SyntaxEditor with the .NET Languages Add-On to provide Intellisense for C# files that I can 1) Add and 2) Exclude from my project.

I am able to successfully get intellisense appearing for newly added files by using the following code:

_dotNetProjectResolver.SourceProjectContent.LoadForFile(_cSharpSyntaxLanguage, myFullFilePath);

However, when I remove a single file from my project, I am unable to reverse this process, because I can't find any kind of method like:

_dotNetProjectResolver.SourceProjectContent.RemoveForFile(_cSharpSyntaxLanguage, myFullFilePath);

Also, the following code doesn't remove the Intellisense for a file just removed from my project:

_dotNetProjectResolver.SourceProjectContent.Clear();

How can I get the Intellisense to go away for a C# code file that was first added to Intellisense via _dotNetProjectResolver.SourceProjectContent.LoadForFile(_cSharpSyntaxLanguage, myFullFilePath); ?

Thank you very much in advance,

Brook

Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Brook,

The SourceProjectContent.Clear method removes source file reflection data. Such as in our .NET Reflection QuickStart, if we add this line in response to a toolbar button click, the quick info for the ColorButton class no longer works since the source file data for it has been removed:
dotNetProjectResolver.SourceProjectContent.Clear(Program.ProjectPath + @"ColorButton.cs");


Actipro Software Support

Posted 8 years ago by Brook Hunter
Avatar
Hello,

Thanks for the tip. I tried this, and it didn't work in my situation, because I forgot to tell you something else that is probably causing the problem, which I also can't figure out how to fix:

In addition to adding each file that is added to my project to Intellisense with the following line:

_dotNetProjectResolver.SourceProjectContent.LoadForFile(_cSharpSyntaxLanguage, myFullFilePath);

I also add support dynamically compiling all the C# code files into an assembly, which I also add to Intellisense when the application starts up, using the following code:

_dotNetProjectResolver.AddExternalReference(MyDllFilePath);

The problem is, even though I remove the Intellisense from the code file with the code you showed me (dotNetProjectResolver.SourceProjectContent.Clear(MyFilePath);), the Intellisense is still showing up.

Do I need to write another line of code to tell the Intellisense that my assembly's compiled code has changed, i.e. no longer has the compiled code from the file I just removed?

Thanks a lot,

Brook
Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Brook,

If you are loading duplicates (via source and binary) of the same types, that isn't really a good thing to do. You should only do one or the other.

Once an assembly is loaded and since an assembly is a large unit of code, you'd either need to refresh it in its entirety (via AssemblyCodeRepository.Refresh) or remove it as a reference altogether (via DotNetProjectResolver.RemoveExternalReference), whichever thing is appropriate for your scenario.


Actipro Software Support

The latest build of this product (v2018.1 build 0341) was released 6 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.