Skip to content

Commit 6c58037

Browse files
authored
housekeeping: Update to C# 10 (#2987)
1 parent a43e99a commit 6c58037

File tree

374 files changed

+27060
-28870
lines changed

Some content is hidden

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

374 files changed

+27060
-28870
lines changed

.editorconfig

Lines changed: 88 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,45 @@ root = true
1010
insert_final_newline = true
1111
indent_style = space
1212
indent_size = 4
13-
trim_trailing_whitespace = true
13+
dotnet_diagnostic.CA1027.severity=error
14+
dotnet_diagnostic.CA1062.severity=error
15+
dotnet_diagnostic.CA1064.severity=error
16+
dotnet_diagnostic.CA1066.severity=error
17+
dotnet_diagnostic.CA1067.severity=error
18+
dotnet_diagnostic.CA1068.severity=error
19+
dotnet_diagnostic.CA1069.severity=warning
20+
dotnet_diagnostic.CA2013.severity=error
21+
dotnet_diagnostic.CA1802.severity=error
22+
dotnet_diagnostic.CA1813.severity=error
23+
dotnet_diagnostic.CA1814.severity=error
24+
dotnet_diagnostic.CA1815.severity=error
25+
dotnet_diagnostic.CA1822.severity=error
26+
dotnet_diagnostic.CA1827.severity=error
27+
dotnet_diagnostic.CA1828.severity=error
28+
dotnet_diagnostic.CA1826.severity=error
29+
dotnet_diagnostic.CA1829.severity=error
30+
dotnet_diagnostic.CA1830.severity=error
31+
dotnet_diagnostic.CA1831.severity=error
32+
dotnet_diagnostic.CA1832.severity=error
33+
dotnet_diagnostic.CA1833.severity=error
34+
dotnet_diagnostic.CA1834.severity=error
35+
dotnet_diagnostic.CA1835.severity=error
36+
dotnet_diagnostic.CA1836.severity=error
37+
dotnet_diagnostic.CA1837.severity=error
38+
dotnet_diagnostic.CA1838.severity=error
39+
dotnet_diagnostic.CA2015.severity=error
40+
dotnet_diagnostic.CA2012.severity=error
41+
dotnet_diagnostic.CA2011.severity=error
42+
dotnet_diagnostic.CA2009.severity=error
43+
dotnet_diagnostic.CA2008.severity=error
44+
dotnet_diagnostic.CA2007.severity=warning
45+
dotnet_diagnostic.CA2000.severity=suggestion
46+
47+
[project.json]
48+
indent_size = 2
1449

1550
# C# files
1651
[*.cs]
17-
1852
# New line preferences
1953
csharp_new_line_before_open_brace = all
2054
csharp_new_line_before_else = true
@@ -41,10 +75,12 @@ dotnet_style_qualification_for_property = false:suggestion
4175
dotnet_style_qualification_for_method = false:suggestion
4276
dotnet_style_qualification_for_event = false:suggestion
4377

44-
# Types: use keywords instead of BCL types, and permit var only when the type is clear
78+
# only use var when it's obvious what the variable type is
4579
csharp_style_var_for_built_in_types = true:suggestion
46-
csharp_style_var_when_type_is_apparent = true:none
80+
csharp_style_var_when_type_is_apparent = true:suggestion
4781
csharp_style_var_elsewhere = true:suggestion
82+
83+
# prefer C# premade types.
4884
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
4985
dotnet_style_predefined_type_for_member_access = true:suggestion
5086

@@ -56,14 +92,14 @@ dotnet_naming_symbols.constant_fields.applicable_kinds = field
5692
dotnet_naming_symbols.constant_fields.required_modifiers = const
5793
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
5894

59-
# static fields should have _ prefix
95+
# static fields should have s_ prefix
6096
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
6197
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
6298
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
6399
dotnet_naming_symbols.static_fields.applicable_kinds = field
64100
dotnet_naming_symbols.static_fields.required_modifiers = static
65101
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
66-
dotnet_naming_style.static_prefix_style.required_prefix = _
102+
dotnet_naming_style.static_prefix_style.required_prefix = s_
67103
dotnet_naming_style.static_prefix_style.capitalization = camel_case
68104

