Skip to content

Commit f6fefcb

Browse files
committed
Updated docs and issue templates
1 parent 7b8c9cb commit f6fefcb

File tree

6 files changed

+78
-94
lines changed

6 files changed

+78
-94
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,29 @@
22
name: Bug report
33
about: Create a report to help us improve
44
title: ''
5-
labels: ''
5+
labels: 'bug'
66
assignees: ''
77

88
---
99

10+
**DO NOT USE ISSUES FOR QUESTIONS**
11+
1012
**Describe the bug**
1113
A clear and concise description of what the bug is.
1214

1315
**To Reproduce**
14-
Steps to reproduce the behavior:
15-
1. Go to '...'
16-
2. Click on '....'
17-
3. Scroll down to '....'
18-
4. See error
16+
Steps to reproduce the behavior, preferably using a code snippet.
1917

2018
**Expected behavior**
2119
A clear and concise description of what you expected to happen.
2220

23-
**Screenshots**
24-
If applicable, add screenshots to help explain your problem.
21+
**Stack trace**
22+
Copy the full stack trace here if you get an exception.
2523

2624
**Desktop (please complete the following information):**
27-
- OS: [e.g. iOS]
28-
- Browser [e.g. chrome, safari]
29-
- Version [e.g. 22]
30-
31-
**Smartphone (please complete the following information):**
32-
- Device: [e.g. iPhone6]
33-
- OS: [e.g. iOS8.1]
34-
- Browser [e.g. stock browser, safari]
35-
- Version [e.g. 22]
25+
- OS: [e.g. macOS]
26+
- .NET version [e.g. .NET 5]
27+
- Version [e.g. 107.0.4]
3628

3729
**Additional context**
3830
Add any other context about the problem here.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Get help
4+
url: https://restsharp.dev/support/#get-help
5+
about: Read about asking questions and reporting issues

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
name: Feature request
33
about: Suggest an idea for this project
44
title: ''
5-
labels: ''
5+
labels: 'feature-request'
66
assignees: ''
77

88
---
99

10+
**DO NOT USE ISSUES FOR QUESTIONS**
11+
1012
**Is your feature request related to a problem? Please describe.**
1113
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
1214

docs/support/README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Got issues, questions, suggestions? Please read this page carefully to understan
1111
The most effective way to resolve questions about using RestSharp is StackOverflow.
1212

