Skip to content

Commit

Permalink
Fix the readme issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzimarev committed Apr 2, 2024
1 parent f6be96c commit 78d7d0b
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ In previous versions of RestSharp, the default XML serializer was a custom RestS
You can add it back if necessary by installing the package and adding it to the client:

```csharp
client.UseXmlSerializer();
var client = new RestClient(
options,
configureSerialization: s => s.UseXmlSerializer()
);
```

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.
Expand Down Expand Up @@ -77,6 +80,29 @@ JsonSerializerSettings DefaultSettings = new JsonSerializerSettings {
If you need to use different settings, you can supply your instance of
`JsonSerializerSettings` as a parameter for the extension method.

## CSV

A separate package `RestSharp.Serializers.CsvHelper` provides a CSV serializer for RestSharp. It is based on the
`CsvHelper` library.

Use the extension method provided by the package to configure the client:

```csharp
var client = new RestClient(
options,
configureSerialization: s => s.UseCsvHelper()
);
```

You can also supply your instance of `CsvConfiguration` as a parameter for the extension method.

```csharp
var client = new RestClient(
options,
configureSerialization: s => s.UseCsvHelper(new CsvConfiguration(CultureInfo.InvariantCulture) {...})
);
```

## Custom

You can also implement your custom serializer. To support both serialization and
Expand Down
2 changes: 2 additions & 0 deletions src/RestSharp.Serializers.CsvHelper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# About

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<ItemGroup>
<Using Remove="System.Net.Http"/>
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions src/RestSharp.Serializers.NewtonsoftJson/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# About

This library allows using Newtonsoft.Json as a serializer for RestSharp instead of the default JSON serializer based
on `System.Text.Json`.

# How to use

The default JSON serializer uses `System.Text.Json`, which is a part of .NET since .NET 6.

If you want to use Newtonsoft.Json, you can install the `RestSharp.Serializers.NewtonsoftJson` package and configure
the
client to use it:

```csharp
var client = new RestClient(
options,
configureSerialization: s => s.UseNewtonsoftJson()
);
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<Using Include="Newtonsoft.Json"/>
<Using Remove="System.Net.Http"/>
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions src/RestSharp.Serializers.Xml/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# About

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.

# How to use

The default XML serializer in RestSharp is `DotNetXmlSerializer`, which uses `System.Xml.Serialization` library from .
NET.

In previous versions of RestSharp, the default XML serializer was a custom RestSharp XML serializer. To make the
code library size smaller, the custom serializer was removed from RestSharp.

You can add it back if necessary by installing the `RestSharp.Serializers.Xml` package and adding it to the client:

```csharp
var client = new RestClient(
options,
configureSerialization: s => s.UseXmlSerializer()
);
```

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.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
<ItemGroup>
<Using Remove="System.Net.Http"/>
</ItemGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>

0 comments on commit 78d7d0b

Please sign in to comment.