Skip to content

Commit 477fca3

Browse files
committed
.editorconfig; lang version; nuget updates
1 parent 111b771 commit 477fca3

File tree

14 files changed

+223
-46
lines changed

14 files changed

+223
-46
lines changed

.editorconfig

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
root = true
2+
3+
4+
[*.{cs,vb}]
5+
indent_size = 4
6+
indent_style = space
7+
end_of_line = crlf
8+
insert_final_newline = true
9+
10+
dotnet_separate_import_directive_groups = false
11+
dotnet_sort_system_directives_first = false
12+
13+
dotnet_style_qualification_for_event = false:suggestion
14+
dotnet_style_qualification_for_field = false:suggestion
15+
dotnet_style_qualification_for_method = false:suggestion
16+
dotnet_style_qualification_for_property = false:suggestion
17+
18+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
19+
dotnet_style_predefined_type_for_member_access = true:suggestion
20+
21+
dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent
22+
dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent
23+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
24+
dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent
25+
26+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
27+
28+
dotnet_style_coalesce_expression = true:suggestion
29+
dotnet_style_collection_initializer = true:suggestion
30+
dotnet_style_explicit_tuple_names = true:suggestion
31+
dotnet_style_null_propagation = true:suggestion
32+
dotnet_style_object_initializer = true:suggestion
33+
dotnet_style_operator_placement_when_wrapping = end_of_line
34+
dotnet_style_prefer_auto_properties = true:suggestion
35+
dotnet_style_prefer_compound_assignment = true:suggestion
36+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
37+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
38+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
39+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
40+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
41+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
42+
dotnet_style_prefer_simplified_interpolation = true:suggestion
43+
44+
45+
# Naming rules
46+
47+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
48+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
49+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
50+
51+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
52+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
53+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
54+
55+
dotnet_naming_rule.non_private_members_should_be_pascal_case.severity = suggestion
56+
dotnet_naming_rule.non_private_members_should_be_pascal_case.symbols = non_private_members
57+
dotnet_naming_rule.non_private_members_should_be_pascal_case.style = pascal_case
58+
59+
dotnet_naming_rule.private_members_should_be_pascal_case.severity = suggestion
60+
dotnet_naming_rule.private_members_should_be_pascal_case.symbols = private_members
61+
dotnet_naming_rule.private_members_should_be_pascal_case.style = camel_case
62+
63+
dotnet_naming_ruke.non_private_fields_should_be_canel_case.severity = suggestion
64+
dotnet_naming_ruke.non_private_fields_should_be_canel_case.symbols = non_private_fields
65+
dotnet_naming_ruke.non_private_fields_should_be_canel_case.style = camel_case
66+
67+
68+
# Symbols for use with naming rules
69+
70+
dotnet_naming_symbols.interface.applicable_kinds = interface
71+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
72+
dotnet_naming_symbols.interface.required_modifiers =
73+
74+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum, delegate
75+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
76+
dotnet_naming_symbols.types.required_modifiers =
77+
78+
dotnet_naming_symbols.non_private_members.applicable_kinds = property, method, event
79+
dotnet_naming_symbols.non_private_members.applicable_accessibilities = public, internal, protected, private_protected, protected_internal
80+
81+
dotnet_naming_symbols.private_members.applicable_kinds = property, method, field, event
82+
dotnet_naming_symbols.private_members.applicable_accessibilities = private
83+
84+
dotnet_naming_symbols.non_private_fields.applicable_kinds = field
85+
dotnet_naming_symbols.non_private_fields.applicable_accessibilities = internal, protected, private_protected, protected_internal
86+
87+
88+
# Naming styles
89+
90+
dotnet_naming_style.pascal_case.required_prefix =
91+
dotnet_naming_style.pascal_case.required_suffix =
92+
dotnet_naming_style.pascal_case.word_separator =
93+
dotnet_naming_style.pascal_case.capitalization = pascal_case
94+
95+
dotnet_naming_style.begins_with_i.required_prefix = I
96+
dotnet_naming_style.begins_with_i.required_suffix =
97+
dotnet_naming_style.begins_with_i.word_separator =
98+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
99+
100+
dotnet_naming_style.camel_case.required_prefix =
101+
dotnet_naming_style.camel_case.required_suffix =
102+
dotnet_naming_style.camel_case.word_separator =
103+
dotnet_naming_style.camel_case.capitalization = camel_case
104+
105+
106+
[*.cs]
107+
csharp_new_line_before_catch = false
108+
csharp_new_line_before_else = false
109+
csharp_new_line_before_finally = false
110+
csharp_new_line_before_members_in_anonymous_types = true
111+
csharp_new_line_before_members_in_object_initializers = true
112+
csharp_new_line_before_open_brace = none
113+
csharp_new_line_between_query_expression_clauses = true
114+
115+
csharp_indent_block_contents = true
116+
csharp_indent_braces = false
117+
csharp_indent_case_contents = true
118+
csharp_indent_case_contents_when_block = true
119+
csharp_indent_labels = one_less_than_current
120+
csharp_indent_switch_labels = true
121+
122+
csharp_space_after_cast = false
123+
csharp_space_after_colon_in_inheritance_clause = true
124+
csharp_space_after_comma = true
125+
csharp_space_after_dot = false
126+
csharp_space_after_keywords_in_control_flow_statements = true
127+
csharp_space_after_semicolon_in_for_statement = true
128+
csharp_space_around_binary_operators = before_and_after
129+
csharp_space_around_declaration_statements = false
130+
csharp_space_before_colon_in_inheritance_clause = true
131+
csharp_space_before_comma = false
132+
csharp_space_before_dot = false
133+
csharp_space_before_open_square_brackets = false
134+
csharp_space_before_semicolon_in_for_statement = false
135+
csharp_space_between_empty_square_brackets = false
136+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
137+
csharp_space_between_method_call_name_and_opening_parenthesis = false
138+
csharp_space_between_method_call_parameter_list_parentheses = false
139+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
140+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
141+
csharp_space_between_method_declaration_parameter_list_parentheses = false
142+
csharp_space_between_parentheses = false
143+
csharp_space_between_square_brackets = false
144+
145+
csharp_preserve_single_line_blocks = true
146+
csharp_preserve_single_line_statements = true
147+
148+
csharp_prefer_braces = true:warning
149+
150+
csharp_style_expression_bodied_constructors = true:suggestion
151+
csharp_style_expression_bodied_methods = true:suggestion
152+
csharp_style_expression_bodied_properties = true:suggestion
153+
154+
csharp_prefer_simple_default_expression = true:suggestion
155+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
156+
157+
csharp_style_var_elsewhere = true:suggestion
158+
csharp_style_var_for_built_in_types = true:suggestion
159+
csharp_style_var_when_type_is_apparent = true:suggestion
160+
161+
csharp_preferred_modifier_order = internal,protected,public,private,static,readonly,abstract,override,sealed,virtual:suggestion
162+
163+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
164+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
165+
csharp_style_inlined_variable_declaration = true:suggestion
166+
csharp_style_deconstructed_variable_declaration = true:suggestion
167+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
168+
csharp_style_throw_expression = true:suggestion
169+
csharp_style_conditional_delegate_call = true:suggestion
170+
171+
172+
[*.vb]
173+
visual_basic_preferred_modifier_order = partial,default,private,protected,public,friend,notoverridable,overridable,mustoverride,overloads,overrides,mustinherit,notinheritable,static,shared,shadows,readonly,writeonly,dim,const,withevents,widening,narrowing,custom,async,iterator:silent
174+
visual_basic_style_unused_value_assignment_preference = unused_local_variable:suggestion
175+
visual_basic_style_unused_value_expression_statement_preference = unused_local_variable:silent

