Skip to content

Commit a36b671

Browse files
committed
Merge branch 'master' of https://github.com/aaubry/YamlDotNet into nullable-enums
2 parents 65a0e71 + 35db04b commit a36b671

File tree

274 files changed

+6440
-5785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+6440
-5785
lines changed

.editorconfig

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
11+
# Code files
12+
[*.{cs,csx,vb,vbx}]
13+
indent_size = 4
14+
insert_final_newline = true
15+
charset = utf-8-bom
16+
17+
# XML project files
18+
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
19+
indent_size = 2
20+
21+
# XML config files
22+
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
23+
indent_size = 2
24+
25+
# JSON files
26+
[*.json]
27+
indent_size = 2
28+
29+
# Powershell files
30+
[*.ps1]
31+
indent_size = 2
32+
33+
# Shell script files
34+
[*.sh]
35+
end_of_line = lf
36+
indent_size = 2
37+
38+
#[*.cs]
39+
#dotnet_analyzer_diagnostic.category-Style.severity = error
40+
#dotnet_analyzer_diagnostic.category-CodeQuality.severity = error
41+
42+
# Dotnet code style settings:
43+
[*.{cs,vb}]
44+
45+
file_header_template = This file is part of YamlDotNet - A .NET library for YAML.\nCopyright (c) Antoine Aubry and contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the "Software"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is furnished to do\nso, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.
46+
47+
# IDE0055: Fix formatting
48+
dotnet_diagnostic.IDE0055.severity = warning
49+
50+
# Sort using and Import directives with System.* appearing first
51+
dotnet_sort_system_directives_first = true
52+
dotnet_separate_import_directive_groups = false
53+
54+
# Use language keywords instead of framework type names for type references
55+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
56+
dotnet_style_predefined_type_for_member_access = true:suggestion
57+
58+
# Suggest more modern language features when available
59+
dotnet_style_object_initializer = true:suggestion
60+
dotnet_style_collection_initializer = true:suggestion
61+
dotnet_style_coalesce_expression = true:suggestion
62+
dotnet_style_null_propagation = true:suggestion
63+
dotnet_style_explicit_tuple_names = true:suggestion
64+
65+
# Non-private static fields are PascalCase
66+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
67+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
68+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
69+
70+
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
71+
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
72+
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
73+
74+
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
75+
76+
# Non-private readonly fields are PascalCase
77+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
78+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
79+
80+
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
81+
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
82+
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
83+
84+
dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
85+
86+
# Constants are PascalCase
87+
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
88+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
89+
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
90+
91+
dotnet_naming_symbols.constants.applicable_kinds = field, local
92+
dotnet_naming_symbols.constants.required_modifiers = const
93+
94+
dotnet_naming_style.constant_style.capitalization = pascal_case
95+
96+
# Static fields are camelCase without prefix
97+
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
98+
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
99+
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
100+
101+
dotnet_naming_symbols.static_fields.applicable_kinds = field
102+
dotnet_naming_symbols.static_fields.required_modifiers = static
103+
104+
dotnet_naming_style.static_field_style.capitalization = pascal_case
105+
106+
# Instance fields are camelCase without prefix
107+
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
108+
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
109+
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
110+
111+
dotnet_naming_symbols.instance_fields.applicable_kinds = field
112+
dotnet_naming_symbols.instance_fields.applicable_accessibilities = protected, internal, protected_internal, private_protected, private
113+
114+
dotnet_naming_style.instance_field_style.capitalization = camel_case
115+
116+
# Locals and parameters are camelCase
117+
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
118+
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
119+
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
120+
121+
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
122+
123+
dotnet_naming_style.camel_case_style.capitalization = camel_case
124+
125+
# Local functions are PascalCase
126+
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
127+
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
128+
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
129+
130+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
131+
132+
dotnet_naming_style.local_function_style.capitalization = pascal_case
133+
134+
# By default, name items with PascalCase
135+
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
136+
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
137+
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
138+
139+
dotnet_naming_symbols.all_members.applicable_kinds = *
140+
141+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
142+
143+
# error RS2008: Enable analyzer release tracking for the analyzer project containing rule '{0}'
144+
dotnet_diagnostic.RS2008.severity = none
145+
146+
# IDE0073: File header
147+
dotnet_diagnostic.IDE0073.severity = warning
148+
149+
# IDE0035: Remove unreachable code
150+
dotnet_diagnostic.IDE0035.severity = warning
151+
152+
# IDE0036: Order modifiers
153+
dotnet_diagnostic.IDE0036.severity = warning
154+
155+
# IDE0043: Format string contains invalid placeholder
156+
dotnet_diagnostic.IDE0043.severity = warning
157+
158+
# IDE0044: Make field readonly
159+
dotnet_diagnostic.IDE0044.severity = warning
160+
161+
# CSharp code style settings:
162+
[*.cs]
163+
# Newline settings
164+
csharp_new_line_before_open_brace = all
165+
csharp_new_line_before_else = true
166+
csharp_new_line_before_catch = true
167+
csharp_new_line_before_finally = true
168+
csharp_new_line_before_members_in_object_initializers = true
169+
csharp_new_line_before_members_in_anonymous_types = true
170+
csharp_new_line_between_query_expression_clauses = true
171+
172+
# Indentation preferences
173+
csharp_indent_block_contents = true
174+
csharp_indent_braces = false
175+
csharp_indent_case_contents = true
176+
csharp_indent_case_contents_when_block = true
177+
csharp_indent_switch_labels = true
178+
csharp_indent_labels = flush_left
179+
180+
# Prefer "var" everywhere
181+
csharp_style_var_for_built_in_types = true:suggestion
182+
csharp_style_var_when_type_is_apparent = true:suggestion
183+
csharp_style_var_elsewhere = true:suggestion
184+
185+
# Prefer method-like constructs to have a block body
186+
csharp_style_expression_bodied_methods = false:none
187+
csharp_style_expression_bodied_constructors = false:none
188+
csharp_style_expression_bodied_operators = false:none
189+
190+
# Prefer property-like constructs to have an expression-body
191+
csharp_style_expression_bodied_properties = true:none
192+
csharp_style_expression_bodied_indexers = true:none
193+
csharp_style_expression_bodied_accessors = true:none
194+
195+
# Suggest more modern language features when available
196+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
197+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
198+
csharp_style_inlined_variable_declaration = true:suggestion
199+
csharp_style_throw_expression = true:suggestion
200+
csharp_style_conditional_delegate_call = true:suggestion
201+
202+
# Space preferences
203+
csharp_space_after_cast = false
204+
csharp_space_after_colon_in_inheritance_clause = true
205+
csharp_space_after_comma = true
206+
csharp_space_after_dot = false
207+
csharp_space_after_keywords_in_control_flow_statements = true
208+
csharp_space_after_semicolon_in_for_statement = true
209+
csharp_space_around_binary_operators = before_and_after
210+
csharp_space_around_declaration_statements = do_not_ignore
211+
csharp_space_before_colon_in_inheritance_clause = true
212+
csharp_space_before_comma = false
213+
csharp_space_before_dot = false
214+
csharp_space_before_open_square_brackets = false
215+
csharp_space_before_semicolon_in_for_statement = false
216+
csharp_space_between_empty_square_brackets = false
217+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
218+
csharp_space_between_method_call_name_and_opening_parenthesis = false
219+
csharp_space_between_method_call_parameter_list_parentheses = false
220+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
221+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
222+
csharp_space_between_method_declaration_parameter_list_parentheses = false
223+
csharp_space_between_parentheses = false
224+
csharp_space_between_square_brackets = false
225+
226+
# Blocks are allowed
227+
csharp_prefer_braces = true
228+
csharp_preserve_single_line_blocks = true
229+
csharp_preserve_single_line_statements = true
230+
231+
# Unusable features
232+
csharp_style_prefer_range_operator = false
233+
csharp_style_prefer_index_operator = false
234+
235+
# IDE0011: Add braces
236+
dotnet_diagnostic.IDE0011.severity = warning
237+
238+
# IDE0005: Using directive is unnecessary.
239+
dotnet_diagnostic.IDE0005.severity = suggestion

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ YamlDotNet/Properties/AssemblyInfo.Generated.cs
3131
BenchmarkDotNet.Artifacts
3232

