Skip to content

Commit 78d7d0b

Browse files
committed
Fix the readme issue
1 parent f6be96c commit 78d7d0b

File tree

7 files changed

+79
-1
lines changed

7 files changed

+79
-1
lines changed

docs/serialization.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ In previous versions of RestSharp, the default XML serializer was a custom RestS
3737
You can add it back if necessary by installing the package and adding it to the client:
3838

3939
```csharp
40-
client.UseXmlSerializer();
40+
var client = new RestClient(
41+
options,
42+
configureSerialization: s => s.UseXmlSerializer()
43+
);
4144
```
4245

4346
As before, you can supply three optional arguments for a custom namespace, custom root element, and if you want to use `SerializeAs` and `DeserializeAs` attributed.
@@ -77,6 +80,29 @@ JsonSerializerSettings DefaultSettings = new JsonSerializerSettings {
7780
If you need to use different settings, you can supply your instance of
7881
`JsonSerializerSettings` as a parameter for the extension method.
7982

83+
## CSV
84+
85+
A separate package `RestSharp.Serializers.CsvHelper` provides a CSV serializer for RestSharp. It is based on the
86+
`CsvHelper` library.
87+
88+
Use the extension method provided by the package to configure the client:
89+
90+
```csharp
91+
var client = new RestClient(
92+
options,
93+
configureSerialization: s => s.UseCsvHelper()
94+
);
95+
```
96+
97+
You can also supply your instance of `CsvConfiguration` as a parameter for the extension method.
98+
99+
```csharp
100+
var client = new RestClient(
101+
options,
102+
configureSerialization: s => s.UseCsvHelper(new CsvConfiguration(CultureInfo.InvariantCulture) {...})
103+
);
104+
```
105+
80106
## Custom
81107

82108
You can also implement your custom serializer. To support both serialization and
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# About
2+

src/RestSharp.Serializers.CsvHelper/RestSharp.Serializers.CsvHelper.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
<ItemGroup>
99
<Using Remove="System.Net.Http"/>
1010
</ItemGroup>
11+
<ItemGroup>
12+
<None Include="README.md" Pack="true" PackagePath="\" />
13+
</ItemGroup>
1114
</Project>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# About
2+
3+
This library allows using Newtonsoft.Json as a serializer for RestSharp instead of the default JSON serializer based
4+
on `System.Text.Json`.
5+
6+
# How to use
7+
8+
The default JSON serializer uses `System.Text.Json`, which is a part of .NET since .NET 6.
9+
10+
If you want to use Newtonsoft.Json, you can install the `RestSharp.Serializers.NewtonsoftJson` package and configure
11+
the
12+
client to use it:
13+
14+
```csharp
15+
var client = new RestClient(
16+
options,
17+
configureSerialization: s => s.UseNewtonsoftJson()
18+
);
19+
```

src/RestSharp.Serializers.NewtonsoftJson/RestSharp.Serializers.NewtonsoftJson.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
<Using Include="Newtonsoft.Json"/>
1010
<Using Remove="System.Net.Http"/>
1111
</ItemGroup>
12+
<ItemGroup>
13+
<None Include="README.md" Pack="true" PackagePath="\" />
14+
</ItemGroup>
1215
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# About
2+
3+
This package is a custom XML serializer for RestSharp. It is based on the original XML serializer that was part of RestSharp but was removed in version 107.0.0.
4+
5+
# How to use
6+
7+
The default XML serializer in RestSharp is `DotNetXmlSerializer`, which uses `System.Xml.Serialization` library from .
8+
NET.
9+
10+
In previous versions of RestSharp, the default XML serializer was a custom RestSharp XML serializer. To make the
11+
code library size smaller, the custom serializer was removed from RestSharp.
12+
13+
You can add it back if necessary by installing the `RestSharp.Serializers.Xml` package and adding it to the client:
14+
15+
```csharp
16+
var client = new RestClient(
17+
options,
18+
configureSerialization: s => s.UseXmlSerializer()
19+
);
20+
```
21+
22+
As before, you can supply three optional arguments for a custom namespace, custom root element, and if you want to use `SerializeAs` and `DeserializeAs` attributed.

src/RestSharp.Serializers.Xml/RestSharp.Serializers.Xml.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@
88
<ItemGroup>
99
<Using Remove="System.Net.Http"/>
1010
</ItemGroup>
11+
<ItemGroup>
12+
<None Include="README.md" Pack="true" PackagePath="\" />
13+
</ItemGroup>
1114
</Project>

0 commit comments

Comments
 (0)