Rider/ReSharper ignoring generated code
Answered
I have a .net core c# csproj with a BeforeTargets="CoreCompile" target. This target uses protoc to generate .cs files in $(BaseIntermediateOutputPath) (obj), and then adds them to the Compile group of the csproj. Everything there works fine and the types end up in the compiled assembly.
The issue is that I am unable to get Rider/ReSharper to identify these generated types and add them to the Intellisense. Does anyone know how to get ReSharper to recognize code generated as part of the build process?
I have tried adding the folder and file mask to the Generated Code settings, as well as adding the output cs files as <None> targets in the csproj.
<Target Name="CompileProto" BeforeTargets="CoreCompile">
<PropertyGroup>
<ProtoOutputPath Condition="'$(BaseIntermediateOutputPath)'!='' ">$(BaseIntermediateOutputPath)</ProtoOutputPath>
<ProtoOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">obj</ProtoOutputPath>
</PropertyGroup>
<ItemGroup>
<Protos Include="protos/*.proto" />
</ItemGroup>
<MakeDir Directories="$(ProtoOutputPath)" />
<Exec Command="protoc -I=protos/ --csharp_out=$(ProtoOutputPath)/ --csharp_opt=file_extension=.g.cs @(Protos, ' ')" />
<ItemGroup>
<GeneratedProtos Include="$(ProtoOutputPath)/*.g.cs" />
<Compile Include="@(GeneratedProtos)" />
<FileWrites Include="@(GeneratedProtos)" />
</ItemGroup>
</Target>
Please sign in to leave a comment.
You can try to change BeforeTargets="CoreCompile" to BeforeTargets="ResolveAssemblyReferences". With it, Rider must detect the generated code.