3333
/YamlDotNet.AotTest/exitcode.txt
34+
/tools/build/Properties/launchSettings.json

YamlDotNet.AotTest/Program.cs

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
using System;
1+
// This file is part of YamlDotNet - A .NET library for YAML.
2+
// Copyright (c) Antoine Aubry and contributors
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
// this software and associated documentation files (the "Software"), to deal in
6+
// the Software without restriction, including without limitation the rights to
7+
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
// of the Software, and to permit persons to whom the Software is furnished to do
9+
// so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
using System;
223
using System.Collections.Generic;
324
using System.IO;
425
using YamlDotNet.Serialization;
@@ -9,7 +30,7 @@ namespace YamlDotNet.AotTest
930
{
1031
class Program
1132
{
12-
static int Main(string[] args)
33+
static int Main()
1334
{
1435
Console.WriteLine();
1536
Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------");
@@ -24,17 +45,17 @@ static int Main(string[] args)
2445
TrySerialize("TraverseGenericDictionary", new GenericTestDictionary<long, long> { { 1, 2 } });
2546

2647
Console.WriteLine();
27-
Console.WriteLine(" \x1b[93m{0}\x1b[97m test succeeded, \x1b[93m{1}\x1b[97m tests failed", succeededTestCount, failedTestCount);
48+
Console.WriteLine(" \x1b[93m{0}\x1b[97m test succeeded, \x1b[93m{1}\x1b[97m tests failed", SucceededTestCount, FailedTestCount);
2849

2950
Console.WriteLine();
3051
Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------");
3152
Console.WriteLine("\x1b[0m");
3253

33-
return failedTestCount;
54+
return FailedTestCount;
3455
}
3556

36-
private static int succeededTestCount;
37-
private static int failedTestCount;
57+
private static int SucceededTestCount;
58+
private static int FailedTestCount;
3859

3960
private static void TrySerialize<T>(string testName, T graph)
4061
{
@@ -63,7 +84,7 @@ private static void PerformTest(string testName, Action act)
6384
{
6485
act();
6586
Console.WriteLine("\x1b[92m[success]\x1b[37m");
66-
++succeededTestCount;
87+
++SucceededTestCount;
6788
}
6889
catch (Exception ex)
6990
{
@@ -78,7 +99,7 @@ private static void PerformTest(string testName, Action act)
7899
Console.Write("\x1b[93m ");
79100
Console.WriteLine(current.Message);
80101
Console.Write("\x1b[37m");
81-
++failedTestCount;
102+
++FailedTestCount;
82103
return;
83104
}
84105

@@ -90,6 +111,7 @@ private static void PerformTest(string testName, Action act)
90111
}
91112
}
92113

114+
#pragma warning disable IDE1006 // Naming Styles
93115
public class MyDictionary
94116
{
95117
public Dictionary<string, int> myDictionary { get; set; }
@@ -104,4 +126,5 @@ public class MyArray
104126
{
105127
public int[] myArray { get; set; }
106128
}
129+
#pragma warning restore IDE1006 // Naming Styles
107130
}

YamlDotNet.Samples/ConvertYamlToJson.cs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
using System.IO;
2-
using YamlDotNet.Serialization;
3-
using YamlDotNet.Samples.Helpers;
1+
// This file is part of YamlDotNet - A .NET library for YAML.
2+
// Copyright (c) Antoine Aubry and contributors
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
// this software and associated documentation files (the "Software"), to deal in
6+
// the Software without restriction, including without limitation the rights to
7+
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
// of the Software, and to permit persons to whom the Software is furnished to do
9+
// so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
using System.IO;
423
using Xunit.Abstractions;
24+
using YamlDotNet.Samples.Helpers;
25+
using YamlDotNet.Serialization;
526

627
namespace YamlDotNet.Samples
728
{

0 commit comments

Comments
 (0)