69105
# internal and private fields should be _camelCase
@@ -78,7 +114,7 @@ dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
78114
# Code style defaults
79115
csharp_using_directive_placement = outside_namespace:suggestion
80116
dotnet_sort_system_directives_first = true
81-
csharp_prefer_braces = true:suggestion
117+
csharp_prefer_braces = true:silent
82118
csharp_preserve_single_line_blocks = true:none
83119
csharp_preserve_single_line_statements = false:none
84120
csharp_prefer_static_local_function = true:suggestion
@@ -99,8 +135,8 @@ dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggesti
99135
dotnet_style_prefer_inferred_tuple_names = true:suggestion
100136
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
101137
dotnet_style_prefer_auto_properties = true:suggestion
102-
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
103-
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
138+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
139+
dotnet_style_prefer_conditional_expression_over_return = true:silent
104140
csharp_prefer_simple_default_expression = true:suggestion
105141

106142
# Expression-bodied members
@@ -242,7 +278,6 @@ dotnet_diagnostic.RCS1074.severity = error
242278
dotnet_diagnostic.RCS1090.severity = error
243279
dotnet_diagnostic.RCS1138.severity = error
244280
dotnet_diagnostic.RCS1139.severity = error
245-
dotnet_diagnostic.RCS1158.severity = none
246281
dotnet_diagnostic.RCS1163.severity = suggestion
247282
dotnet_diagnostic.RCS1168.severity = suggestion
248283
dotnet_diagnostic.RCS1188.severity = error
@@ -365,7 +400,7 @@ dotnet_diagnostic.SA1501.severity = error
365400
dotnet_diagnostic.SA1502.severity = error
366401
dotnet_diagnostic.SA1503.severity = error
367402
dotnet_diagnostic.SA1504.severity = error
368-
dotnet_diagnostic.SA1505.severity = error
403+
dotnet_diagnostic.SA1505.severity = none
369404
dotnet_diagnostic.SA1506.severity = error
370405
dotnet_diagnostic.SA1507.severity = error
371406
dotnet_diagnostic.SA1508.severity = error
@@ -374,7 +409,7 @@ dotnet_diagnostic.SA1510.severity = error
374409
dotnet_diagnostic.SA1511.severity = error
375410
dotnet_diagnostic.SA1512.severity = error
376411
dotnet_diagnostic.SA1513.severity = error
377-
dotnet_diagnostic.SA1514.severity = error
412+
dotnet_diagnostic.SA1514.severity = none
378413
dotnet_diagnostic.SA1515.severity = error
379414
dotnet_diagnostic.SA1516.severity = error
380415
dotnet_diagnostic.SA1517.severity = error
@@ -424,22 +459,55 @@ dotnet_diagnostic.SA1651.severity = error
424459
dotnet_diagnostic.SX1101.severity = error
425460
dotnet_diagnostic.SX1309.severity = error
426461
dotnet_diagnostic.SX1623.severity = none
427-
428-
dotnet_diagnostic.IDE0046.severity = suggestion
429-
dotnet_diagnostic.IDE0060.severity = none
462+
dotnet_diagnostic.RCS1102.severity=error
463+
dotnet_diagnostic.RCS1166.severity=error
464+
dotnet_diagnostic.RCS1078i.severity=error
465+
dotnet_diagnostic.RCS1248.severity=error
466+
dotnet_diagnostic.RCS1080.severity=error
467+
dotnet_diagnostic.RCS1077.severity=error
468+
dotnet_diagnostic.CA1825.severity=error
469+
dotnet_diagnostic.CA1812.severity=error
470+
dotnet_diagnostic.CA1805.severity=error
471+
dotnet_diagnostic.RCS1197.severity=error
472+
dotnet_diagnostic.RCS1198.severity=suggestion
473+
dotnet_diagnostic.RCS1231.severity=suggestion
474+
dotnet_diagnostic.RCS1235.severity=error
475+
dotnet_diagnostic.RCS1242.severity=error
476+
dotnet_diagnostic.CA2016.severity=warning
477+
dotnet_diagnostic.CA2014.severity=error
478+
dotnet_diagnostic.RCS1010.severity=error
479+
dotnet_diagnostic.RCS1006.severity=error
480+
dotnet_diagnostic.RCS1005.severity=error
481+
dotnet_diagnostic.RCS1020.severity=error
482+
dotnet_diagnostic.RCS1049.severity=warning
483+
dotnet_diagnostic.RCS1058.severity=warning
484+
dotnet_diagnostic.RCS1068.severity=warning
485+
dotnet_diagnostic.RCS1073.severity=warning
486+
dotnet_diagnostic.RCS1084.severity=error
487+
dotnet_diagnostic.RCS1085.severity=error
488+
dotnet_diagnostic.RCS1105.severity=error
489+
dotnet_diagnostic.RCS1112.severity=error
490+
dotnet_diagnostic.RCS1128.severity=error
491+
dotnet_diagnostic.RCS1143.severity=error
492+
dotnet_diagnostic.RCS1171.severity=error
493+
dotnet_diagnostic.RCS1173.severity=error
494+
dotnet_diagnostic.RCS1176.severity=error
495+
dotnet_diagnostic.RCS1177.severity=error
496+
dotnet_diagnostic.RCS1179.severity=error
497+
dotnet_diagnostic.RCS1180.severity=warning
498+
dotnet_diagnostic.RCS1190.severity=error
499+
dotnet_diagnostic.RCS1195.severity=error
500+
dotnet_diagnostic.RCS1214.severity=error
430501

