IntelliSense/code analysis won't pick up .NET classes generated by MSBuild?

Hi,

We have a developer tool that contains the following components:
a MSBuild extension to generate C#/VB.NET classes from a custom file format;
project and item templates for developers to create files of that format in Visual Studio;
...

A common routine for developers to use this tool is:
create a C#/VB.NET project (either by using the project template or not);
add a file of the custom format, and edit the file. The file generally contains class and property definitions;
create other C#/VB.NET classes (either partial to the ones defined in the custom file, or helpers to manipuate those classes) in the same project;
build the project. This step invokes the custom MSBuild extension which generates C#/VB.NET classes based on the file created in step 2, and places the generated files in obj\;
create other projects and reference the one created in step 1;
...

This approach has been working really well for us. Without having to build the project between step 2 and 3, Visual Studio's intellisense can automatically pick up the classes and properties defined in the custom file.

However, with Resharper (v6.0.2202.688), we noticed that regardless of whether we are building the project between step 2 and 3, Resharper's intellisense won't work and its code analysis keeps reporting errors on those classes and properties. So I'm wondering if any one could shed some light on whether this is a bug in ReSharper, or there is something we could do to workaround it. Basically, we just need ReSharper's intellisense to play more nicely with code generated by MSBuild.


A few other notes:

<CoreCompileDependsOn>$(CoreCompileDependsOn);MyCustomCompile</CoreCompileDependsOn>

<Target Name="MyCustomCompile" DependsOnTargets="ResolveReferences">
   ...
   <Move SourceFiles="@(_GeneratedCompile)" DestinationFolder="$(IntermediateOutputPath)" OverwriteReadOnlyFiles="true">
      <Output TaskParameter="MovedFiles" ItemName="Compile"/>
      <Output TaskParameter="MovedFiles" ItemName="FileWrites"/>
   </Move>
   ...
</Target>

Also, based on this post and a few other reasons, we decide not to use Custom Tool in Visual Studio, so please don't suggest this as a workaround.


Thanks in advance,
Mark

9 comments
Comment actions Permalink

Hello Mark
     If these generated files are not included in your project in Visual Studio, there's no way for ReSharper to find out that these files are related and take them into account. As a workaround, you can compile these generated files into a separate assembly and include a reference to that assembly in your project. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hi Andrey,

Thanks for the reply. Just want to clarify one thing: from what you're saying, unlike VS, ReSharper doesn't use MSBuild in the background to resolve symbols, does it?


Cheers,
Mark

0
Comment actions Permalink

Hi,

I am still hoping someone could answer the question I have in my reply to Andrey's post: Does ReSharper use MSBuild in the backgound to find/resolve symbols?


Thanks,
Mark

0
Comment actions Permalink

Hello Mark
     Sorry for delayed response! No, ReSharper doesn't use MSBuild during code analysis. However, when a solution has a web site, ReSharper occasionally builds that web site so that the analysis is correct. We could also build each project during analysis, but that would impose a huge performance impact and it's hard to find out which of the generated files should be included into analysis. We've already received similar requests and we will discuss if this problem can be addressed in one of the future releases. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Any ways to workaround this in the newer versions? I have the same issue with ReSharper 8.1

0
Comment actions Permalink

Same issue with ReSharper 9 too. Also, R#9 seems to have taken away the possibility of adding "External Code", which seems that would have helped me in this case, although I haven't tried it... should I go back to ReSharper 8.1 to get this functionality or is it hidden somewhere in 9 too?

0
Comment actions Permalink

Hello,

Theoretically, R# Options | Environment | General | MSBuild access section
should be dealing with that.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0
Comment actions Permalink

Thanks for the response, but unfortunately this didn't work either. A bug was created at https://youtrack.jetbrains.com/issue/RSRP-432373

Thanks,
Julian

0
Comment actions Permalink

Hello,

Thanks for the response, but unfortunately this didn't work either.


I've heard there're problems around that functionality, yet I don't know
the particulars. That's why it were put as "theoretically". But should it
work as intended, it would be addressing right the generated files in question.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Please sign in to leave a comment.