Skip to content

Commit 0e6f24b

Browse files
Checkpoint.
1 parent 4420e02 commit 0e6f24b

12 files changed

+485
-365
lines changed

.editorconfig

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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 = true
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

AsyncProcess.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
using Open.Disposable;
2-
using System;
32
using System.Diagnostics.Contracts;
4-
using System.Threading;
5-
using System.Threading.Tasks;
63

74
namespace Open.Threading;
85

@@ -81,7 +78,7 @@ protected virtual void Process(object progress)
8178
protected virtual Task EnsureProcess(bool once, TimeSpan? timeAllowedBeforeRefresh = null)
8279
{
8380
Task? task = null;
84-
SyncLock!.ReadWriteConditionalOptimized(
81+
SyncLock!.ReadWriteConditional(
8582
_ =>
8683
{
8784
task = InternalTask;

AsyncQuery.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System;
2-
using System.Diagnostics.CodeAnalysis;
3-
using System.Threading.Tasks;
1+
using System.Diagnostics.CodeAnalysis;
42

53
namespace Open.Threading.Tasks;
64

@@ -30,7 +28,7 @@ protected Task<TResult> EnsureProcessValued(bool once, TimeSpan? timeAllowedBefo
3028
{
3129
Task<TResult>? task = null;
3230

33-
SyncLock!.ReadWriteConditionalOptimized(
31+
SyncLock!.ReadWriteConditional(
3432
_ =>
3533
{
3634
task = InternalTaskValued;
@@ -110,7 +108,8 @@ public virtual void OverrideLatest(TResult value, DateTime? completed = null) =>
110108
IsLatestAvailable = true;
111109
});
112110

113-
public virtual void OverrideLatest(TResult value, Func<TResult, TResult, bool> useNewValueEvaluator, DateTime? completed = null) => SyncLock!.ReadWriteConditionalOptimized(
111+
public virtual void OverrideLatest(TResult value, Func<TResult, TResult, bool> useNewValueEvaluator, DateTime? completed = null)
112+
=> SyncLock!.ReadWriteConditional(
114113
(_) => useNewValueEvaluator(_latest, value),
115114
() =>
116115
{
@@ -129,7 +128,7 @@ public TResult Latest
129128

130129
public bool WaitForRunningToComplete(TimeSpan? waitForCurrentTimeout = null)
131130
{
132-
var task = SyncLock!.ReadValue(() => InternalTaskValued);
131+
var task = SyncLock!.Read(() => InternalTaskValued);
133132
if (task is null) return false;
134133
if (waitForCurrentTimeout.HasValue)
135134
task.Wait(waitForCurrentTimeout.Value);
@@ -142,7 +141,7 @@ public TResult RunningValue
142141
{
143142
get
144143
{
145-
var task = SyncLock!.ReadValue(() => InternalTaskValued);
144+
var task = SyncLock!.Read(() => InternalTaskValued);
146145
return task is null ? GetRunningValue() : task.Result;
147146
}
148147
}
@@ -168,7 +167,7 @@ public virtual bool TryGetLatest(
168167
{
169168
var result = default(TResult);
170169
var resultComplete = DateTime.MinValue;
171-
var isReady = SyncLock!.ReadValue(() =>
170+
var isReady = SyncLock!.Read(() =>
172171
{
173172
result = _latest;
174173
resultComplete = LatestCompleted;

Container.cs

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using Open.Disposable;
2-
using System;
32
using System.Diagnostics.CodeAnalysis;
4-
using System.Threading;
53

64
namespace Open.Threading;
75

@@ -95,7 +93,7 @@ public bool SetValue(T value)
9593
AssertIsAlive();
9694
var init = false;
9795

98-
var original = SyncLock.WriteValue(() =>
96+
var original = SyncLock.Write(() =>
9997
{
10098
AssertIsAlive();
10199

@@ -153,7 +151,7 @@ private void OnValueUpdatedInternal(T originalValue, T newValue)
153151
public bool GetValue(out T value)
154152
{
155153
var hv = false;
156-
value = SyncLock.ReadValue(() =>
154+
value = SyncLock.Read(() =>
157155
{
158156
var r = GetValue();
159157
hv = HasValue;
@@ -169,17 +167,18 @@ public bool GetValue(out T value)
169167
public T GetOrUpdate(Func<T> valueFactory)
170168
{
171169
var result = _value;
172-
if (valueFactory is not null)
173-
{
174-
SyncLock.ReadWriteConditional((_) =>
170+
if (valueFactory is null)
171+
return result;
172+
173+
SyncLock.ReadWriteConditional(
174+
(_) =>
175175
{
176176
AssertIsAlive();
177177
result = _value;
178178
return !HasValue;
179-
}, () =>
180-
SetValue(result = valueFactory())
181-
);
182-
}
179+
},
180+
() => SetValue(result = valueFactory())
181+
);
183182
return result;
184183
}
185184

@@ -226,7 +225,7 @@ public Container(T value) : base(value) { }
226225
public Func<T>? ValueFactory
227226
{
228227
get => _valueFactory;
229-
set => SyncLock.WriteValue(() => _valueFactory = value);
228+
set => SyncLock.Write(() => _valueFactory = value);
230229
}
231230

232231
public void EnsureValueFactory(Func<T> valueFactory, bool ensuredIfValuePresent = false)
@@ -241,7 +240,7 @@ public void EnsureValueFactory(Func<T> valueFactory, bool ensuredIfValuePresent
241240
}
242241
}
243242

244-
protected override T Eval() => SyncLock.ReadValue(_valueFactory ?? base.Eval);
243+
protected override T Eval() => SyncLock.Read(_valueFactory ?? base.Eval);
245244

246245
protected override void OnDispose()
247246
{
@@ -264,10 +263,11 @@ public ContainerLight(T value) : base(value) { }
264263
public ContainerLight(Func<T> valueFactory)
265264
: base(valueFactory) { }
266265

267-
protected override T Eval() => SyncLock.ReadValue(() =>
268-
{
269-
var result = base.Eval();
270-
ValueFactory = null;
271-
return result;
272-
});
266+
protected override T Eval()
267+
=> SyncLock.Read(() =>
268+
{
269+
var result = base.Eval();
270+
ValueFactory = null;
271+
return result;
272+
});
273273
}

0 commit comments

Comments
 (0)