431502
# C++ Files
432503
[*.{cpp,h,in}]
433504
curly_bracket_next_line = true
434505
indent_brace_style = Allman
435506

436507
# Xml project files
437-
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
508+
[*.{csproj,vcxproj,vcxproj.filters,proj,nativeproj,locproj}]
438509
indent_size = 2
439510

440-
[*.{csproj,vbproj,proj,nativeproj,locproj}]
441-
charset = utf-8
442-
443511
# Xml build files
444512
[*.builds]
445513
indent_size = 2
@@ -452,13 +520,8 @@ indent_size = 2
452520
[*.{props,targets,config,nuspec}]
453521
indent_size = 2
454522

455-
# YAML config files
456-
[*.{yml,yaml}]
457-
indent_size = 2
458-
459523
# Shell scripts
460524
[*.sh]
461525
end_of_line = lf
462-
463-
[*.{cmd,bat}]
526+
[*.{cmd, bat}]
464527
end_of_line = crlf

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ src/ReactiveUI.Events*/Events_*.cs
355355
# macOS
356356
.DS_Store
357357

358-
src/*.Tests/**/ApiApprovalTests*.received.txt
358+
src/*.Tests/**/*ApiApprovalTests*.received.txt
359359
.idea/
360360

361361
# Fody Weavers (for tests)

images/logo.png

Lines changed: 3 additions & 0 deletions
Loading

integrationtests/IntegrationTests.Android/MainActivity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ public override bool OnCreateOptionsMenu(IMenu menu)
5454
/// <inheritdoc />
5555
public override bool OnOptionsItemSelected(IMenuItem item)
5656
{
57+
if (item is null)
58+
{
59+
throw new ArgumentNullException(nameof(item));
60+
}
61+
5762
return item.ItemId == Resource.Id.action_settings || base.OnOptionsItemSelected(item);
5863
}
5964

integrationtests/IntegrationTests.Shared.Tests/BuilderExtensions.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6+
using System;
67
using System.Collections.Generic;
78

