Skip to content

Commit 134fdfe

Browse files
Style update and a fix.
1 parent 7fb37ed commit 134fdfe

5 files changed

Lines changed: 1056 additions & 853 deletions

File tree

.editorconfig

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
# C# files
2+
[*.cs]
3+
4+
#### Core EditorConfig Options ####
5+
6+
# Indentation and spacing
7+
indent_size = 4
8+
indent_style = tab
9+
tab_width = 4
10+
11+
# New line preferences
12+
end_of_line = crlf
13+
insert_final_newline = false
14+
15+
#### .NET Coding Conventions ####
16+
17+
# Organize usings
18+
dotnet_separate_import_directive_groups = false
19+
dotnet_sort_system_directives_first = false
20+
file_header_template = unset
21+
22+
# this. and Me. preferences
23+
dotnet_style_qualification_for_event = false:suggestion
24+
dotnet_style_qualification_for_field = false
25+
dotnet_style_qualification_for_method = false:suggestion
26+
dotnet_style_qualification_for_property = false:suggestion
27+
28+
# Language keywords vs BCL types preferences
29+
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
30+
dotnet_style_predefined_type_for_member_access = true:warning
31+
32+
# Parentheses preferences
33+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:suggestion
34+
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:suggestion
35+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
36+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:suggestion
37+
38+
# Modifier preferences
39+
dotnet_style_require_accessibility_modifiers = for_non_interface_members
40+
41+
# Expression-level preferences
42+
dotnet_style_coalesce_expression = true:warning
43+
dotnet_style_collection_initializer = true
44+
dotnet_style_explicit_tuple_names = true
45+
dotnet_style_namespace_match_folder = true
46+
dotnet_style_null_propagation = true:warning
47+
dotnet_style_object_initializer = true
48+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
49+
dotnet_style_prefer_auto_properties = true:suggestion
50+
dotnet_style_prefer_compound_assignment = true
51+
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
52+
dotnet_style_prefer_conditional_expression_over_return = true:warning
53+
dotnet_style_prefer_inferred_anonymous_type_member_names = true
54+
dotnet_style_prefer_inferred_tuple_names = true
55+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
56+
dotnet_style_prefer_simplified_boolean_expressions = true:warning
57+
dotnet_style_prefer_simplified_interpolation = true
58+
59+
# Field preferences
60+
dotnet_style_readonly_field = true
61+
62+
# Parameter preferences
63+
dotnet_code_quality_unused_parameters = all
64+
65+
# Suppression preferences
66+
dotnet_remove_unnecessary_suppression_exclusions = none
67+
68+
# New line preferences
69+
dotnet_style_allow_multiple_blank_lines_experimental = true
70+
dotnet_style_allow_statement_immediately_after_block_experimental = false
71+
72+
#### C# Coding Conventions ####
73+
74+
# var preferences
75+
csharp_style_var_elsewhere = false
76+
csharp_style_var_for_built_in_types = false
77+
csharp_style_var_when_type_is_apparent = true:suggestion
78+
79+
# Expression-bodied members
80+
csharp_style_expression_bodied_accessors = true:suggestion
81+
csharp_style_expression_bodied_constructors = when_on_single_line:silent
82+
csharp_style_expression_bodied_indexers = true:suggestion
83+
csharp_style_expression_bodied_lambdas = true:suggestion
84+
csharp_style_expression_bodied_local_functions = true:suggestion
85+
csharp_style_expression_bodied_methods = true:suggestion
86+
csharp_style_expression_bodied_operators = true:suggestion
87+
csharp_style_expression_bodied_properties = true:suggestion
88+
89+
# Pattern matching preferences
90+
csharp_style_pattern_matching_over_as_with_null_check = true:warning
91+
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
92+
csharp_style_prefer_not_pattern = true:warning
93+
csharp_style_prefer_pattern_matching = true:suggestion
94+
csharp_style_prefer_switch_expression = true
95+
96+
# Null-checking preferences
97+
csharp_style_conditional_delegate_call = true:warning
98+
99+
# Modifier preferences
100+
csharp_prefer_static_local_function = true
101+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
102+
103+
# Code-block preferences
104+
csharp_prefer_braces = when_multiline:silent
105+
csharp_prefer_simple_using_statement = true:suggestion
106+
csharp_style_namespace_declarations = file_scoped:suggestion
107+
108+
# Expression-level preferences
109+
csharp_prefer_simple_default_expression = true
110+
csharp_style_deconstructed_variable_declaration = true
111+
csharp_style_implicit_object_creation_when_type_is_apparent = true
112+
csharp_style_inlined_variable_declaration = true
113+
csharp_style_pattern_local_over_anonymous_function = true
114+
csharp_style_prefer_index_operator = true:silent
115+
csharp_style_prefer_null_check_over_type_check = true:warning
116+
csharp_style_prefer_range_operator = true:silent
117+
csharp_style_throw_expression = true:warning
118+
csharp_style_unused_value_assignment_preference = discard_variable
119+
csharp_style_unused_value_expression_statement_preference = discard_variable
120+
121+
# 'using' directive preferences
122+
csharp_using_directive_placement = outside_namespace:warning
123+
124+
# New line preferences
125+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:warning
126+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
127+
csharp_style_allow_embedded_statements_on_same_line_experimental = true
128+
129+
#### C# Formatting Rules ####
130+
131+
# New line preferences
132+
csharp_new_line_before_catch = true
133+
csharp_new_line_before_else = true
134+
csharp_new_line_before_finally = true
135+
csharp_new_line_before_members_in_anonymous_types = true
136+
csharp_new_line_before_members_in_object_initializers = true
137+
csharp_new_line_before_open_brace = all
138+
csharp_new_line_between_query_expression_clauses = true
139+
140+
# Indentation preferences
141+
csharp_indent_block_contents = true
142+
csharp_indent_braces = false
143+
csharp_indent_case_contents = true
144+
csharp_indent_case_contents_when_block = false
145+
csharp_indent_labels = one_less_than_current
146+
csharp_indent_switch_labels = true
147+
148+
# Space preferences
149+
csharp_space_after_cast = false
150+
csharp_space_after_colon_in_inheritance_clause = true
151+
csharp_space_after_comma = true
152+
csharp_space_after_dot = false
153+
csharp_space_after_keywords_in_control_flow_statements = true
154+
csharp_space_after_semicolon_in_for_statement = true
155+
csharp_space_around_binary_operators = before_and_after
156+
csharp_space_around_declaration_statements = false
157+
csharp_space_before_colon_in_inheritance_clause = true
158+
csharp_space_before_comma = false
159+
csharp_space_before_dot = false
160+
csharp_space_before_open_square_brackets = false
161+
csharp_space_before_semicolon_in_for_statement = false
162+
csharp_space_between_empty_square_brackets = false
163+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
164+
csharp_space_between_method_call_name_and_opening_parenthesis = false
165+
csharp_space_between_method_call_parameter_list_parentheses = false
166+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
167+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
168+
csharp_space_between_method_declaration_parameter_list_parentheses = false
169+
csharp_space_between_parentheses = false
170+
csharp_space_between_square_brackets = false
171+
172+
# Wrapping preferences
173+
csharp_preserve_single_line_blocks = true
174+
csharp_preserve_single_line_statements = true
175+
176+
#### Naming styles ####
177+
178+
# Naming rules
179+
180+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
181+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
182+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
183+
184+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
185+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
186+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
187+
188+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
189+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
190+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
191+
192+
# Symbol specifications
193+
194+
dotnet_naming_symbols.interface.applicable_kinds = interface
195+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
196+
dotnet_naming_symbols.interface.required_modifiers =
197+
198+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
199+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
200+
dotnet_naming_symbols.types.required_modifiers =
201+
202+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
203+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
204+
dotnet_naming_symbols.non_field_members.required_modifiers =
205+
206+
# Naming styles
207+
208+
dotnet_naming_style.pascal_case.required_prefix =
209+
dotnet_naming_style.pascal_case.required_suffix =
210+
dotnet_naming_style.pascal_case.word_separator =
211+
dotnet_naming_style.pascal_case.capitalization = pascal_case
212+
213+
dotnet_naming_style.begins_with_i.required_prefix = I
214+
dotnet_naming_style.begins_with_i.required_suffix =
215+
dotnet_naming_style.begins_with_i.word_separator =
216+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
217+
csharp_style_prefer_extended_property_pattern = true:suggestion
218+
219+
[*.{cs,vb}]
220+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
221+
tab_width = 4
222+
indent_size = 4
223+
end_of_line = crlf
224+
dotnet_style_coalesce_expression = true:warning
225+
dotnet_style_null_propagation = true:warning
226+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
227+
dotnet_style_prefer_auto_properties = true:suggestion
228+
dotnet_style_qualification_for_property = false:suggestion
229+
230+
# RCS1123: Add parentheses when necessary.
231+
dotnet_diagnostic.RCS1123.severity = silent
232+
233+
# HAA0502: new allocation
234+
dotnet_diagnostic.HAA0502.severity = silent
235+
236+
# RCS1242: leave silent for simplicity with .NET Standard 2.0
237+
dotnet_diagnostic.RCS1242.severity = silent
238+
239+
dotnet_style_object_initializer = true:suggestion
240+
dotnet_style_collection_initializer = true:suggestion
241+
dotnet_style_prefer_simplified_boolean_expressions = true:warning
242+
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
243+
dotnet_style_prefer_conditional_expression_over_return = true:warning
244+
dotnet_style_explicit_tuple_names = true:suggestion