Debuggee/Debuggee.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<TargetFrameworks>net472;netstandard2.0;netcoreapp2.0</TargetFrameworks>
55
<RootNamespace>ExpressionTreeVisualizer.Debuggee</RootNamespace>
66
<AssemblyName>ExpressionTreeVisualizer.Debuggee</AssemblyName>
7-
<LangVersion>8.0</LangVersion>
7+
<LangVersion>9.0</LangVersion>
88
<Nullable>enable</Nullable>
99
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1010
<DefineConstants>VISUALIZER_DEBUGGEE</DefineConstants>
@@ -28,8 +28,8 @@
2828
</PropertyGroup>
2929

3030
<ItemGroup>
31-
<PackageReference Include="ZSpitz.Util" Version="0.1.81" />
32-
<PackageReference Include="ExpressionTreeToString" Version="3.2.53" />
31+
<PackageReference Include="ZSpitz.Util" Version="0.1.105" />
32+
<PackageReference Include="ExpressionTreeToString" Version="3.4.63" />
3333
<Reference Include="Microsoft.VisualStudio.DebuggerVisualizers">
3434
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll</HintPath>
3535
<Private>false</Private>

Package/Package.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
3+
<TargetFrameworks>net472;netcoreapp3.1;net5.0-windows</TargetFrameworks>
44
<RootNamespace>ExpressionTreeVisualizer</RootNamespace>
55
<AssemblyName>ExpressionTreeVisualizer.UI</AssemblyName>
6-
<LangVersion>8.0</LangVersion>
6+
<LangVersion>9.0</LangVersion>
77
<Nullable>enable</Nullable>
88
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
99
<UseWPF>true</UseWPF>
@@ -27,10 +27,10 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="ExpressionTreeToString" Version="3.2.53" />
31-
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
32-
<PackageReference Include="ZSpitz.Util" Version="0.1.81" />
33-
<PackageReference Include="ZSpitz.Util.Wpf" Version="0.1.81" />
30+
<PackageReference Include="ExpressionTreeToString" Version="3.4.63" />
31+
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.31" />
32+
<PackageReference Include="ZSpitz.Util" Version="0.1.105" />
33+
<PackageReference Include="ZSpitz.Util.Wpf" Version="0.1.105" />
3434
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
3535
<PackageReference Include="MultiSelectTreeView" Version="1.0.9" />
3636
</ItemGroup>

