How to configure Resharper to work together with source generators in Visual Studio 2022?

46 views Asked by At

(Note: this question is not logging related, and also not related with Microsoft's logging source generator. Resharper behaves exactly this way with any other source generator, I just using LoggerMessageAttribute as example.)

I have the following method which is using LoggerMessageAttribute to trigger Microsoft logging source generator:

public partial class Logger
{
    [LoggerMessage(Level = LogLevel.Information, Message = "Generating {ForecastCount} forecasts")]
    public static partial void GeneratingForecasts(ILogger logger, int forecastCount);
}

My application compiles and runs properly, my issue is related to the developer experience. When I ctrl+click on GeneratingForecasts method if Resharper is active it opens a new text editor tab, with empty content, even after a successful build. The title on the tab is logging.g.cs, which seems to be correct, but obviously Resharper is looking the generated file in the wrong place, or something else is going wrong.

If I turn off Resharper, and do nothing else, then Visual Studio's own ctrl+click on GeneratingForecasts method navigates correctly to the generated source.

What am I missing?

Visual Studio version: 17.8.0 Resharper version: 232.0.20231101.132807 built on 2023-11-01

1

There are 1 answers

0
Mary Pleskunina On

Please try installing the latest ReSharper - 2023.3.2, this should help. The issue appears to be fixed as it is not reproducible in this version.