DeferredHashSet.cs

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
11
using System;
22
using System.Collections.Generic;
3-
namespace Open.RandomizationExtensions
3+
4+
namespace Open.RandomizationExtensions;
5+
6+
class DeferredHashSet<T> : HashSet<T>, IDisposable
47
{
5-
class DeferredHashSet<T> : HashSet<T>, IDisposable
6-
{
7-
public DeferredHashSet(IEnumerator<T> source)
8-
{
9-
Source = source ?? throw new ArgumentNullException(nameof(source));
10-
}
8+
public DeferredHashSet(IEnumerator<T> source)
9+
=> Source = source ?? throw new ArgumentNullException(nameof(source));
1110

12-
public DeferredHashSet(IEnumerable<T> source)
13-
: this((source ?? throw new ArgumentNullException(nameof(source))).GetEnumerator())
14-
{
11+
public DeferredHashSet(IEnumerable<T> source)
12+
: this((source ?? throw new ArgumentNullException(nameof(source))).GetEnumerator()) { }
1513

16-
}
14+
private readonly IEnumerator<T> Source;
1715

18-
private readonly IEnumerator<T> Source;
16+
public new bool Contains(T item)
17+
{
18+
if (base.Contains(item))
19+
return true;
1920

20-
public new bool Contains(T item)
21+
while (Source.MoveNext())
2122
{
22-
if (base.Contains(item))
23+
var i = Source.Current;
24+
_ = Add(i);
25+
if (item is null ? i is null : item.Equals(i))
2326
return true;
24-
25-
while (Source.MoveNext())
26-
{
27-
var i = Source.Current;
28-
Add(i);
29-
if (item is null ? i is null : item.Equals(i))
30-
return true;
31-
}
32-
33-
return false;
3427
}
3528

36-
public void Dispose()
37-
{
38-
Source.Dispose();
39-
this.Clear();
40-
}
29+
return false;
30+
}
31+
32+
public void Dispose()
33+
{
34+
Source.Dispose();
35+
Clear();
4136
}
4237
}

Open.RandomizationExtensions.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.RandomizationExtensions</RepositoryUrl>
1919
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2020
<RepositoryType>git</RepositoryType>
21-
<Version>2.5.2</Version>
21+
<Version>2.5.3</Version>
2222
<PackageReleaseNotes></PackageReleaseNotes>
2323
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2424
<PublishRepositoryUrl>true</PublishRepositoryUrl>

0 commit comments

Comments
 (0)