Serialization/Config.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override Config Clone() =>
3737
#else
3838
public Config Clone() =>
3939
#endif
40-
new Config {
40+
new() {
4141
Formatter = Formatter,
4242
Language = Language,
4343
Path = Path

Serialization/ExpressionNodeData.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class ExpressionNodeData {
2121
.SelectMany(x => new[] { x, typeof(IEnumerable<>).MakeGenericType(x) })
2222
.ToHashSet();
2323

24-
private static readonly Dictionary<Type, List<(string @namespace, string typename)>> baseTypes = new Dictionary<Type, List<(string @namespace, string typename)>>();
24+
private static readonly Dictionary<Type, List<(string @namespace, string typename)>> baseTypes = new();
2525

2626
private static readonly Dictionary<Type, string[]> factoryMethodNamesByType =
2727
typeof(Expression).GetMethods()
@@ -110,7 +110,7 @@ private ExpressionNodeData(
110110

111111
var (evaluated, value) = valueExtractor.GetValue(expr);
112112
if (evaluated) {
113-
StringValue = StringValue(value!, language); // TODO value is allowed to be null
113+
StringValue = StringValue(value, language); // TODO value is allowed to be null
114114
EnableValueInNewWindow = value is { } && value.GetType().InheritsFromOrImplementsAny(NodeTypes);
115115
}
116116

@@ -142,7 +142,7 @@ private ExpressionNodeData(
142142
NodeType = callSiteBinder.BinderType().ToString();
143143
break;
144144
default:
145-
NodeType = o.GetType().FriendlyName(language);
145+
NodeType = o.GetType().FriendlyName(language)!;
146146
break;
147147
}
148148

@@ -161,11 +161,10 @@ private ExpressionNodeData(
161161
var typename = o.GetType().BaseTypes(false, true).First(x => !x.IsGenericType && x.IsPublic && properties.All(prp => x.GetProperty(prp.Name) is { })); // because the FullName of generic types is often the fully-qualified name
162162
if (parentWatchExpression.IsNullOrWhitespace()) {
163163
var formatString = "{0}";
164-
if (language == CSharp) {
165-
WatchExpressionFormatString = $"(({typename}){formatString})";
166-
} else { // VisualBasic
167-
WatchExpressionFormatString = $"CType({formatString}, {typename})";
168-
}
164+
WatchExpressionFormatString =
165+
language == CSharp ?
166+
$"(({typename}){formatString})" :
167+
$"CType({formatString}, {typename})";
169168
} else {
170169
var watchPathFromParent = PathFromParent;
171170
if (language == CSharp) {
@@ -179,14 +178,15 @@ private ExpressionNodeData(
179178
// populate Children
180179
var preferredOrder = PreferredPropertyOrders.FirstOrDefault(x => x.type.IsAssignableFrom(type)).propertyNames;
181180
Children = properties
182-
.OrderBy(prp => {
183-
if (preferredOrder == null) { return -1; }
184-
return Array.IndexOf(preferredOrder, prp.Name);
185-
})
181+
.OrderBy(prp =>
182+
preferredOrder is not null ?
183+
Array.IndexOf(preferredOrder, prp.Name) :
184+
-1
185+
)
186186
.ThenBy(prp => prp.Name)
187187
.SelectMany(prp => {
188188
if (prp.PropertyType.InheritsFromOrImplements<IEnumerable>()) {
189-
return (prp.GetValue(o) as IEnumerable).Cast<object>().Select((x, index) => ($"{prp.Name}[{index}]", x, prp));
189+
return (prp.GetValue(o) as IEnumerable)!.Cast<object>().Select((x, index) => ($"{prp.Name}[{index}]", x, prp));
190190
} else {
191191
return new[] { (prp.Name, prp.GetValue(o)!, prp) };
192192
}
@@ -213,14 +213,14 @@ private ExpressionNodeData(
213213
Globals.FactoryMethodNames.TryGetValue(((Expression)o).NodeType, out factoryMethodName);
214214
}
215215
if (factoryMethodName.IsNullOrWhitespace()) {
216-
var publicType = o.GetType().BaseTypes(false, true).FirstOrDefault(x => !x.IsInterface && x.IsPublic);
216+
var publicType = o.GetType().BaseTypes(false, true).First(x => !x.IsInterface && x.IsPublic);
217217
factoryMethodNamesByType.TryGetValue(publicType, out _factoryMethodNames!);
218218
} else {
219219
_factoryMethodNames = new[] { factoryMethodName };
220220
}
221221
}
222222

223-
public EndNodeData EndNodeData => new EndNodeData {
223+
public EndNodeData EndNodeData => new() {
224224
Closure = Closure,
225225
Name = Name,
226226
Type = ReflectionTypeName,

Serialization/VisualizerData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class VisualizerData {
1414
public VisualizerData(object o, Config? config = null) {
1515
Config = config ?? new Config();
1616
if (!Config.Path.IsNullOrWhitespace()) {
17-
o = ((Expression)ResolvePath(o, Config.Path)).ExtractValue();
17+
o = ((Expression)ResolvePath(o, Config.Path)!).ExtractValue()!;
1818
}
1919
Source = Renderers.Invoke(Config.Formatter, o, Config.Language, out var pathSpans);
2020

Tests.Visualizer/Tests.csproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
<PropertyGroup>
44
<TargetFramework>net472</TargetFramework>
5-
<LangVersion>8.0</LangVersion>
5+
<LangVersion>9.0</LangVersion>
66
<Nullable>enable</Nullable>
77
<RootNamespace>ExpressionTreeVisualizer.Tests</RootNamespace>
88
<AssemblyName>ExpressionTreeVisualizer.Tests</AssemblyName>
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="ExpressionTreeToString" Version="3.2.53" />
12+
<PackageReference Include="ExpressionTreeToString" Version="3.4.63" />
1313
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
1414
<PackageReference Include="xunit" Version="2.4.1" />
1515
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1818
</PackageReference>
19-
<PackageReference Include="ExpressionTreeTestObjects" Version="1.0.18" />
19+
<PackageReference Include="ExpressionTreeTestObjects" Version="1.0.21" />
20+
<PackageReference Include="ZSpitz.Util" Version="0.1.105" />
2021
</ItemGroup>
2122

2223
<ItemGroup>

UI/ViewModels/EndNodeGroupViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class EndNodeGroupViewModel : Selectable<EndNodeData> {
1616
public EndNodeGroupViewModel(EndNodeData model, IEnumerable<ExpressionNodeDataViewModel> nodes) : base(model) {
1717
Nodes = nodes.ToReadOnlyCollection();
1818

19-
void handler(object s, PropertyChangedEventArgs e) {
19+
void handler(object? s, PropertyChangedEventArgs e) {
2020
if (e.PropertyName != nameof(IsSelected)) { return; }
2121
IsSelected = Nodes.Any(x => x.IsSelected);
2222
}

UI/ViewModels/VisualizerDataViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public ExpressionNodeDataViewModel FindNodeBySpan(int start, int length) {
8484
//if (start < NodeData.Span.start || end > NodeData.SpanEnd) { throw new ArgumentOutOfRangeException(); }
8585
var current = Root;
8686
while (true) {
87-
var child = current.Children.SingleOrDefault(x => x.Model.Span.start <= start && x.Model.SpanEnd >= end);
87+
var child =
88+
(start, length) == (0,0) ?
89+
current.Children.FirstOrDefault(x => x.Model.Span == (0,0)) :
90+
current.Children.SingleOrDefault(x => x.Model.Span.start <= start && x.Model.SpanEnd >= end);
8891
if (child == null) { break; }
8992
current = child;
9093
}
@@ -127,4 +130,4 @@ public string WindowTitle {
127130
}
128131
}
129132
}
130-
}
133+
}

0 commit comments

Comments
 (0)