Skip to content

Commit f1105e2

Browse files
authored
Add support for customising encoders (#406)
1 parent 9ba789d commit f1105e2

17 files changed

Lines changed: 256 additions & 48 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ nugets/
1111
*.DotSettings.user
1212

1313
# Approval Tests
14-
*.received.*
14+
*.received.*
15+
16+
src/.idea/

readme.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of documents via [ImageSharp](https://github.com/SixLabors/ImageSharp).
77

88

9-
109
## NuGet package
1110

1211
https://nuget.org/packages/Verify.ImageSharp/
@@ -27,7 +26,7 @@ public class Samples
2726
VerifyImageSharp.Initialize();
2827
}
2928
```
30-
<sup><a href='/src/Tests/Samples.cs#L4-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-testdefinition' title='Start of snippet'>anchor</a></sup>
29+
<sup><a href='/src/Tests/Samples.cs#L4-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-testdefinition' title='Start of snippet'>anchor</a></sup>
3130
<!-- endSnippet -->
3231

3332

@@ -42,7 +41,17 @@ public Task VerifyImageFile()
4241
return VerifyFile("sample.jpg");
4342
}
4443
```
45-
<sup><a href='/src/Tests/Samples.cs#L14-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyimagefile' title='Start of snippet'>anchor</a></sup>
44+
<sup><a href='/src/Tests/Samples.cs#L16-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyimagefile' title='Start of snippet'>anchor</a></sup>
45+
<a id='snippet-verifyimagefile-1'></a>
46+
```cs
47+
[Test]
48+
public Task VerifyImageFileWithCustomEncoder()
49+
{
50+
return VerifyFile("sample.jpg")
51+
.EncodeAsPng();
52+
}
53+
```
54+
<sup><a href='/src/Tests/Samples.cs#L26-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyimagefile-1' title='Start of snippet'>anchor</a></sup>
4655
<!-- endSnippet -->
4756

4857
Two files are produced
@@ -52,7 +61,7 @@ Two files are produced
5261

5362
Samples.VerifyImageFile.00.verified.txt
5463

55-
<!-- snippet: Samples.VerifyImageFile.00.verified.txt -->
64+
<!-- snip2pet: Samples.VerifyImageFile.00.verified.txt -->
5665
<a id='snippet-Samples.VerifyImageFile.00.verified.txt'></a>
5766
```txt
5867
{
@@ -87,10 +96,10 @@ public Task VerifyImage()
8796
{
8897
[5, 5] = Rgba32.ParseHex("#0000FF")
8998
};
90-
return Verify(image).UseExtension("png");
99+
return Verify(image);
91100
}
92101
```
93-
<sup><a href='/src/Tests/Samples.cs#L24-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyimage' title='Start of snippet'>anchor</a></sup>
102+
<sup><a href='/src/Tests/Samples.cs#L37-L49' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyimage' title='Start of snippet'>anchor</a></sup>
94103
<!-- endSnippet -->
95104

96105

src/.editorconfig

Lines changed: 98 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,95 @@
1+
root = true
12
# EditorConfig: http://EditorConfig.org
23

34
# top-most EditorConfig file
4-
root = true
55

66
[*]
77
indent_style = space:error
88

9+
# Microsoft .NET properties
10+
csharp_new_line_before_members_in_object_initializers = false
11+
csharp_preferred_modifier_order = public, private, protected, internal, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async:suggestion
12+
csharp_style_namespace_declarations = file_scoped:error
13+
csharp_style_var_elsewhere = true:suggestion
14+
csharp_style_var_for_built_in_types = true:suggestion
15+
csharp_style_var_when_type_is_apparent = true:suggestion
16+
dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined
17+
dotnet_naming_rule.private_constants_rule.severity = warning
18+
dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style
19+
dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
20+
dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = as_predefined
21+
dotnet_naming_rule.private_instance_fields_rule.severity = warning
22+
dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
23+
dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
24+
dotnet_naming_rule.private_static_fields_rule.import_to_resharper = as_predefined
25+
dotnet_naming_rule.private_static_fields_rule.severity = warning
26+
dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style
27+
dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
28+
dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined
29+
dotnet_naming_rule.private_static_readonly_rule.severity = warning
30+
dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style
31+
dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
32+
dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
33+
dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
34+
dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
35+
dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
36+
dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
37+
dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
38+
dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
39+
dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
40+
dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
41+
dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
42+
dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
43+
dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
44+
dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static, readonly
45+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none
46+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none
47+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none
48+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
49+
dotnet_style_predefined_type_for_member_access = true:suggestion
50+
dotnet_style_qualification_for_event = false:suggestion
51+
dotnet_style_qualification_for_field = false:suggestion
52+
dotnet_style_qualification_for_method = false:suggestion
53+
dotnet_style_qualification_for_property = false:suggestion
54+
55+
# ReSharper properties
56+
resharper_apply_on_completion = true
57+
resharper_csharp_wrap_lines = false
58+
resharper_object_creation_when_type_not_evident = target_typed
59+
60+
# ReSharper inspection severities
61+
resharper_arrange_object_creation_when_type_evident_highlighting = error
62+
resharper_arrange_object_creation_when_type_not_evident_highlighting = error
63+
resharper_arrange_redundant_parentheses_highlighting = error
64+
resharper_arrange_static_member_qualifier_highlighting = error
65+
resharper_arrange_this_qualifier_highlighting = hint
66+
resharper_arrange_type_member_modifiers_highlighting = none
67+
resharper_built_in_type_reference_style_for_member_access_highlighting = hint
68+
resharper_built_in_type_reference_style_highlighting = hint
69+
resharper_check_namespace_highlighting = none
70+
resharper_convert_to_using_declaration_highlighting = error
71+
resharper_css_not_resolved_highlighting = warning
72+
resharper_field_can_be_made_read_only_local_highlighting = none
73+
resharper_merge_into_logical_pattern_highlighting = warning
74+
resharper_merge_into_pattern_highlighting = error
75+
resharper_method_has_async_overload_highlighting = warning
76+
resharper_partial_type_with_single_part_highlighting = error
77+
resharper_redundant_base_qualifier_highlighting = warning
78+
resharper_redundant_cast_highlighting = error
79+
resharper_redundant_empty_object_creation_argument_list_highlighting = error
80+
resharper_redundant_empty_object_or_collection_initializer_highlighting = error
81+
resharper_redundant_name_qualifier_highlighting = error
82+
resharper_redundant_suppress_nullable_warning_expression_highlighting = error
83+
resharper_redundant_using_directive_highlighting = error
84+
resharper_redundant_verbatim_string_prefix_highlighting = error
85+
resharper_replace_substring_with_range_indexer_highlighting = warning
86+
resharper_suggest_var_or_type_built_in_types_highlighting = hint
87+
resharper_suggest_var_or_type_elsewhere_highlighting = hint
88+
resharper_suggest_var_or_type_simple_types_highlighting = hint
89+
resharper_unnecessary_whitespace_highlighting = error
90+
resharper_use_await_using_highlighting = warning
91+
resharper_use_deconstruction_highlighting = warning
92+
993
[*.cs]
1094
indent_size = 4:error
1195
charset = utf-8-bom:error
@@ -60,18 +144,23 @@ csharp_new_line_before_finally = true:error
60144
csharp_new_line_before_members_in_object_initializers = true:error
61145
csharp_new_line_before_members_in_anonymous_types = true:error
62146

63-
#braces
64-
#csharp_prefer_braces = true:error
147+
dotnet_style_require_accessibility_modifiers = never:error
65148

66-
# msbuild
67-
[*.{csproj,targets,props}]
68-
indent_size = 2
149+
#braces https://www.jetbrains.com/help/resharper/EditorConfig_CSHARP_CSharpCodeStylePageImplSchema.html#Braces
150+
braces_for_ifelse = required
151+
braces_for_foreach = required
152+
braces_for_while = required
153+
braces_for_dowhile = required
154+
braces_for_lock = required
155+
braces_for_fixed = required
156+
braces_for_for = required
69157

70158
# Xml files
71-
[*.{xml,config,nuspec,resx,vsixmanifest}]
159+
[*.{xml,config,nuspec,resx,vsixmanifest,csproj,targets,props}]
72160
indent_size = 2
73-
resharper_xml_wrap_tags_and_pi = true:error
161+
# https://www.jetbrains.com/help/resharper/EditorConfig_XML_XmlCodeStylePageSchema.html#resharper_xml_blank_line_after_pi
162+
blank_line_after_pi = false
74163

75-
# JSON files
76164
[*.json]
77165
indent_size = 2
166+

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;CS0649</NoWarn>
5-
<Version>3.7.0</Version>
5+
<Version>3.8.0</Version>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<AssemblyVersion>1.0.0</AssemblyVersion>
88
<PackageTags>ImageSharp, Verify</PackageTags>

src/Tests/Samples.VerifyImage.00.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
Width: 11,
33
Height: 11,
44
HorizontalResolution: 96.0,

src/Tests/Samples.VerifyImageFile.00.verified.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{
1+
{
22
Width: 1599,
33
Height: 1066,
44
HorizontalResolution: 1.0,
-55 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
Width: 1599,
3+
Height: 1066,
4+
HorizontalResolution: 1.0,
5+
VerticalResolution: 1.0
6+
}
1000 KB
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
Width: 11,
3+
Height: 11,
4+
HorizontalResolution: 96.0,
5+
VerticalResolution: 96.0,
6+
ResolutionUnits: PixelsPerInch
7+
}

0 commit comments

Comments
 (0)