1313
RestSharp has a large user base. Tens of thousands of projects and hundreds of thousands of developers
14-
use RestSharp on a daily basis. So, asking questions on StackOverflow with [restsharp](https://stackoverflow.com/questions/tagged/restsharp) tag
14+
use RestSharp on a daily basis. So, asking questions on **StackOverflow** with [restsharp](https://stackoverflow.com/questions/tagged/restsharp) tag
1515
would most definitely lead you to a solution.
1616

1717
::: warning
@@ -34,7 +34,7 @@ a crash or anything else that you consider a bug, is submitting an issue
3434
at our GitHub repository.
3535

3636
::: warning
37-
Please do not ignore our contribution guidelines, otherwise you risk your issue to be
37+
**Do not ignore our contribution guidelines**, otherwise you risk your issue to be
3838
closed without being considered. Respect the maintainers, be specific and provide
3939
as many details about the issue as you can.
4040
:::
@@ -55,45 +55,44 @@ Here are contribution guidelines:
5555

5656
- Make each pull request atomic and exclusive; don't send pull requests for a laundry list of changes.
5757
- Even better, commit in small manageable chunks.
58-
- Use the supplied `.DotSettings` file to format the code.
58+
- Use the supplied `.editorconfig` file to format the code.
5959
- Any change must be accompanied by a unit test covering the change.
60-
- New tests are preferred to use Shoudly.
61-
- No regions except for license header
62-
- Code must build for .NET Standard 2.0 and .NET Framework 4.5.2.
63-
- Test must run on .NET Core 3.1 and .NET Framework 4.5.2
60+
- New tests are preferred to use FluentAssertions.
61+
- No regions.
62+
- No licence header for tested.
63+
- Code must build for .NET Standard 2.0, .NET 5, and .NET 6.
64+
- Test must run on .NET 6.
6465
- Use `autocrlf=true` (`git config --global core.autocrlf true` [http://help.github.com/dealing-with-lineendings/])
6566

6667
### Sponsor
6768

6869
You can also support maintainers and motivate them by contributing
6970
financially at [Open Collective](https://opencollective.com/restsharp).
7071

71-
## Common Issues
72+
## Common issues
7273

7374
Before opening an issue on GitHub, please check the list of known issues below.
7475

75-
### Connection closed with SSL
76+
### Content type
7677

77-
When connecting via HTTPS, you get an exception:
78+
One of the mistakes developers make when using RestSharp is setting the `Content-Type` header manually.
79+
Remember that in most of the usual scenarios setting the content type header manually is not required, and it might be harmful.
7880

79-
> The underlying connection was closed: An unexpected error occurred on a send
80-
81-
The exception is thrown by `WebRequest` so you need to tell the .NET Framework to
82-
accept more certificate types than it does by default.
83-
84-
Adding this line somewhere in your application, where it gets called once, should solve the issue:
81+
RestSharp sets the content type header automatically based on the request type.
82+
You might want to override the request body content type, but the best way to do it is to supply the content type to the body parameter itself.
83+
Functions for adding the request body to the request have overloads, which accept content type. For example
8584

8685
```csharp
87-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
86+
request.AddStringBody(jsonString, ContentType.Json);
8887
```
8988

9089
### Setting the User Agent
9190

9291
Setting the user agent on the request won't work when you use `AddHeader`.
9392

94-
Instead, please use the `RestClient.UserAgent` property.
93+
Instead, please use the `RestClientOptions.UserAgent` property.
9594

96-
### Empty Response
95+
### Empty response
9796

9897
We regularly get issues where developers complain that their requests get executed
9998
and they get a proper raw response, but the `RestResponse<T>` instance doesn't
@@ -105,7 +104,7 @@ All those issues are caused by the design choice to swallow exceptions
105104
that occur when RestSharp makes the request and processes the response. Instead,
106105
RestSharp produces so-called _error response_.
107106

108-
You can check the response status to find out if there're any errors.
107+
You can check the response status to find out if there are any errors.
109108
The following properties can tell you about those errors:
110109

111110
- `IsSuccessful`

docs/usage.md

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,12 @@ You can also make POST (and PUT/DELETE/HEAD/OPTIONS) requests:
8484
```csharp
8585
// TwilioApi.cs, method of TwilioApi class
8686
public Task<Call> InitiateOutboundCall(CallOptions options) {
87-
Require.Argument("Caller", options.Caller);
88-
Require.Argument("Called", options.Called);
89-
Require.Argument("Url", options.Url);
90-
91-
var request = new RestRequest("Accounts/{AccountSid}/Calls");
92-
request.RootElement = "Calls";
93-
94-
request.AddParameter("Caller", options.Caller);
95-
request.AddParameter("Called", options.Called);
96-
request.AddParameter("Url", options.Url);
87+
var request = new RestRequest("Accounts/{AccountSid}/Calls") {
88+
RootElement = "Calls"
89+
}
90+
.AddParameter("Caller", options.Caller)
91+
.AddParameter("Called", options.Called)
92+
.AddParameter("Url", options.Url);
9793

9894
if (options.Method.HasValue) request.AddParameter("Method", options.Method);
9995
if (options.SendDigits.HasValue()) request.AddParameter("SendDigits", options.SendDigits);
@@ -251,8 +247,7 @@ client.UseNewtonsoftJson();
251247
The serializer configures some options by default:
252248

253249
```csharp
254-
JsonSerializerSettings DefaultSettings = new JsonSerializerSettings
255-
{
250+
JsonSerializerSettings DefaultSettings = new JsonSerializerSettings {
256251
ContractResolver = new CamelCasePropertyNamesContractResolver(),
257252
DefaultValueHandling = DefaultValueHandling.Include,
258253
TypeNameHandling = TypeNameHandling.None,
@@ -273,16 +268,14 @@ deserialization, you must implement the `IRestSerializer` interface.
273268
Here is an example of a custom serializer that uses `System.Text.Json`:
274269

275270
```csharp
276-
public class SimpleJsonSerializer : IRestSerializer
277-
{
271+
public class SimpleJsonSerializer : IRestSerializer {
278272
public string Serialize(object obj) => JsonSerializer.Serialize(obj);
279273

280274
public string Serialize(Parameter bodyParameter) => Serialize(bodyParameter.Value);
281275

282276
public T Deserialize<T>(IRestResponse response) => JsonSerializer.Deserialize<T>(response.Content);
283277

284-
public string[] SupportedContentTypes { get; } =
285-
{
278+
public string[] SupportedContentTypes { get; } = {
286279
"application/json", "text/json", "text/x-json", "text/javascript", "*+json"
287280
};
288281

@@ -318,6 +311,39 @@ in favour of giving you the error as a property.
318311

319312
Those properties are available for the `RestClient` instance and will be used for all request made with that instance.
320313

314+
::: warning
315+
Please be aware that deserialization failures will only work if the serializer throws an exception when deserializing the response.
316+
Many serializers don't throw by default, and just return a `null` result. RestSharp is unable to figure out why `null` is returned, so it won't fail in this case.
317+
Check the serializer documentation to find out if it can be configured to throw on deserialization error.
318+
:::
319+
321320
There are also slight differences on how different overloads handle exceptions.
322321

323322
Asynchronous generic methods `GetAsync<T>`, `PostAsync<T>` and so on, which aren't a part of `RestClient` interface (those methods are extension methods) return `Task<T>`. It means that there's no `RestResponse` to set the response status to error. We decided to throw an exception when such a request fails. It is a trade-off between the API consistency and usability of the library. Usually, you only need the content of `RestResponse` instance to diagnose issues and most of the time the exception would tell you what's wrong.
323+
324+
Below you can find how different extensions deal with errors. Note that functions, which don't throw by default, will throw exceptions when `ThrowOnAnyError` is set to `true`.
325+
326+
| Function | Throws on errors |
327+
|:----------------------|:-----------------|
328+
| `ExecuteAsync` | No |
329+
| `ExecuteGetAsync` | No |
330+
| `ExecuteGetAsync<T>` | No |
331+
| `ExecutePostAsync` | No |
332+
| `ExecutePutAsync` | No |
333+
| `ExecuteGetAsync<T>` | No |
334+
| `ExecutePostAsync<T>` | No |
335+
| `ExecutePutAsync<T>` | No |
336+
| `GetAsync` | Yes |
337+
| `GetAsync<T>` | Yes |
338+
| `PostAsync` | Yes |
339+
| `PostAsync<T>` | Yes |
340+
| `PatchAsync` | Yes |
341+
| `PatchAsync<T>` | Yes |
342+
| `DeleteAsync` | Yes |
343+
| `DeleteAsync<T>` | Yes |
344+
| `OptionsAsync` | Yes |
345+
| `OptionsAsync<T>` | Yes |
346+
| `HeadAsync` | Yes |
347+
| `HeadAsync<T>` | Yes |
348+
349+
In addition, all the functions for JSON requests, like `GetJsonAsync` and `PostJsonAsyn` throw an exception if the HTTP call fails.

0 commit comments

Comments
 (0)