Question

I'm trying to build a Visual Studio 2010 vsix add on to alter (to start with just add and delete) using statements in a c# document. Using the FileCodeModel on the current ProjectItem I can see how to add classes, structs etc, but not using directives. Can anyone advise me on this?

Was it helpful?

OTHER TIPS

I've solved the problem. I can recursively analyze for CodeImports on the FileCodeModel which gives me a list of the current using directives. Unfortunately I can't find any AddCodeImport method in FileCodeModel and so presume it doesn't exist. As a result when I'm inserting using directives I've had to perform get the TextPoints associated with the last CodeImport (within the current namespace scope) and insert the using directive as text there.

This works fine, but I don't quite understand why there is no AddCodeImport method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top