89
namespace IntegrationTests.Shared.Tests
@@ -41,7 +42,12 @@ public static TBuilder With<TBuilder, TField>(this TBuilder @this, ref TField fi
4142
public static TBuilder With<TBuilder, TField>(this TBuilder @this, ref List<TField> field, IEnumerable<TField> values)
4243
where TBuilder : IBuilder
4344
{
44-
if (values == null)
45+
if (field is null)
46+
{
47+
throw new ArgumentNullException(nameof(field));
48+
}
49+
50+
if (values is null)
4551
{
4652
field = null;
4753
}
@@ -66,6 +72,11 @@ public static TBuilder With<TBuilder, TField>(this TBuilder @this, ref List<TFie
6672
public static TBuilder With<TBuilder, TField>(this TBuilder @this, ref List<TField> field, TField value)
6773
where TBuilder : IBuilder
6874
{
75+
if (field is null)
76+
{
77+
throw new ArgumentNullException(nameof(field));
78+
}
79+
6980
field.Add(value);
7081
return @this;
7182
}

integrationtests/IntegrationTests.Shared.Tests/Features/Login/LoginViewModelBuilder.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// The .NET Foundation licenses this file to you under the MIT license.
44
// See the LICENSE file in the project root for full license information.
55

6+
using System;
67
using System.Reactive.Concurrency;
78

89
namespace IntegrationTests.Shared.Tests.Features.Login
@@ -28,7 +29,10 @@ public LoginViewModelBuilder()
2829
/// Converts the builder into a LoginViewModel using automatic casting.
2930
/// </summary>
3031
/// <param name="builder">The builder instance to convert into a LoginViewModel.</param>
31-
public static implicit operator LoginViewModel(LoginViewModelBuilder builder) => builder.ToLoginViewModel();
32+
public static implicit operator LoginViewModel(LoginViewModelBuilder builder)
33+
{
34+
return builder?.ToLoginViewModel();
35+
}
3236

3337
/// <summary>
3438
/// Logs the user in with the specified user name.

integrationtests/IntegrationTests.UWP/App.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
4040

4141
// Do not repeat app initialization when the Window already has content,
4242
// just ensure that the window is active
43-
if (rootFrame == null)
43+
if (rootFrame is null)
4444
{
4545
// Create a Frame to act as the navigation context and navigate to the first page
4646
rootFrame = new Frame();
@@ -58,7 +58,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
5858

5959
if (!e.PrelaunchActivated)
6060
{
61-
if (rootFrame.Content == null)
61+
if (rootFrame.Content is null)
6262
{
6363
// When the navigation stack isn't restored navigate to the first page,
6464
// configuring the new page by passing required information as a navigation

integrationtests/IntegrationTests.UWP/IntegrationTests.UWP.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<AssemblyName>IntegrationTests.UWP</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14-
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.17763.0</TargetPlatformVersion>
15-
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
14+
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.16299.0</TargetPlatformVersion>
15+
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>
1818
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

integrationtests/IntegrationTests.XamarinForms.UWP/App.xaml.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,16 @@ public App()
3636
/// <param name="e">Details about the launch request and process.</param>
3737
protected override void OnLaunched(LaunchActivatedEventArgs e)
3838
{
39+
if (e is null)
40+
{
41+
throw new ArgumentNullException(nameof(e));
42+
}
43+
3944
var rootFrame = Window.Current.Content as Frame;
4045

4146
// Do not repeat app initialization when the Window already has content,
4247
// just ensure that the window is active
43-
if (rootFrame == null)
48+
if (rootFrame is null)
4449
{
4550
// Create a Frame to act as the navigation context and navigate to the first page
4651
rootFrame = new Frame();
@@ -58,7 +63,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
5863
Window.Current.Content = rootFrame;
5964
}
6065

61-
if (rootFrame.Content == null)
66+
if (rootFrame.Content is null)
6267
{
6368
// When the navigation stack isn't restored navigate to the first page,
6469
// configuring the new page by passing required information as a navigation

integrationtests/IntegrationTests.XamarinForms.UWP/IntegrationTests.XamarinForms.UWP.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<AssemblyName>IntegrationTests.XamarinForms.UWP</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14-
<TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion>
15-
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
14+
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
15+
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<EnableDotNetNativeCompatibleProfile>true</EnableDotNetNativeCompatibleProfile>
1818
<FileAlignment>512</FileAlignment>

0 commit comments

Comments
 (0)