Skip to content

Support Restsharp 107 plus - #179

Merged
llimllib merged 6 commits into
mainfrom
restsharp-107-plus
Jun 16, 2023
Merged

Support Restsharp 107 plus#179
llimllib merged 6 commits into
mainfrom
restsharp-107-plus

Conversation

@llimllib

@llimllibllimllib commented Jun 16, 2023

Copy link
Copy Markdown
🚥 FixesKong/httpsnippet#312

🧰 Changes

After version 107, restsharp completely changed their API. This PR fixes the code generator to support the new API.

🧬 QA & Testing

To test this, I:

  • generated all new fixtures with OVERWRITE_EVERYTHING=true npm run test
  • generated a C# hello world project with dotnet new console -o HelloWorld -f net7.0
  • installed RestSharp into it with dotnet add package RestSharp]
  • ran this script and looked for significant differences between csharp and bash:
#!/usr/bin/env bashset -euxo pipefail
file=Program.cs
mkdir -p fixtures
# for the multipart testprintf"hello"> hello.txt
forfixturein~/readme/httpsnippet/src/targets/csharp/restsharp/fixtures/*;do
rm -f $file# the custom method isn't supportedif [[ $fixture==*custom-method* ]];thencontinue;fi
sed 's,test/fixtures/files/hello.txt,hello.txt,'"$fixture">>$fileprintf'Console.WriteLine("{0}", response.Content);'>>$file
dotnet run $file>"fixtures/$(basename "$fixture".out)"done## now run the bash fixtures for comparisonforfixturein~/readme/httpsnippet/src/targets/shell/curl/fixtures/*;do# the curl for custom-indentation does not work properly, so we need to add# || true
sed 's,test/fixtures/files/hello.txt,hello.txt,'"$fixture"|
bash >"fixtures/$(basename "$fixture".out)"||truedone# then, compare the outputsforfixturein~/readme/httpsnippet/src/targets/http/http1.1/fixtures/*;do
base=$(basename "$fixture")
cs="fixtures/$base.cs.out"
sh="fixtures/$base.sh.out"if [[ !-e$cs ]];thenprintf"Unable to find fixture %s\n""$cs";continue;fiif [[ !-e$cs ]];thenprintf"Unable to find fixture %s\n""$sh";continue;fi
git diff "fixtures/$base.cs.out""fixtures/$base.sh.out"||truedone

Updates restsharp support following their breaking
changes, reported in Kong#312
@llimllib

Copy link
Copy Markdown
Author

test failures appear to be unrelated to this code

@erunion

Copy link
Copy Markdown
Member

@llimllib I've just updated this branch with the latest, and rebased, main.

@erunionerunion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! feel free to merge whenever you'd like and i'll cut a new release

@llimllib

Copy link
Copy Markdown
Author

I think "mostly working" is better than "not at all", so I'll merge this 👍

@llimllib
llimllib merged commit 3fd5bbc into mainJun 16, 2023
@llimllib
llimllib deleted the restsharp-107-plus branch June 16, 2023 23:19
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

C# RestSharp is using deprecated syntax

2 participants

@llimllib@erunion