Dotnet build is using old version of IIncrementalGenerator

39 views Asked by At

I have this IIncrementalGenerator which I'm trying to make work on MacOS and while fiddling with it on Windows I came across strange behavior which drives me crazy. I basically remove all contents of the generator so it's empty - does not emit anything and certainly does not throw any exceptions. Like so:

[Generator]
public sealed class LanguageClassMakerGenerator : IIncrementalGenerator
{
    public void Initialize(IncrementalGeneratorInitializationContext context)
    {

    }
}

Now when I run dotnet build I see exception from the source generator in the console and subsequent build issues stemming from the fact generator did not run.

I tried <DisableIncrementalBuild>true</DisableIncrementalBuild>

I tried dotnet clean

and I deleted bin and obj folders.

I have no clue from where dotnet build takes this version of a source code which throws an error. Its virtually impossible if it has a correct file. I'm losing my mind here.. WTAF

UPDATE: When I make new solution and put there new console app and source generator and connect everything the source generator works as expected (When I revert the deletion and have working version of the generator). Then I run dotnet build of the original project and the output is still the same with the exception..

UPDATE: I renamed the generator and now I have warning:

CSC : warning CS8032: An instance of analyzer ClassLibrary1.LanguageClassMakerGenerator2 cannot be created from C:\dev\
LocTest\ClassLibrary1\bin\Debug\netstandard2.0\ClassLibrary1.dll : Could not load type 'ClassLibrary1.Languag
eClassMakerGenerator2' from assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.. [C:\dev\C
AT\Turbo\LocTest\ConsoleApp1\ConsoleApp1.csproj]

Which I read as the Roslyn compiler knows about new updated type of generator (LanguageClassMakerGenerator2) but uses old DLL which does not contain update type..

0

There are 0 answers