Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Nov 27, 2023
1 parent 8aae5a3 commit 53aac9d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
28 changes: 20 additions & 8 deletions docs/serializer-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ The default encoding for snapshot files uses UTF-8 with byte order marks (BOM) e
<!-- snippet: UseUtf8NoBom -->
<a id='snippet-useutf8nobom'></a>
```cs
VerifierSettings.UseUtf8NoBom();
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.UseUtf8NoBom();
}
```
<sup><a href='/src/StaticSettingsTests/EncodingTests.cs#L9-L11' title='Snippet source file'>snippet source</a> | <a href='#snippet-useutf8nobom' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/ModuleInitDocs/UseUtf8NoBom.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-useutf8nobom' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## UseEncoding
Expand All @@ -91,13 +96,20 @@ To override the encoding used for snapshot files, replacing the default UTF-8 en
<!-- snippet: UseEncoding -->
<a id='snippet-useencoding'></a>
```cs
var encoding = new UnicodeEncoding(
bigEndian: false,
byteOrderMark: true,
throwOnInvalidBytes: true);
VerifierSettings.UseEncoding(encoding);
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init()
{
var encoding = new UnicodeEncoding(
bigEndian: false,
byteOrderMark: true,
throwOnInvalidBytes: true);
VerifierSettings.UseEncoding(encoding);
}
}
```
<sup><a href='/src/StaticSettingsTests/EncodingTests.cs#L27-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-useencoding' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/ModuleInitDocs/UseEncoding.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-useencoding' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

## Default settings
Expand Down
19 changes: 19 additions & 0 deletions src/ModuleInitDocs/UseEncoding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public class UseEncoding
{
#region UseEncoding

public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init()
{
var encoding = new UnicodeEncoding(
bigEndian: false,
byteOrderMark: true,
throwOnInvalidBytes: true);
VerifierSettings.UseEncoding(encoding);
}
}

#endregion
}
13 changes: 13 additions & 0 deletions src/ModuleInitDocs/UseUtf8NoBom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class UseUtf8NoBom
{
#region UseUtf8NoBom

public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.UseUtf8NoBom();
}

#endregion
}
4 changes: 0 additions & 4 deletions src/StaticSettingsTests/EncodingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ public class EncodingTests :
[Fact]
public async Task UseUtf8NoBom()
{
#region UseUtf8NoBom
VerifierSettings.UseUtf8NoBom();
#endregion

var file = CurrentFile.Relative($"EncodingTests.{nameof(UseUtf8NoBom)}.verified.txt");
File.Delete(file);
Expand All @@ -24,13 +22,11 @@ public async Task UseUtf8NoBom()
[Fact]
public async Task Utf16()
{
#region UseEncoding
var encoding = new UnicodeEncoding(
bigEndian: false,
byteOrderMark: true,
throwOnInvalidBytes: true);
VerifierSettings.UseEncoding(encoding);
#endregion

var file = CurrentFile.Relative($"EncodingTests.{nameof(Utf16)}.verified.txt");
File.Delete(file);
Expand Down

0 comments on commit 53aac9d

Please sign in to comment.