AArnott / CodeGeneration.Roslyn

Assists in performing Roslyn-based code generation during a build.
Microsoft Public License
408 stars 59 forks source link

CodeGeneration.Roslyn doesn't respect CustomAdditionalCompileInputs #127

Open Pzixel opened 5 years ago

Pzixel commented 5 years ago

My code generator has addiitonal inputs beside C# files. So I add

<ItemGroup>
    <CustomAdditionalCompileInputs Include="**\*.sol" />
</ItemGroup>

to the project. VS correctly starts build when file gets edited, but CodeGenerator.Roslyn doesn't regenerate files. I only see

1>------ Build started: Project: Solidity.Roslyn.Example, Configuration: Debug Any CPU ------
1>Build started 16.04.2019 14:58:55.
1>Target _GetProjectReferenceTargetFrameworkProperties:
1>Target ResolveProjectReferences:
1>  Target GetNativeManifest:
1>Target PrepareGenerateCodeFromAttributes:
1>  Deleting file "obj\Debug\netstandard2.0\Solidity.Roslyn.Example.csproj.dotnet-codegen.GeneratedFileList.txt".
1>  0.4.88+g3109bcd51d
1>  Running CodeGeneration.Roslyn.Tool v0.4.88+g3109bcd51d
1>Target GenerateCodeFromAttributesCore:
1>  File "Solidity.cs" hashed to L4PwaM+L
1>  obj\Debug\netstandard2.0\Solidity.L4PwaM+L.generated.cs

But resulting C# code doesn't reflect actual changes. Only when I rebuild the whole project I get correct results.

AArnott commented 5 years ago

Do the CustomAdditionalCompileInputs items get fed into the compiler, or simply trigger msbuild's incremental build to run the CoreCompile target? I'm trying to understand why changing the .sol file would lead to a different result in the code generation result.

Pzixel commented 5 years ago

@AArnott no, they aren't fed to the compiler directly, I rather use them in my generator. I was author of the assembly-level generators if you recall. Here is an example https://github.com/Pzixel/Solidity.Roslyn

This one generates C# classes from sol file. Thus when you change sol you indeed change generator input and it has to regenerate stuff.

AArnott commented 5 years ago

OK, that makes sense. I won't get time for much or any OSS work over the next couple weeks, so if this is urgent, or if you just feel like contributing, I'd welcome a PR.

Pzixel commented 4 years ago

I tried to fix this with VS guys but it seems that it's only related to the CodeGeneration.Roslyn. See https://github.com/dotnet/project-system/issues/5621#issuecomment-557228622 for details.

I think I'l try to manage to get some time in near future but I wonder what changes could be done without being rejected (e.g. because I invalidate caches too much).