Resharper does not detect generated types

I am developing a visual studio extension and I have a potential R# bug to report. My extension involves an msbuild task that performs a transformation on the code file and generates a C#/VB file during the build. That file gets added to the list of Compile items and ends up in the compiled assembly. It may generate any number of classes in that way. When I am not using R# the default language service finds the generated types just fine and highlights them properly, when using R# the types are displayed Red as if they were unknown, despite the successful build and lack of errors.

I do have a VS extension that I am using to provide highlighting information for this custom code file, is there a way for me to communicate Type information to R# such that it will successfully detect my generated types?

4 comments

Hello Justin,

As far as I can see now, this appears to be a known behavior for ReSharper.

Currently, ReSharper doesn't support this kind of "dynamic references" for Code Analysis for now.

To have a successful analysis, the references/files should be referenced strictly as a part of the project/solution.

Thank you.

0

Thank you for confirming my suspicions but you're also saying there is nothing I can do about it and no hope for this to get fixed? So there is no CodeModel object that I can work with to create Types from in my extension? If I need to implement some interfaces and write some tough code I probably could.

0

I believe if your extension is generating dome kind of files (.cs of .dll), the only way to workaround this is to add this file to you project/solution everytime it's changed. Maybe this can be achieved with custom macros or another extension.
We apologize for the inconvenience.

Thank you.

0

Well I am generating this file from a semantic model. Meaning I'm parsing a DSL, internally I have a code model of this DSL, then I generate a codefile which ends up as part of the build and living side-by-side the C#/VB in the built assembly. It would be possible for me to update any code model that R# has from within my extension if there were such API's exposed. I just have no idea if there are or not, or where to begin.

Also, it might be worth mentioning that I believe that the VS intellisense and highlighter is using both it's internal code model of the code files and the last built dll. R# might want to do that in future versions for just this reason.

0

Please sign in to leave a comment.