Adding extra types to DotNetProjectResolver

SyntaxEditor .NET Languages Add-on for Windows Forms Forum

Posted 16 years ago by John Corbett - Software Architect, SonarData Pty. Ltd.
Avatar
Hi,

I'm using your C# add-on and going very well. I am writing an "expression evaluator" (actually a code editing window, but with a very limited and tightly controlled API). I am only adding a couple of my own "API" assemblies to compile/link the code against, and also adding these to the DotNetProjectResolver. I am deliberately not adding mscorlib as a reference when I compile, and I'm not adding it to DotNetProjectResolver either. This is because I don't want my end user to be able to access much of the system API (due to confusion and security issues in my situation)

My code compiles fine, and mostly the intellisense works well too. I have one problem though; there are members on the built-in types such as "string" (for instance, "string.Clone()") that I want to appear in Intellisense, that don't. By rights I think they ought to, because even though I don't compile against mscorlib, these methods are available. But I don't see them in Intellisense.

I tried the following but couldn't make it work; maybe you can help me or suggest something else ...
1- I thought that I could add mscorlib as a reference and then use something like DotNetProjectResolver.GetNativeType("System.String") to obtain something along the lines of a CodeDomCompiledUnit ...

2- which I could add into the DotNetProjectResolver along the lines of http://www.actiprosoftware.com/Support/Forums/ViewForumTopic.aspx?ForumTopicID=1789.

3- then unload mscorlib as a reference.

If I get a CodeDomCompiledUnit from the SemanticParser, I can add it to the DotNetProjectResolver. But I can't get the CodeDomCompiledUnit out of the DotNetProjectResolver for System.String. I don't know if it is possible. Can you assist me?

My fallback position is to create some "dummy" source files containing definitions for "System.String" (such as produced by VS, by clicking on "Go to definition" of System.String - constructed by metadata), which is kind of ok but messy. I'd rather get the "already compiled" intellisense out of the DotNetProjectResolver.

Best regards
John

Comments (4)

Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi John,

Let me suggest a different direction for this. In the docs for the .NET add-on, check out the Member List Pre-Filtering topic. That lets you add/remove member list items before the list is displayed. This way you could remove members that you don't want visible and still leave mscorlib included. Would that work better for you?


Actipro Software Support

Posted 16 years ago by John Corbett - Software Architect, SonarData Pty. Ltd.
Avatar
Hi,

I did also think of that as well, but I thought it was a bit of a "roundabout" route, to add a System reference to the project resolver (even though I don't link my code against that assembly) and then filter out all the guff that it adds just to leave a few methods (like string.Split) which presumably must not be in mscorlib anyway, since it is no problem to call them without linking to that assembly.

That being said, that is now what I am doing and it works fine!

Thanks for the direction,
John.
Posted 16 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You could go the other direction too though... maybe not include System and then when string is passed, use the filter feature to add items in for it. You'd have to determine the items to add yourself though and would probably have to add the appropriate documentation comments too. So in this case, it would be similar to your idea of making a custom source code class that defines string, except here you would be populating the data programmatically.


Actipro Software Support

Posted 16 years ago by John Corbett - Software Architect, SonarData Pty. Ltd.
Avatar
Thanks for your assistance. For now, I've implemented the "filtering out" technique and it works fine.
The latest build of this product (v24.1.0) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.