zijianhuang / webapiclientgen

Strongly Typed Client API Generators generate strongly typed client APIs in C# .NET and in TypeScript for jQuery and Angular 2+ from ASP.NET Web API and .NET Core Web API
MIT License
167 stars 38 forks source link

make PS1 scripts friendly to PowerShell 7 when encountering exception. #168

Open zijianhuang opened 1 day ago

zijianhuang commented 1 day ago

Current in PwSh.exe, when http exception occurs:

 $response = $_.Exception.Response.GetResponseStream()
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.Net.Http.HttpResponseMessage] does not contain a method named
     | 'GetResponseStream'.
zijianhuang commented 1 day ago

detect pwsh , and use https://learn.microsoft.com/en-us/dotnet/api/system.net.http.streamcontent?view=net-9.0