Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.68 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.68 KB

MakeGenericAgain

Problem is that nswag client code generation from open api specification or swagger generates classes without generics. This tool can be used afterwards to make classes generic again

More infos about the general problem can be found here

To install it on other projects, add this to the csproj:

  <Target Name="MakeGenericAgain" AfterTargets="NSwag" Condition="'$(Configuration)' == 'Debug'">
    <Exec IgnoreExitCode="true" Command="dotnet tool install --global makeGenericAgain" />
    <Exec Command="makeGenericAgain -f $(SolutionDir)src\SDK\Net\v1\ClientGenerated.cs" />
  </Target>

You can optionally provide names of types to ignore (should include any type names containing the word 'Of' as a minimum)

  <Target Name="MakeGenericAgain" AfterTargets="NSwag" Condition="'$(Configuration)' == 'Debug'">
    <Exec IgnoreExitCode="true" Command="dotnet tool install --global makeGenericAgain" />
    <Exec Command="makeGenericAgain -f $(SolutionDir)src\SDK\Net\v1\ClientGenerated.cs -i IgnorableOfType,AnotherOfIgnorable" />
  </Target>

To run int use

 makeGenericAgain -f "C:\Path\client.cs"

Or with ignorable type names

 makeGenericAgain -f "C:\Path\client.cs" -i "IgnorableOfType,AnotherOfIgnorable"

Also you can specify specific output file with -o

 makeGenericAgain -f "C:\Path\client.cs" -i "IgnorableOfType,AnotherOfIgnorable" -o "C:\Path\client_with_generics.cs"

Links

Github Repository | Nuget Package