-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from christianhelle/source-generator-tests
Add production tests for source generators
- Loading branch information
Showing
15 changed files
with
271 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Run Tests | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
type: string | ||
default: ubuntu-latest | ||
|
||
jobs: | ||
|
||
test: | ||
|
||
name: ${{ inputs.os }} | ||
runs-on: ${{ inputs.os }} | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: 🛒 Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🛠️ Build SourceGenerator.sln | ||
run: dotnet build | ||
working-directory: test/SourceGenerator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<LangVersion>latest</LangVersion> | ||
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="..\Program.cs"> | ||
<Link>Program.cs</Link> | ||
</Compile> | ||
<AdditionalFiles Include="..\*.refitter" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Refitter.SourceGenerator" Version="0.7.0.28-preview" /> | ||
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" /> | ||
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net462</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net48</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net481</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.ComponentModel.DataAnnotations" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Refit; | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace MyNamespace; | ||
|
||
internal class Program | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
await TestPetstoreUsingDirectTypes(); | ||
await TestPetstoreUsingApiResponse(); | ||
} | ||
|
||
private static async Task TestPetstoreUsingApiResponse() | ||
{ | ||
var responseClient = RestService.For<Petstore.UsingApiResponse.ISwaggerPetstoreApiResponse>("https://petstore3.swagger.io/api/v3"); | ||
var response = await responseClient.GetPetById(1); | ||
|
||
Console.WriteLine("## Using IApiResponse<T> as return type ##"); | ||
Console.WriteLine($"HTTP Status Code: {response.StatusCode}"); | ||
Console.WriteLine($"Name: {response.Content.Name}"); | ||
Console.WriteLine($"Status: {response.Content.Status}"); | ||
|
||
var pets = await responseClient.FindPetsByStatus(Petstore.UsingApiResponse.Status.Available); | ||
Console.WriteLine("Found " + pets.Content.Count + " available pet(s)"); | ||
|
||
var taggedPets = await responseClient.FindPetsByTags(new[] { "tag1Updated", "new" }); | ||
Console.WriteLine("Found " + taggedPets.Content.Count + " tagged pet(s)"); | ||
} | ||
|
||
private static async Task TestPetstoreUsingDirectTypes() | ||
{ | ||
var client = RestService.For<Petstore.ISwaggerPetstoreDirect>("https://petstore3.swagger.io/api/v3"); | ||
var pet = await client.GetPetById(1); | ||
|
||
Console.WriteLine($"Name: {pet.Name}"); | ||
Console.WriteLine($"Status: {pet.Status}"); | ||
|
||
var pets = await client.FindPetsByStatus(Petstore.Status.Available); | ||
Console.WriteLine("Found " + pets.Count + " available pet(s)"); | ||
|
||
var taggedPets = await client.FindPetsByTags(new[] { "tag1Updated", "new" }); | ||
Console.WriteLine("Found " + taggedPets.Count + " tagged pet(s)"); | ||
|
||
Console.WriteLine(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net462", "Net462\Net462.csproj", "{DDF75403-9EF8-4B7E-89E7-392071720D18}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net472", "Net472\Net472.csproj", "{946FFF5A-19F3-4DCC-91E7-0F8D8E22FC39}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net48", "Net48\Net48.csproj", "{5651B984-6110-4A6A-B6EC-6A8466F97FF9}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net481", "Net481\Net481.csproj", "{CC6110B0-4DC4-4C9A-98F5-6327979815F2}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net6", "Net6\Net6.csproj", "{EC36C592-66FD-4F0F-A50D-01791EE37BAC}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net7", "Net7\Net7.csproj", "{E5E1F363-0A7C-4EA5-B36E-D5B8A1D73B8A}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandard20", "NetStandard20\NetStandard20.csproj", "{457977B3-A993-4284-853A-ADB3DFFFBCC1}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandard21", "NetStandard21\NetStandard21.csproj", "{0A8BAE94-81E2-43FE-8DD2-EE9E576DDB47}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{DDF75403-9EF8-4B7E-89E7-392071720D18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{DDF75403-9EF8-4B7E-89E7-392071720D18}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{DDF75403-9EF8-4B7E-89E7-392071720D18}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{DDF75403-9EF8-4B7E-89E7-392071720D18}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{946FFF5A-19F3-4DCC-91E7-0F8D8E22FC39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{946FFF5A-19F3-4DCC-91E7-0F8D8E22FC39}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{946FFF5A-19F3-4DCC-91E7-0F8D8E22FC39}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{946FFF5A-19F3-4DCC-91E7-0F8D8E22FC39}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{5651B984-6110-4A6A-B6EC-6A8466F97FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{5651B984-6110-4A6A-B6EC-6A8466F97FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{5651B984-6110-4A6A-B6EC-6A8466F97FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{5651B984-6110-4A6A-B6EC-6A8466F97FF9}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{CC6110B0-4DC4-4C9A-98F5-6327979815F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CC6110B0-4DC4-4C9A-98F5-6327979815F2}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CC6110B0-4DC4-4C9A-98F5-6327979815F2}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CC6110B0-4DC4-4C9A-98F5-6327979815F2}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{EC36C592-66FD-4F0F-A50D-01791EE37BAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{EC36C592-66FD-4F0F-A50D-01791EE37BAC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{EC36C592-66FD-4F0F-A50D-01791EE37BAC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{EC36C592-66FD-4F0F-A50D-01791EE37BAC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E5E1F363-0A7C-4EA5-B36E-D5B8A1D73B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E5E1F363-0A7C-4EA5-B36E-D5B8A1D73B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E5E1F363-0A7C-4EA5-B36E-D5B8A1D73B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E5E1F363-0A7C-4EA5-B36E-D5B8A1D73B8A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{457977B3-A993-4284-853A-ADB3DFFFBCC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{457977B3-A993-4284-853A-ADB3DFFFBCC1}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{457977B3-A993-4284-853A-ADB3DFFFBCC1}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{457977B3-A993-4284-853A-ADB3DFFFBCC1}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{0A8BAE94-81E2-43FE-8DD2-EE9E576DDB47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0A8BAE94-81E2-43FE-8DD2-EE9E576DDB47}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0A8BAE94-81E2-43FE-8DD2-EE9E576DDB47}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0A8BAE94-81E2-43FE-8DD2-EE9E576DDB47}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"openApiPath": "../OpenAPI/v3.0/petstore.json", | ||
"namespace": "Petstore.UsingApiResponse", | ||
"returnIApiResponse": true, | ||
"naming": { | ||
"useOpenApiTitle": false, | ||
"interfaceName": "SwaggerPetstoreApiResponse" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"openApiPath": "../OpenAPI/v3.0/petstore.json", | ||
"namespace": "Petstore", | ||
"naming": { | ||
"useOpenApiTitle": false, | ||
"interfaceName": "SwaggerPetstoreDirect" | ||
} | ||
} |