Source generator #424
Replies: 3 comments
-
@bastiennoel93 Thanks for taking the time to report this. There was a known issue in a previous release of Refitter where the Source Generator stopped working due to a bad dependency update. The source generator in lastest stable version, v1.1.3 works fine after I just tested it right now I created an empty .NET console app and added the Refit and Refitter.SourceGenerator package references. The csproj looks like this <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Refit" Version="7.1.2" />
<PackageReference Include="Refitter.SourceGenerator" Version="1.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> I added a .refitter file that points to the Swagger Petstore v3 example. It looks like this {
"openApiPath": "https://petstore3.swagger.io/api/v3/openapi.json",
"namespace": "Petstore"
} When I build the project, I get the following, it generates a folder called My working folder looks like this: total 24
drwxr-xr-x 3 christianhelle staff 96 Jul 23 16:37 Generated
-rw-r--r-- 1 christianhelle staff 105 Jul 23 16:28 Program.cs
-rw-r--r-- 1 christianhelle staff 99 Jul 23 16:32 petstore.refitter
-rw-r--r-- 1 christianhelle staff 582 Jul 23 16:34 refitter.sourcegen.sample.csproj |
Beta Was this translation helpful? Give feedback.
-
The issue appears in v1.1.2 and I updated the package in nuget.org to display it as deprecated When I use v1.1.2 in a project like this <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Refit" Version="7.1.2" />
<PackageReference Include="Refitter.SourceGenerator" Version="1.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project> The build output is the following
and no output file is created |
Beta Was this translation helpful? Give feedback.
-
@bastiennoel93 Sorry! I missed this detail in my previous responses. No, I don't think I have seen this before. One thing you could do to force re-generation is to shut down the build-server by calling I spend most of my time in Rider which only triggers the source generator upon build. Visual Studio triggers the source generator by making changes to the .refitter file. I guess triggering the source generator based on file changes are better than something triggered by the build, but I just got use to it |
Beta Was this translation helpful? Give feedback.
-
Hello,
When I open my visual studio, files are generated.
But when I delete them, after opening, even if I restore or rebuild, the files are not generated.
I have to close and open my visual studio for them to regenerate.
Have you had this problem?
Beta Was this translation helpful? Give feedback.
All reactions