Skip to content

A Swiss Army knife for developers.

Updated CI, added .editorconfig and ran Code Cleanup (#66)

Etienne Baudoux55b0a41ee6f7
diff --git a/ci/azure-pipelines-release.yml b/ci/azure-pipelines-release.yml
index 672dc17c5..bd6566f5a 100644
--- a/ci/azure-pipelines-release.yml
+++ b/ci/azure-pipelines-release.yml
@@ -7,7 +7,7 @@ trigger: none
pr: none
pool:
- vmImage: 'windows-2022'
+ vmImage: 'windows-2019'
variables:
group: BuildPipelineVariables
@@ -15,6 +15,7 @@ variables:
buildPlatform: 'x86|x64|ARM'
buildConfiguration: 'Release'
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
+ buildFolder: '$(Build.SourcesDirectory)\bin\'
certificateSecureFilePath: 'DevToys.Startup_TemporaryKey.pfx'
jobs:
@@ -67,7 +68,8 @@ jobs:
solution: '$(uwpProject)'
platform: 'x86'
configuration: '$(buildConfiguration)'
- msbuildArguments: '/t:build;_GenerateAppxPackage
+ msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"
+ /t:build;_GenerateAppxPackage
/p:AppxBundlePlatforms="$(buildPlatform)"
/p:AppxPackageDir="$(appxPackageDir)"
/p:AppxBundle=Always
@@ -82,6 +84,13 @@ jobs:
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(appxPackageDir)'
+ condition: succeeded()
+
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifact: output'
+ inputs:
+ PathtoPublish: '$(buildFolder)'
+ condition: failed()
### Store release ###
- job: StoreRelease
@@ -126,7 +135,8 @@ jobs:
solution: '$(uwpProject)'
platform: 'x86'
configuration: '$(buildConfiguration)'
- msbuildArguments: '/t:build;_GenerateAppxPackage
+ msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"
+ /t:build;_GenerateAppxPackage
/p:AppxBundlePlatforms="$(buildPlatform)"
/p:AppxPackageDir="$(appxPackageDir)"
/p:AppxBundle=Always
@@ -138,3 +148,10 @@ jobs:
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(appxPackageDir)'
+ condition: succeeded()
+
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifact: output'
+ inputs:
+ PathtoPublish: '$(buildFolder)'
+ condition: failed()
\ No newline at end of file
diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml
index 6ffd0bc89..2650db424 100644
--- a/ci/azure-pipelines.yml
+++ b/ci/azure-pipelines.yml
@@ -7,7 +7,7 @@ trigger:
- main
pool:
- vmImage: 'windows-2022'
+ vmImage: 'windows-2019'
variables:
group: BuildPipelineVariables
@@ -15,6 +15,7 @@ variables:
buildPlatform: 'x86|x64|ARM'
buildConfiguration: 'Release'
appxPackageDir: '$(build.artifactStagingDirectory)\AppxPackages\\'
+ buildFolder: '$(Build.SourcesDirectory)\bin\'
jobs:
- job: Build
@@ -23,7 +24,7 @@ jobs:
# Run the init.ps1, which mostly restores dependencies
- task: PowerShell@2
- displayName: 'Restore nuget packages'
+ displayName: 'Restore nuget packages & Monaco editor'
inputs:
filePath: 'init.ps1'
failOnStderr: true
@@ -34,7 +35,8 @@ jobs:
inputs:
solution: '$(uwpProject)'
configuration: '$(buildConfiguration)'
- msbuildArguments: '/t:build
+ msbuildArguments: '/bl:"$(buildFolder)\msbuild.binlog"
+ /t:build
/p:AppxBundlePlatforms="$(buildPlatform)"
/p:AppxPackageDir="$(appxPackageDir)"
/p:AppxPackageSigningEnabled=false
@@ -46,3 +48,10 @@ jobs:
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(appxPackageDir)'
+ condition: succeeded()
+
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifact: output'
+ inputs:
+ PathtoPublish: '$(buildFolder)'
+ condition: failed()
diff --git a/init.ps1 b/init.ps1
index 24fd6b3bc..b42f442e0 100644
--- a/init.ps1
+++ b/init.ps1
@@ -1,4 +1,9 @@
-Function Get-MsBuildPath {
+param (
+ [Parameter(Mandatory = $false)]
+ [Boolean]$VsPreview=$true
+)
+
+Function Get-MsBuildPath($useVsPreview) {
if (-not (Test-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"))
{
Throw "Unable to find 'vswhere.exe'. Is Visual Studio installed?"
@@ -6,10 +11,16 @@ Function Get-MsBuildPath {
$path = ""
try {
- $path = & "${env:ProgramFiles}\microsoft visual studio\installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
+ if ($useVsPreview)
+ {
+ $path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -latest -prerelease -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
+ }
+ else
+ {
+ $path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
+ }
}
catch {
- $path = & "${env:ProgramFiles(x86)}\microsoft visual studio\installer\vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
}
if (!$path)
@@ -40,7 +51,7 @@ try {
$HeaderColor = 'Green'
$toolsPath = "$PSScriptRoot\tools"
$nugetVerbosity = 'minimal'
- $MSBuildPath = Get-MsBuildPath
+ $MSBuildPath = Get-MsBuildPath $VsPreview
if ($VerbosePreference -eq 'continue') { $nugetVerbosity = 'Detailed' }
Restore-PackagesUnder "$PSScriptRoot\src"
diff --git a/src/.editorconfig b/src/.editorconfig
new file mode 100644
index 000000000..75b4d6754
--- /dev/null
+++ b/src/.editorconfig
@@ -0,0 +1,141 @@
+# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
+###############################
+# Core EditorConfig Options #
+###############################
+# All files
+[*]
+indent_style = space
+
+# XML project files
+[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
+indent_size = 2
+
+# XML config files
+[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
+indent_size = 2
+
+# Code files
+[*.{cs,csx,vb,vbx}]
+indent_size = 4
+insert_final_newline = true
+charset = utf-8-bom
+###############################
+# .NET Coding Conventions #
+###############################
+[*.{cs,vb}]
+# Organize usings
+dotnet_sort_system_directives_first = true
+# this. preferences
+dotnet_style_qualification_for_field =false:warning
+dotnet_style_qualification_for_property =false:warning
+dotnet_style_qualification_for_method =false:warning
+dotnet_style_qualification_for_event =false:warning
+# Language keywords vs BCL types preferences
+dotnet_style_predefined_type_for_locals_parameters_members = true:silent
+dotnet_style_predefined_type_for_member_access = true:silent
+# Parentheses preferences
+dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
+dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
+# Modifier preferences
+dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
+dotnet_style_readonly_field =true:warning
+# Expression-level preferences
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_explicit_tuple_names =true:warning
+dotnet_style_null_propagation =true:warning
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_prefer_is_null_check_over_reference_equality_method =true:warning
+dotnet_style_prefer_inferred_tuple_names = true:suggestion
+dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
+dotnet_style_prefer_auto_properties = true:silent
+dotnet_style_prefer_conditional_expression_over_assignment = true:silent
+dotnet_style_prefer_conditional_expression_over_return = true:silent
+###############################
+# Naming Conventions #
+###############################
+# Style Definitions
+dotnet_naming_style.pascal_case_style.capitalization = pascal_case
+# Use PascalCase for constant fields
+dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
+dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
+dotnet_naming_symbols.constant_fields.applicable_kinds = field
+dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
+dotnet_naming_symbols.constant_fields.required_modifiers = const
+dotnet_style_namespace_match_folder=true:warning
+dotnet_style_allow_multiple_blank_lines_experimental=true:warning
+dotnet_code_quality_unused_parameters=all:warning
+###############################
+# C# Coding Conventions #
+###############################
+[*.cs]
+# var preferences
+csharp_style_var_for_built_in_types =false:warning
+csharp_style_var_when_type_is_apparent =true:warning
+csharp_style_var_elsewhere =false:warning
+# Expression-bodied members
+csharp_style_expression_bodied_methods = false:silent
+csharp_style_expression_bodied_constructors = false:silent
+csharp_style_expression_bodied_operators = false:silent
+csharp_style_expression_bodied_properties = true:silent
+csharp_style_expression_bodied_indexers = true:silent
+csharp_style_expression_bodied_accessors = true:silent
+# Pattern matching preferences
+csharp_style_pattern_matching_over_is_with_cast_check =true:error
+csharp_style_pattern_matching_over_as_with_null_check =true:error
+# Null-checking preferences
+csharp_style_throw_expression = true:suggestion
+csharp_style_conditional_delegate_call = true:suggestion
+# Modifier preferences
+csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
+# Expression-level preferences
+csharp_prefer_braces =true:error
+csharp_style_deconstructed_variable_declaration = true:suggestion
+csharp_prefer_simple_default_expression = true:suggestion
+csharp_style_pattern_local_over_anonymous_function = true:suggestion
+csharp_style_inlined_variable_declaration =true:warning
+###############################
+# C# Formatting Rules #
+###############################
+# New line preferences
+csharp_new_line_before_open_brace = all
+csharp_new_line_before_else = true
+csharp_new_line_before_catch = true
+csharp_new_line_before_finally = true
+csharp_new_line_before_members_in_object_initializers = true
+csharp_new_line_before_members_in_anonymous_types = true
+csharp_new_line_between_query_expression_clauses = true
+# Indentation preferences
+csharp_indent_case_contents = true
+csharp_indent_switch_labels = true
+csharp_indent_labels = flush_left
+# Space preferences
+csharp_space_after_cast = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+csharp_space_between_parentheses = false
+csharp_space_before_colon_in_inheritance_clause = true
+csharp_space_after_colon_in_inheritance_clause = true
+csharp_space_around_binary_operators = before_and_after
+csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
+csharp_space_between_method_call_name_and_opening_parenthesis = false
+csharp_space_between_method_call_empty_parameter_list_parentheses = false
+# Wrapping preferences
+csharp_preserve_single_line_statements = true
+csharp_preserve_single_line_blocks = true
+csharp_indent_braces=false
+csharp_using_directive_placement=outside_namespace:warning
+csharp_prefer_static_local_function=true:warning
+csharp_style_prefer_switch_expression=true:warning
+csharp_style_prefer_pattern_matching=true:warning
+csharp_style_prefer_not_pattern=true:warning
+###############################
+# VB Coding Conventions #
+###############################
+[*.vb]
+# Modifier preferences
+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:suggestion
diff --git a/src/DevToys.sln b/src/DevToys.sln
index 2f46acf51..f7f1b9b07 100644
--- a/src/DevToys.sln
+++ b/src/DevToys.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.31624.102
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dev", "dev", "{2C2B8C64-7BA1-4244-86E1-48CA7D85D7D9}"
EndProject
@@ -19,6 +19,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DevToys", "dev\impl\DevToys
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B4C026E3-9BBF-434B-A14D-712C6A3731E4}"
ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
..\.vsconfig = ..\.vsconfig
..\CONTRIBUTING.md = ..\CONTRIBUTING.md
Directory.Build.props = Directory.Build.props
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index b7146bf61..4c2321625 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -30,7 +30,7 @@
<Nuget_MicrosoftToolkitUwpUIControls>7.0.2</Nuget_MicrosoftToolkitUwpUIControls>
<Nuget_MicrosoftTypeScriptMSBuild>4.4.2</Nuget_MicrosoftTypeScriptMSBuild>
<NuGet_MicrosoftUIXaml>2.6.2</NuGet_MicrosoftUIXaml>
- <NuGet_MicrosoftWindowsSDKBuildTools>10.0.20348.19</NuGet_MicrosoftWindowsSDKBuildTools>
+ <NuGet_MicrosoftWindowsSDKBuildTools>10.0.22000.194</NuGet_MicrosoftWindowsSDKBuildTools>
<NuGet_MSTestTestAdapter>2.1.1</NuGet_MSTestTestAdapter>
<NuGet_MSTestTestFramework>2.1.1</NuGet_MSTestTestFramework>
<NuGet_NewtonsoftJson>12.0.3</NuGet_NewtonsoftJson>
diff --git a/src/dev/DevToys.Startup/DevToys.Startup.wapproj b/src/dev/DevToys.Startup/DevToys.Startup.wapproj
index 845687794..dd9de0f3e 100644
--- a/src/dev/DevToys.Startup/DevToys.Startup.wapproj
+++ b/src/dev/DevToys.Startup/DevToys.Startup.wapproj
@@ -48,6 +48,8 @@
<UapAppxPackageBuildMode>StoreAndSideload</UapAppxPackageBuildMode>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<!-- Workaround to https://github.com/microsoft/microsoft-ui-xaml/issues/6195 -->
<AppxUseHardlinksIfPossible>false</AppxUseHardlinksIfPossible>
</PropertyGroup>
@@ -113,4 +115,7 @@
</AppxManifest>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
+ <ItemGroup>
+ <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="$(NuGet_MicrosoftWindowsSDKBuildTools)" PrivateAssets="all" />
+ </ItemGroup>
</Project>
\ No newline at end of file
diff --git a/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.cs b/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.cs
index 856c850dd..0bfac3d7b 100644
--- a/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/CodeEditorCore.cs
@@ -1,12 +1,5 @@
#nullable enable
-using Collections.Generic;
-using DevToys.MonacoEditor.Extensions;
-using DevToys.MonacoEditor.Helpers;
-using DevToys.MonacoEditor.Monaco;
-using DevToys.MonacoEditor.Monaco.Editor;
-using DevToys.MonacoEditor.Monaco.Helpers;
-using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -17,6 +10,13 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading;
using System.Threading.Tasks;
+using Collections.Generic;
+using DevToys.MonacoEditor.Extensions;
+using DevToys.MonacoEditor.Helpers;
+using DevToys.MonacoEditor.Monaco;
+using DevToys.MonacoEditor.Monaco.Editor;
+using DevToys.MonacoEditor.Monaco.Helpers;
+using Newtonsoft.Json;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Core;
@@ -51,8 +51,8 @@ namespace DevToys.MonacoEditor.CodeEditorControl
internal const string FocusedState = "Focused";
internal const string DisabledState = "Disabled";
- private readonly DisposableSempahore _mutexMarkers = new DisposableSempahore();
- private readonly DisposableSempahore _mutexLineDecorations = new DisposableSempahore();
+ private readonly DisposableSempahore _mutexMarkers = new();
+ private readonly DisposableSempahore _mutexLineDecorations = new();
private bool _initialized;
private WebView? _view;
@@ -135,7 +135,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
string.Empty,
(d, e) =>
{
- if (!(d is CodeEditorCore editor))
+ if (d is not CodeEditorCore editor)
{
return;
}
@@ -166,7 +166,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
false,
(d, e) =>
{
- if (!(d is CodeEditorCore editor))
+ if (d is not CodeEditorCore editor)
{
return;
}
@@ -520,7 +520,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
private async void Options_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
- if (!(sender is StandaloneEditorConstructionOptions options) || IsDiffViewMode)
+ if (sender is not StandaloneEditorConstructionOptions options || IsDiffViewMode)
{
return;
}
@@ -555,7 +555,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
private async void DiffOptions_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
- if (!(sender is DiffEditorConstructionOptions options) || !IsDiffViewMode)
+ if (sender is not DiffEditorConstructionOptions options || !IsDiffViewMode)
{
return;
}
@@ -872,8 +872,8 @@ namespace DevToys.MonacoEditor.CodeEditorControl
private async void RequestedTheme_PropertyChanged(DependencyObject obj, DependencyProperty property)
{
var editor = (CodeEditorCore)obj;
- var theme = editor.RequestedTheme;
- var tstr = string.Empty;
+ ElementTheme theme = editor.RequestedTheme;
+ string? tstr = string.Empty;
if (theme == ElementTheme.Default)
{
@@ -1032,7 +1032,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
public IAsyncOperation<string?> AddCommandAsync(int keybinding, CommandHandler handler, string context)
{
- var name = "Command" + keybinding;
+ string? name = "Command" + keybinding;
ParentAccessor?.RegisterAction(name, new Action(() => { handler?.Invoke(); }));
return InvokeScriptAsync<string?>("addCommand", new object[] { keybinding, name, context }).AsAsyncOperation();
}
@@ -1081,7 +1081,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
/// <returns></returns>
private IAsyncAction DeltaDecorationsHelperAsync([ReadOnlyArray] ModelDeltaDecoration[]? newDecorations)
{
- var newDecorationsAdjust = newDecorations ?? Array.Empty<ModelDeltaDecoration>();
+ ModelDeltaDecoration[]? newDecorationsAdjust = newDecorations ?? Array.Empty<ModelDeltaDecoration>();
// Update Styles
return InvokeScriptAsync("updateStyle", CssStyleBroker.GetInstance(this).GetStyles()).ContinueWith((noop) =>
diff --git a/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/InvertedBooleanConverter.cs b/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/InvertedBooleanConverter.cs
index dc8524740..8e8f5f9a8 100644
--- a/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/InvertedBooleanConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/CodeEditorControl/InvertedBooleanConverter.cs
@@ -13,7 +13,7 @@ namespace DevToys.MonacoEditor.CodeEditorControl
{
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys.MonacoEditor/Extensions/DispatcherExtensions.cs b/src/dev/impl/DevToys.MonacoEditor/Extensions/DispatcherExtensions.cs
index f4e7b02da..78156cd5a 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Extensions/DispatcherExtensions.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Extensions/DispatcherExtensions.cs
@@ -115,17 +115,13 @@ namespace DevToys.MonacoEditor.Extensions
private static CoreDispatcherPriority GetDispatcherPriority(ThreadPriority priority)
{
- switch (priority)
+ return priority switch
{
- case ThreadPriority.Low:
- return CoreDispatcherPriority.Low;
- case ThreadPriority.Normal:
- return CoreDispatcherPriority.Normal;
- case ThreadPriority.High:
- return CoreDispatcherPriority.High;
- default:
- throw new NotSupportedException();
- }
+ ThreadPriority.Low => CoreDispatcherPriority.Low,
+ ThreadPriority.Normal => CoreDispatcherPriority.Normal,
+ ThreadPriority.High => CoreDispatcherPriority.High,
+ _ => throw new NotSupportedException(),
+ };
}
}
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Extensions/WebViewExtensions.cs b/src/dev/impl/DevToys.MonacoEditor/Extensions/WebViewExtensions.cs
index d6810106f..81ed09796 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Extensions/WebViewExtensions.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Extensions/WebViewExtensions.cs
@@ -1,12 +1,12 @@
#nullable enable
-using DevToys.MonacoEditor.Monaco.Editor;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Serialization;
using System;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
+using DevToys.MonacoEditor.Monaco.Editor;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
using Windows.Data.Json;
using Windows.UI.Xaml.Controls;
@@ -15,7 +15,7 @@ namespace DevToys.MonacoEditor.Extensions
internal static class WebViewExtensions
{
- private static readonly JsonSerializerSettings _settings = new JsonSerializerSettings()
+ private static readonly JsonSerializerSettings _settings = new()
{
NullValueHandling = NullValueHandling.Ignore,
ContractResolver = new CamelCasePropertyNamesContractResolver()
@@ -73,7 +73,7 @@ namespace DevToys.MonacoEditor.Extensions
[CallerFilePath] string? file = null,
[CallerLineNumber] int line = 0)
{
- var start = "try {\n";
+ string? start = "try {\n";
if (typeof(T) != typeof(object))
{
script = script.Trim(';');
@@ -83,7 +83,7 @@ namespace DevToys.MonacoEditor.Extensions
{
start += script;
}
- var fullscript = start +
+ string? fullscript = start +
"\n} catch (err) { JSON.stringify({ wv_internal_error: true, message: err.message, description: err.description, number: err.number, stack: err.stack }); }";
if (_view.Dispatcher.HasThreadAccess)
@@ -115,7 +115,7 @@ namespace DevToys.MonacoEditor.Extensions
private static async Task<T?> RunScriptHelperAsync<T>(WebView _view, string script)
{
- var returnstring = await _view.InvokeScriptAsync("eval", new string[] { script });
+ string? returnstring = await _view.InvokeScriptAsync("eval", new string[] { script });
if (JsonObject.TryParse(returnstring, out JsonObject result))
{
@@ -125,7 +125,7 @@ namespace DevToys.MonacoEditor.Extensions
}
}
- if (returnstring != null && returnstring != "null")
+ if (returnstring is not null and not "null")
{
return JsonConvert.DeserializeObject<T>(returnstring);
}
@@ -184,7 +184,7 @@ namespace DevToys.MonacoEditor.Extensions
{
sanitizedargs = args.Select(item =>
{
- if (item is int || item is double)
+ if (item is int or double)
{
return item.ToString();
}
@@ -204,7 +204,7 @@ namespace DevToys.MonacoEditor.Extensions
sanitizedargs = args.Select(item => item.ToString()).ToArray();
}
- var script = method + "(" + string.Join(",", sanitizedargs) + ");";
+ string? script = method + "(" + string.Join(",", sanitizedargs) + ");";
return await RunScriptAsync<T>(_view, script, member, file, line);
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Helpers/KeyboardListener.cs b/src/dev/impl/DevToys.MonacoEditor/Helpers/KeyboardListener.cs
index cc07d5b9a..10e79388e 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Helpers/KeyboardListener.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Helpers/KeyboardListener.cs
@@ -1,7 +1,7 @@
#nullable enable
-using DevToys.MonacoEditor.CodeEditorControl;
using System;
+using DevToys.MonacoEditor.CodeEditorControl;
using Windows.Foundation.Metadata;
namespace DevToys.MonacoEditor.Helpers
diff --git a/src/dev/impl/DevToys.MonacoEditor/Helpers/ParentAccessor.cs b/src/dev/impl/DevToys.MonacoEditor/Helpers/ParentAccessor.cs
index 07d310759..37026557e 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Helpers/ParentAccessor.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Helpers/ParentAccessor.cs
@@ -1,11 +1,11 @@
#nullable enable
-using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
+using Newtonsoft.Json;
using Windows.Foundation;
using Windows.Foundation.Metadata;
@@ -117,7 +117,7 @@ namespace DevToys.MonacoEditor.Helpers
{
if (parent.TryGetTarget(out IParentAccessorAcceptor tobj))
{
- var propinfo = typeinfo.GetProperty(name);
+ PropertyInfo? propinfo = typeinfo.GetProperty(name);
return propinfo?.GetValue(tobj);
}
@@ -128,8 +128,8 @@ namespace DevToys.MonacoEditor.Helpers
{
if (parent.TryGetTarget(out IParentAccessorAcceptor tobj))
{
- var propinfo = typeinfo.GetProperty(name);
- var obj = propinfo?.GetValue(tobj);
+ PropertyInfo? propinfo = typeinfo.GetProperty(name);
+ object? obj = propinfo?.GetValue(tobj);
return JsonConvert.SerializeObject(obj, new JsonSerializerSettings()
{
@@ -153,11 +153,11 @@ namespace DevToys.MonacoEditor.Helpers
if (parent.TryGetTarget(out IParentAccessorAcceptor tobj))
{
// TODO: Support params for multi-level digging?
- var propinfo = typeinfo.GetProperty(name);
- var prop = propinfo?.GetValue(tobj);
+ PropertyInfo? propinfo = typeinfo.GetProperty(name);
+ object? prop = propinfo?.GetValue(tobj);
if (prop != null)
{
- var childinfo = prop.GetType().GetProperty(child);
+ PropertyInfo? childinfo = prop.GetType().GetProperty(child);
return childinfo?.GetValue(prop);
}
}
@@ -174,7 +174,7 @@ namespace DevToys.MonacoEditor.Helpers
{
if (parent.TryGetTarget(out IParentAccessorAcceptor tobj))
{
- var propinfo = typeinfo.GetProperty(name); // TODO: Cache these?
+ PropertyInfo? propinfo = typeinfo.GetProperty(name); // TODO: Cache these?
tobj.IsSettingValue = true;
propinfo?.SetValue(tobj, value);
tobj.IsSettingValue = false;
@@ -191,15 +191,15 @@ namespace DevToys.MonacoEditor.Helpers
{
if (parent.TryGetTarget(out IParentAccessorAcceptor tobj))
{
- var propinfo = typeinfo.GetProperty(name);
- var typeobj = LookForTypeByName(type);
+ PropertyInfo? propinfo = typeinfo.GetProperty(name);
+ Type? typeobj = LookForTypeByName(type);
if (typeobj is null)
{
throw new Exception("Type not found");
}
- var obj = JsonConvert.DeserializeObject(value, typeobj);
+ object? obj = JsonConvert.DeserializeObject(value, typeobj);
tobj.IsSettingValue = true;
propinfo?.SetValue(tobj, obj);
@@ -218,9 +218,9 @@ namespace DevToys.MonacoEditor.Helpers
}
// Search in Other Assemblies
- foreach (var assembly in Assemblies)
+ foreach (Assembly? assembly in Assemblies)
{
- foreach (var typeInfo in assembly.ExportedTypes)
+ foreach (Type? typeInfo in assembly.ExportedTypes)
{
if (typeInfo.Name == name)
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Helpers/ThemeListener.cs b/src/dev/impl/DevToys.MonacoEditor/Helpers/ThemeListener.cs
index f277f5f85..27c908557 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Helpers/ThemeListener.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Helpers/ThemeListener.cs
@@ -19,8 +19,8 @@ namespace DevToys.MonacoEditor.Helpers
[AllowForWeb]
public sealed class ThemeListener
{
- private readonly AccessibilitySettings _accessible = new AccessibilitySettings();
- private readonly UISettings _uiSettings = new UISettings();
+ private readonly AccessibilitySettings _accessible = new();
+ private readonly UISettings _uiSettings = new();
public string CurrentThemeName { get { return CurrentTheme.ToString(); } } // For Web Retrieval
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AcceptSuggestionOnEnterConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AcceptSuggestionOnEnterConverter.cs
index dc44f1f68..1370a16e3 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AcceptSuggestionOnEnterConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AcceptSuggestionOnEnterConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,18 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "off":
- return AcceptSuggestionOnEnter.Off;
- case "on":
- return AcceptSuggestionOnEnter.On;
- case "smart":
- return AcceptSuggestionOnEnter.Smart;
- }
-
- throw new Exception("Cannot unmarshal type AcceptSuggestionOnEnter");
+ "off" => AcceptSuggestionOnEnter.Off,
+ "on" => AcceptSuggestionOnEnter.On,
+ "smart" => AcceptSuggestionOnEnter.Smart,
+ _ => throw new Exception("Cannot unmarshal type AcceptSuggestionOnEnter"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AccessibilitySupportConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AccessibilitySupportConverter.cs
index c71b2a9f0..cd99d0a4c 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AccessibilitySupportConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AccessibilitySupportConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,18 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "auto":
- return AccessibilitySupport.Auto;
- case "off":
- return AccessibilitySupport.Off;
- case "on":
- return AccessibilitySupport.On;
- }
-
- throw new Exception("Cannot unmarshal type AccessibilitySupport");
+ "auto" => AccessibilitySupport.Auto,
+ "off" => AccessibilitySupport.Off,
+ "on" => AccessibilitySupport.On,
+ _ => throw new Exception("Cannot unmarshal type AccessibilitySupport"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingBracketsConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingBracketsConverter.cs
index 912685724..dd38a373e 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingBracketsConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingBracketsConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,20 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return AutoClosingBrackets.Always;
- case "beforeWhitespace":
- return AutoClosingBrackets.BeforeWhitespace;
- case "languageDefined":
- return AutoClosingBrackets.LanguageDefined;
- case "never":
- return AutoClosingBrackets.Never;
- }
-
- throw new Exception("Cannot unmarshal type AutoClosingBrackets");
+ "always" => AutoClosingBrackets.Always,
+ "beforeWhitespace" => AutoClosingBrackets.BeforeWhitespace,
+ "languageDefined" => AutoClosingBrackets.LanguageDefined,
+ "never" => AutoClosingBrackets.Never,
+ _ => throw new Exception("Cannot unmarshal type AutoClosingBrackets"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingOvertypeConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingOvertypeConverter.cs
index 0a5894e98..7b4b15b2d 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingOvertypeConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingOvertypeConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,17 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return AutoClosingOvertype.Always;
- case "auto":
- return AutoClosingOvertype.Auto;
- case "never":
- return AutoClosingOvertype.Never;
- }
- throw new Exception("Cannot unmarshal type AutoClosingOvertype");
+ "always" => AutoClosingOvertype.Always,
+ "auto" => AutoClosingOvertype.Auto,
+ "never" => AutoClosingOvertype.Never,
+ _ => throw new Exception("Cannot unmarshal type AutoClosingOvertype"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingQuotesConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingQuotesConverter.cs
index ac6fa7445..55e05974b 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingQuotesConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoClosingQuotesConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,20 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return AutoClosingQuotes.Always;
- case "beforeWhitespace":
- return AutoClosingQuotes.BeforeWhitespace;
- case "languageDefined":
- return AutoClosingQuotes.LanguageDefined;
- case "never":
- return AutoClosingQuotes.Never;
- }
-
- throw new Exception("Cannot unmarshal type AutoClosingQuotes");
+ "always" => AutoClosingQuotes.Always,
+ "beforeWhitespace" => AutoClosingQuotes.BeforeWhitespace,
+ "languageDefined" => AutoClosingQuotes.LanguageDefined,
+ "never" => AutoClosingQuotes.Never,
+ _ => throw new Exception("Cannot unmarshal type AutoClosingQuotes"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
@@ -63,6 +58,6 @@ namespace DevToys.MonacoEditor.Monaco.Editor
throw new Exception("Cannot marshal type AutoClosingQuotes");
}
- public static readonly AutoClosingQuotesConverter Singleton = new AutoClosingQuotesConverter();
+ public static readonly AutoClosingQuotesConverter Singleton = new();
}
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoFindInSelectionConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoFindInSelectionConverter.cs
index 5fc5010a5..2ea1de659 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoFindInSelectionConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoFindInSelectionConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,18 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return AutoFindInSelection.Always;
- case "multiline":
- return AutoFindInSelection.Multiline;
- case "never":
- return AutoFindInSelection.Never;
- }
-
- throw new Exception("Cannot unmarshal type AutoFindInSelection");
+ "always" => AutoFindInSelection.Always,
+ "multiline" => AutoFindInSelection.Multiline,
+ "never" => AutoFindInSelection.Never,
+ _ => throw new Exception("Cannot unmarshal type AutoFindInSelection"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoIndentConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoIndentConverter.cs
index 76020a0ac..c37a2f4cb 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoIndentConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoIndentConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -16,22 +16,16 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "advanced":
- return AutoIndent.Advanced;
- case "brackets":
- return AutoIndent.Brackets;
- case "full":
- return AutoIndent.Full;
- case "keep":
- return AutoIndent.Keep;
- case "none":
- return AutoIndent.None;
- }
-
- throw new Exception("Cannot unmarshal type AutoIndent");
+ "advanced" => AutoIndent.Advanced,
+ "brackets" => AutoIndent.Brackets,
+ "full" => AutoIndent.Full,
+ "keep" => AutoIndent.Keep,
+ "none" => AutoIndent.None,
+ _ => throw new Exception("Cannot unmarshal type AutoIndent"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoSurroundConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoSurroundConverter.cs
index 1001d8e50..f847ab2b2 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoSurroundConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/AutoSurroundConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,20 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "brackets":
- return AutoSurround.Brackets;
- case "languageDefined":
- return AutoSurround.LanguageDefined;
- case "never":
- return AutoSurround.Never;
- case "quotes":
- return AutoSurround.Quotes;
- }
-
- throw new Exception("Cannot unmarshal type AutoSurround");
+ "brackets" => AutoSurround.Brackets,
+ "languageDefined" => AutoSurround.LanguageDefined,
+ "never" => AutoSurround.Never,
+ "quotes" => AutoSurround.Quotes,
+ _ => throw new Exception("Cannot unmarshal type AutoSurround"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ContextKey.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ContextKey.cs
index 7548ff4db..a3a046dbc 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ContextKey.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ContextKey.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System;
using DevToys.MonacoEditor.CodeEditorControl;
using Newtonsoft.Json;
-using System;
namespace DevToys.MonacoEditor.Monaco.Editor
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorBlinkingConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorBlinkingConverter.cs
index 397e93639..183f698af 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorBlinkingConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorBlinkingConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -16,22 +16,16 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "blink":
- return CursorBlinking.Blink;
- case "expand":
- return CursorBlinking.Expand;
- case "phase":
- return CursorBlinking.Phase;
- case "smooth":
- return CursorBlinking.Smooth;
- case "solid":
- return CursorBlinking.Solid;
- }
-
- throw new Exception("Cannot unmarshal type CursorBlinking");
+ "blink" => CursorBlinking.Blink,
+ "expand" => CursorBlinking.Expand,
+ "phase" => CursorBlinking.Phase,
+ "smooth" => CursorBlinking.Smooth,
+ "solid" => CursorBlinking.Solid,
+ _ => throw new Exception("Cannot unmarshal type CursorBlinking"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorStyleConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorStyleConverter.cs
index 44ba79ae7..a9c4a1b1f 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorStyleConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorStyleConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,24 +19,17 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "block":
- return CursorStyle.Block;
- case "block-outline":
- return CursorStyle.BlockOutline;
- case "line":
- return CursorStyle.Line;
- case "line-thin":
- return CursorStyle.LineThin;
- case "underline":
- return CursorStyle.Underline;
- case "underline-thin":
- return CursorStyle.UnderlineThin;
- }
-
- throw new Exception("Cannot unmarshal type CursorStyle");
+ "block" => CursorStyle.Block,
+ "block-outline" => CursorStyle.BlockOutline,
+ "line" => CursorStyle.Line,
+ "line-thin" => CursorStyle.LineThin,
+ "underline" => CursorStyle.Underline,
+ "underline-thin" => CursorStyle.UnderlineThin,
+ _ => throw new Exception("Cannot unmarshal type CursorStyle"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorSurroundingLinesStyleConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorSurroundingLinesStyleConverter.cs
index b7fa84f8a..031f74ff4 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorSurroundingLinesStyleConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/CursorSurroundingLinesStyleConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,16 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "all":
- return CursorSurroundingLinesStyle.All;
- case "default":
- return CursorSurroundingLinesStyle.Default;
- }
-
- throw new Exception("Cannot unmarshal type CursorSurroundingLinesStyle");
+ "all" => CursorSurroundingLinesStyle.All,
+ "default" => CursorSurroundingLinesStyle.Default,
+ _ => throw new Exception("Cannot unmarshal type CursorSurroundingLinesStyle"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/DiffEditorConstructionOptions.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/DiffEditorConstructionOptions.cs
index 702611f1e..151ed319b 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/DiffEditorConstructionOptions.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/DiffEditorConstructionOptions.cs
@@ -1,10 +1,10 @@
#nullable enable
-using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -12,7 +12,7 @@ namespace DevToys.MonacoEditor.Monaco.Editor
{
public event PropertyChangedEventHandler? PropertyChanged;
- private readonly Dictionary<string, object?> _propertyBackingDictionary = new Dictionary<string, object?>();
+ private readonly Dictionary<string, object?> _propertyBackingDictionary = new();
private T? GetPropertyValue<T>([CallerMemberName] string? propertyName = null)
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/FoldingStrategyConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/FoldingStrategyConverter.cs
index 26bd7808e..40b900d95 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/FoldingStrategyConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/FoldingStrategyConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,16 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "auto":
- return FoldingStrategy.Auto;
- case "indentation":
- return FoldingStrategy.Indentation;
- }
-
- throw new Exception("Cannot unmarshal type FoldingStrategy");
+ "auto" => FoldingStrategy.Auto,
+ "indentation" => FoldingStrategy.Indentation,
+ _ => throw new Exception("Cannot unmarshal type FoldingStrategy"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IActionDescriptor.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IActionDescriptor.cs
index 00b6f99a5..d682fea0d 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IActionDescriptor.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IActionDescriptor.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Runtime.InteropServices.WindowsRuntime;
using DevToys.MonacoEditor.CodeEditorControl;
using Newtonsoft.Json;
-using System.Runtime.InteropServices.WindowsRuntime;
namespace DevToys.MonacoEditor.Monaco.Editor
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IModel.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IModel.cs
index a825a486c..9b49656fc 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IModel.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/IModel.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System.Collections.Generic;
+using Newtonsoft.Json;
using Windows.Foundation;
namespace DevToys.MonacoEditor.Monaco.Editor
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InsertModeConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InsertModeConverter.cs
index 245f70cab..0a170dbf6 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InsertModeConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InsertModeConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,15 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "insert":
- return InsertMode.Insert;
- case "replace":
- return InsertMode.Replace;
- }
- throw new Exception("Cannot unmarshal type InsertMode");
+ "insert" => InsertMode.Insert,
+ "replace" => InsertMode.Replace,
+ _ => throw new Exception("Cannot unmarshal type InsertMode"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InterfaceToClassConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InterfaceToClassConverter.cs
index 6f1180c4e..e1c55ba3c 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InterfaceToClassConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/InterfaceToClassConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/LineNumbersTypeConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/LineNumbersTypeConverter.cs
index 62f5aa97c..9d9822e7b 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/LineNumbersTypeConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/LineNumbersTypeConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -16,19 +16,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "interval":
- return LineNumbersType.Interval;
- case "off":
- return LineNumbersType.Off;
- case "on":
- return LineNumbersType.On;
- case "relative":
- return LineNumbersType.Relative;
- }
- throw new Exception("Cannot unmarshal type LineNumbersType");
+ "interval" => LineNumbersType.Interval,
+ "off" => LineNumbersType.Off,
+ "on" => LineNumbersType.On,
+ "relative" => LineNumbersType.Relative,
+ _ => throw new Exception("Cannot unmarshal type LineNumbersType"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MatchBracketsConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MatchBracketsConverter.cs
index c95463cf3..f48efc288 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MatchBracketsConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MatchBracketsConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -16,17 +16,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return MatchBrackets.Always;
- case "near":
- return MatchBrackets.Near;
- case "never":
- return MatchBrackets.Never;
- }
- throw new Exception("Cannot unmarshal type MatchBrackets");
+ "always" => MatchBrackets.Always,
+ "near" => MatchBrackets.Near,
+ "never" => MatchBrackets.Never,
+ _ => throw new Exception("Cannot unmarshal type MatchBrackets"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MouseStyleConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MouseStyleConverter.cs
index c51baec1b..c6481a288 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MouseStyleConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MouseStyleConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,18 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "copy":
- return MouseStyle.Copy;
- case "default":
- return MouseStyle.Default;
- case "text":
- return MouseStyle.Text;
- }
-
- throw new Exception("Cannot unmarshal type MouseStyle");
+ "copy" => MouseStyle.Copy,
+ "default" => MouseStyle.Default,
+ "text" => MouseStyle.Text,
+ _ => throw new Exception("Cannot unmarshal type MouseStyle"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifier.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifier.cs
index 5cf99da57..e980d7afe 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifier.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifier.cs
@@ -9,9 +9,9 @@ namespace DevToys.MonacoEditor.Monaco.Editor
/// Defaults to 'alt'
/// </summary>
[JsonConverter(typeof(MultiCursorModifierConverter))]
- public enum MultiCursorModifier
+ public enum MultiCursorModifier
{
Alt,
- CtrlCmd
+ CtrlCmd
}
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifierConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifierConverter.cs
index c208ebbf6..c81730022 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifierConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorModifierConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,16 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "alt":
- return MultiCursorModifier.Alt;
- case "ctrlCmd":
- return MultiCursorModifier.CtrlCmd;
- }
-
- throw new Exception("Cannot unmarshal type MultiCursorModifier");
+ "alt" => MultiCursorModifier.Alt,
+ "ctrlCmd" => MultiCursorModifier.CtrlCmd,
+ _ => throw new Exception("Cannot unmarshal type MultiCursorModifier"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPaste.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPaste.cs
index e7e0b5ad5..3bad8c636 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPaste.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPaste.cs
@@ -11,7 +11,7 @@ namespace DevToys.MonacoEditor.Monaco.Editor
/// </summary>
[JsonConverter(typeof(MultiCursorPasteConverter))]
public enum MultiCursorPaste
- {
+ {
Full,
Spread
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPasteConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPasteConverter.cs
index ab0043664..b4cabbd05 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPasteConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultiCursorPasteConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,16 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "full":
- return MultiCursorPaste.Full;
- case "spread":
- return MultiCursorPaste.Spread;
- }
-
- throw new Exception("Cannot unmarshal type MultiCursorPaste");
+ "full" => MultiCursorPaste.Full,
+ "spread" => MultiCursorPaste.Spread,
+ _ => throw new Exception("Cannot unmarshal type MultiCursorPaste"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/Multiple.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/Multiple.cs
index 8096a7bcc..89bd89dba 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/Multiple.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/Multiple.cs
@@ -5,8 +5,8 @@ using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
[JsonConverter(typeof(MultipleConverter))]
- public enum Multiple
- {
+ public enum Multiple
+ {
Goto,
GotoAndPeek,
Peek
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultipleConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultipleConverter.cs
index 1f7ef2832..b4a05c34d 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultipleConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/MultipleConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,17 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "goto":
- return Multiple.Goto;
- case "gotoAndPeek":
- return Multiple.GotoAndPeek;
- case "peek":
- return Multiple.Peek;
- }
- throw new Exception("Cannot unmarshal type Multiple");
+ "goto" => Multiple.Goto,
+ "gotoAndPeek" => Multiple.GotoAndPeek,
+ "peek" => Multiple.Peek,
+ _ => throw new Exception("Cannot unmarshal type Multiple"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderLineHighlightConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderLineHighlightConverter.cs
index d51851b85..557325238 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderLineHighlightConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderLineHighlightConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,19 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "all":
- return RenderLineHighlight.All;
- case "gutter":
- return RenderLineHighlight.Gutter;
- case "line":
- return RenderLineHighlight.Line;
- case "none":
- return RenderLineHighlight.None;
- }
- throw new Exception("Cannot unmarshal type RenderLineHighlight");
+ "all" => RenderLineHighlight.All,
+ "gutter" => RenderLineHighlight.Gutter,
+ "line" => RenderLineHighlight.Line,
+ "none" => RenderLineHighlight.None,
+ _ => throw new Exception("Cannot unmarshal type RenderLineHighlight"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespace.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespace.cs
index 17f30283a..eb1ea9dce 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespace.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespace.cs
@@ -11,10 +11,10 @@ namespace DevToys.MonacoEditor.Monaco.Editor
/// </summary>
[JsonConverter(typeof(RenderWhitespaceConverter))]
public enum RenderWhitespace
- {
+ {
All,
Boundary,
None,
- Selection
+ Selection
}
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespaceConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespaceConverter.cs
index 136df56a0..241ff4407 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespaceConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/RenderWhitespaceConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,19 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "all":
- return RenderWhitespace.All;
- case "boundary":
- return RenderWhitespace.Boundary;
- case "none":
- return RenderWhitespace.None;
- case "selection":
- return RenderWhitespace.Selection;
- }
- throw new Exception("Cannot unmarshal type RenderWhitespace");
+ "all" => RenderWhitespace.All,
+ "boundary" => RenderWhitespace.Boundary,
+ "none" => RenderWhitespace.None,
+ "selection" => RenderWhitespace.Selection,
+ _ => throw new Exception("Cannot unmarshal type RenderWhitespace"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ScrollbarBehaviorConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ScrollbarBehaviorConverter.cs
index 5cc186e92..8b06b0999 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ScrollbarBehaviorConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ScrollbarBehaviorConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,17 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "auto":
- return ScrollbarBehavior.Auto;
- case "hidden":
- return ScrollbarBehavior.Hidden;
- case "visible":
- return ScrollbarBehavior.Visible;
- }
- throw new Exception("Cannot unmarshal type ScrollbarBehavior");
+ "auto" => ScrollbarBehavior.Auto,
+ "hidden" => ScrollbarBehavior.Hidden,
+ "visible" => ScrollbarBehavior.Visible,
+ _ => throw new Exception("Cannot unmarshal type ScrollbarBehavior"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ShowConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ShowConverter.cs
index b15091be8..34209975a 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ShowConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/ShowConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,15 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "always":
- return Show.Always;
- case "mouseover":
- return Show.Mouseover;
- }
- throw new Exception("Cannot unmarshal type Show");
+ "always" => Show.Always,
+ "mouseover" => Show.Mouseover,
+ _ => throw new Exception("Cannot unmarshal type Show"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SideConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SideConverter.cs
index fc8144ca1..f6d32d8c4 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SideConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SideConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,15 +19,13 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "left":
- return Side.Left;
- case "right":
- return Side.Right;
- }
- throw new Exception("Cannot unmarshal type Side");
+ "left" => Side.Left,
+ "right" => Side.Right,
+ _ => throw new Exception("Cannot unmarshal type Side"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SnippetSuggestionsConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SnippetSuggestionsConverter.cs
index 2556c0d1a..4a1f81dce 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SnippetSuggestionsConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SnippetSuggestionsConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,19 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "bottom":
- return SnippetSuggestions.Bottom;
- case "inline":
- return SnippetSuggestions.Inline;
- case "none":
- return SnippetSuggestions.None;
- case "top":
- return SnippetSuggestions.Top;
- }
- throw new Exception("Cannot unmarshal type SnippetSuggestions");
+ "bottom" => SnippetSuggestions.Bottom,
+ "inline" => SnippetSuggestions.Inline,
+ "none" => SnippetSuggestions.None,
+ "top" => SnippetSuggestions.Top,
+ _ => throw new Exception("Cannot unmarshal type SnippetSuggestions"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/StandaloneEditorConstructionOptions.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/StandaloneEditorConstructionOptions.cs
index dabf03a87..9f987d8a0 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/StandaloneEditorConstructionOptions.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/StandaloneEditorConstructionOptions.cs
@@ -1,10 +1,10 @@
#nullable enable
-using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -15,7 +15,7 @@ namespace DevToys.MonacoEditor.Monaco.Editor
{
public event PropertyChangedEventHandler? PropertyChanged;
- private readonly Dictionary<string, object?> _propertyBackingDictionary = new Dictionary<string, object?>();
+ private readonly Dictionary<string, object?> _propertyBackingDictionary = new();
private T? GetPropertyValue<T>([CallerMemberName] string? propertyName = null)
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelection.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelection.cs
index 6338cfe04..9acbdcd8d 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelection.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelection.cs
@@ -9,9 +9,9 @@ namespace DevToys.MonacoEditor.Monaco.Editor
/// </summary>
[JsonConverter(typeof(SuggestSelectionConverter))]
public enum SuggestSelection
- {
+ {
First,
- RecentlyUsed,
+ RecentlyUsed,
RecentlyUsedByPrefix
}
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelectionConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelectionConverter.cs
index ed8d58dc7..09c2ce179 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelectionConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/SuggestSelectionConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,17 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "first":
- return SuggestSelection.First;
- case "recentlyUsed":
- return SuggestSelection.RecentlyUsed;
- case "recentlyUsedByPrefix":
- return SuggestSelection.RecentlyUsedByPrefix;
- }
- throw new Exception("Cannot unmarshal type SuggestSelection");
+ "first" => SuggestSelection.First,
+ "recentlyUsed" => SuggestSelection.RecentlyUsed,
+ "recentlyUsedByPrefix" => SuggestSelection.RecentlyUsedByPrefix,
+ _ => throw new Exception("Cannot unmarshal type SuggestSelection"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/TabCompletionConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/TabCompletionConverter.cs
index 3e6d16395..dec9ff9aa 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/TabCompletionConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/TabCompletionConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,17 +19,14 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "off":
- return TabCompletion.Off;
- case "on":
- return TabCompletion.On;
- case "onlySnippets":
- return TabCompletion.OnlySnippets;
- }
- throw new Exception("Cannot unmarshal type TabCompletion");
+ "off" => TabCompletion.Off,
+ "on" => TabCompletion.On,
+ "onlySnippets" => TabCompletion.OnlySnippets,
+ _ => throw new Exception("Cannot unmarshal type TabCompletion"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrap.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrap.cs
index 02da0f2b9..b5baaac57 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrap.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrap.cs
@@ -14,8 +14,8 @@ namespace DevToys.MonacoEditor.Monaco.Editor
/// Defaults to "off".
/// </summary>
[JsonConverter(typeof(WordWrapConverter))]
- public enum WordWrap
- {
+ public enum WordWrap
+ {
Bounded,
Off,
On,
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrapConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrapConverter.cs
index 3b5698630..1ff11e9b4 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrapConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WordWrapConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,19 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "bounded":
- return WordWrap.Bounded;
- case "off":
- return WordWrap.Off;
- case "on":
- return WordWrap.On;
- case "wordWrapColumn":
- return WordWrap.WordWrapColumn;
- }
- throw new Exception("Cannot unmarshal type WordWrap");
+ "bounded" => WordWrap.Bounded,
+ "off" => WordWrap.Off,
+ "on" => WordWrap.On,
+ "wordWrapColumn" => WordWrap.WordWrapColumn,
+ _ => throw new Exception("Cannot unmarshal type WordWrap"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WrappingIndentConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WrappingIndentConverter.cs
index f3ed6ca83..613fe84ff 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WrappingIndentConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Editor/WrappingIndentConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Editor
{
@@ -19,19 +19,15 @@ namespace DevToys.MonacoEditor.Monaco.Editor
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "deepIndent":
- return WrappingIndent.DeepIndent;
- case "indent":
- return WrappingIndent.Indent;
- case "none":
- return WrappingIndent.None;
- case "same":
- return WrappingIndent.Same;
- }
- throw new Exception("Cannot unmarshal type WrappingIndent");
+ "deepIndent" => WrappingIndent.DeepIndent,
+ "indent" => WrappingIndent.Indent,
+ "none" => WrappingIndent.None,
+ "same" => WrappingIndent.Same,
+ _ => throw new Exception("Cannot unmarshal type WrappingIndent"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssInlineStyle.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssInlineStyle.cs
index ccacee83c..f22f0b797 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssInlineStyle.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssInlineStyle.cs
@@ -1,7 +1,7 @@
#nullable enable
-using DevToys.MonacoEditor.CodeEditorControl;
using System.Text;
+using DevToys.MonacoEditor.CodeEditorControl;
using Windows.UI.Text;
using Windows.UI.Xaml.Media;
@@ -31,10 +31,10 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
public string ToCss()
{
- StringBuilder output = new StringBuilder(40);
+ var output = new StringBuilder(40);
if (TextDecoration != TextDecoration.None)
{
- string text = TextDecoration.ToString().ToLower();
+ string? text = TextDecoration.ToString().ToLower();
if (TextDecoration == TextDecoration.LineThrough)
{
text = "line-through";
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssLineStyle.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssLineStyle.cs
index e6aabacf2..582cfe8fa 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssLineStyle.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssLineStyle.cs
@@ -1,8 +1,8 @@
#nullable enable
-using DevToys.MonacoEditor.CodeEditorControl;
using System;
using System.Text;
+using DevToys.MonacoEditor.CodeEditorControl;
using Windows.UI.Xaml.Media;
namespace DevToys.MonacoEditor.Monaco.Helpers
@@ -27,7 +27,7 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
public string ToCss()
{
- StringBuilder output = new StringBuilder(40);
+ var output = new StringBuilder(40);
if (BackgroundColor != null)
{
output.AppendLine(string.Format("background: #{0:X2}{1:X2}{2:X2};", BackgroundColor.Color.R,
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleBroker.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleBroker.cs
index de7ca60c5..e3ffcb92d 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleBroker.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleBroker.cs
@@ -1,8 +1,8 @@
#nullable enable
-using DevToys.MonacoEditor.CodeEditorControl;
using System.Collections.Generic;
using System.Text;
+using DevToys.MonacoEditor.CodeEditorControl;
namespace DevToys.MonacoEditor.Monaco.Helpers
{
@@ -12,7 +12,7 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
public sealed class CssStyleBroker
{
private static uint Id = 0;
- private readonly Dictionary<string, ICssStyle> _registered = new Dictionary<string, ICssStyle>();
+ private readonly Dictionary<string, ICssStyle> _registered = new();
private static readonly IDictionary<CodeEditorCore, CssStyleBroker> instances = new Dictionary<CodeEditorCore, CssStyleBroker>();
// Explicit static constructor to tell C# compiler
@@ -53,7 +53,7 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
public string Register(ICssStyle style)
{
Id += 1;
- var name = "generated-style-" + Id;
+ string? name = "generated-style-" + Id;
_registered.Add(name, style);
return name;
}
@@ -64,7 +64,7 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
/// <returns></returns>
public string GetStyles()
{
- StringBuilder rules = new StringBuilder(100);
+ var rules = new StringBuilder(100);
foreach (ICssStyle css in _registered.Values)
{
rules.AppendLine(css.ToCss());
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleConverter.cs
index c389348ba..cb4da41a1 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/CssStyleConverter.cs
@@ -1,8 +1,8 @@
#nullable enable
-using Newtonsoft.Json;
using System;
using System.Linq;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Helpers
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/TextDecorationConverter.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/TextDecorationConverter.cs
index 18aa9ed92..e40e8dc0f 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/TextDecorationConverter.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Helpers/TextDecorationConverter.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Helpers
{
@@ -16,23 +16,17 @@ namespace DevToys.MonacoEditor.Monaco.Helpers
return null;
}
- var value = serializer.Deserialize<string>(reader);
- switch (value)
+ string? value = serializer.Deserialize<string>(reader);
+ return value switch
{
- case "none":
- return TextDecoration.None;
- case "underline":
- return TextDecoration.Underline;
- case "overline":
- return TextDecoration.Overline;
- case "line-through":
- return TextDecoration.LineThrough;
- case "initial":
- return TextDecoration.Initial;
- case "inherit":
- return TextDecoration.Inherit;
- }
- throw new Exception("Cannot unmarshal type TextDecoration");
+ "none" => TextDecoration.None,
+ "underline" => TextDecoration.Underline,
+ "overline" => TextDecoration.Overline,
+ "line-through" => TextDecoration.LineThrough,
+ "initial" => TextDecoration.Initial,
+ "inherit" => TextDecoration.Inherit,
+ _ => throw new Exception("Cannot unmarshal type TextDecoration"),
+ };
}
public override void WriteJson(JsonWriter writer, object? untypedValue, JsonSerializer serializer)
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/KeyMod.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/KeyMod.cs
index b7786c1a3..0984d9169 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/KeyMod.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/KeyMod.cs
@@ -18,7 +18,7 @@ namespace DevToys.MonacoEditor.Monaco
public static int Chord(int firstPart, int secondPart)
{
// https://github.com/Microsoft/vscode/blob/master/src/vs/base/common/keyCodes.ts#L410
- var chordPart = ZeroFillRightShift((secondPart & 0x0000ffff) << 16, 0);
+ int chordPart = ZeroFillRightShift((secondPart & 0x0000ffff) << 16, 0);
return ZeroFillRightShift(firstPart | chordPart, 0);
}
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Languages/Hover.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Languages/Hover.cs
index 1044e40d4..5a4656f65 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Languages/Hover.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Languages/Hover.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System.Runtime.InteropServices.WindowsRuntime;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco.Languages
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/LanguagesHelper.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/LanguagesHelper.cs
index bb5069973..7f170ddc8 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/LanguagesHelper.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/LanguagesHelper.cs
@@ -1,10 +1,10 @@
#nullable enable
+using System;
+using System.Collections.Generic;
using DevToys.MonacoEditor.CodeEditorControl;
using DevToys.MonacoEditor.Monaco.Languages;
using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
using Windows.Foundation;
namespace DevToys.MonacoEditor.Monaco
@@ -54,7 +54,7 @@ namespace DevToys.MonacoEditor.Monaco
{
if (args != null && args.Length >= 2)
{
- var items = await provider.ProvideCompletionItemsAsync(editor.GetModel()!, JsonConvert.DeserializeObject<Position>(args[0]), JsonConvert.DeserializeObject<CompletionContext>(args[1]));
+ CompletionList? items = await provider.ProvideCompletionItemsAsync(editor.GetModel()!, JsonConvert.DeserializeObject<Position>(args[0]), JsonConvert.DeserializeObject<CompletionContext>(args[1]));
if (items != null)
{
@@ -69,9 +69,9 @@ namespace DevToys.MonacoEditor.Monaco
{
if (args != null && args.Length >= 2)
{
- var position = JsonConvert.DeserializeObject<Position>(args[0]);
- var requestedItem = JsonConvert.DeserializeObject<CompletionItem>(args[1]);
- var completionItem = await provider.ResolveCompletionItemAsync(editor.GetModel()!, position, requestedItem);
+ Position? position = JsonConvert.DeserializeObject<Position>(args[0]);
+ CompletionItem? requestedItem = JsonConvert.DeserializeObject<CompletionItem>(args[1]);
+ CompletionItem? completionItem = await provider.ResolveCompletionItemAsync(editor.GetModel()!, position, requestedItem);
if (completionItem != null)
{
@@ -98,7 +98,7 @@ namespace DevToys.MonacoEditor.Monaco
{
if (args != null && args.Length >= 1)
{
- var hover = await provider.ProvideHover(editor.GetModel()!, JsonConvert.DeserializeObject<Position>(args[0]));
+ Hover? hover = await provider.ProvideHover(editor.GetModel()!, JsonConvert.DeserializeObject<Position>(args[0]));
if (hover != null)
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/MarkdownString.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/MarkdownString.cs
index 2ee4247d0..998fda508 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/MarkdownString.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/MarkdownString.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System.Collections.Generic;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco
{
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/ModelHelper.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/ModelHelper.cs
index 9b2553f3d..639cbd8da 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/ModelHelper.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/ModelHelper.cs
@@ -1,10 +1,10 @@
#nullable enable
+using System;
+using System.Collections.Generic;
using DevToys.MonacoEditor.CodeEditorControl;
using DevToys.MonacoEditor.Monaco.Editor;
using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
using Windows.Foundation;
namespace DevToys.MonacoEditor.Monaco
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Position.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Position.cs
index 85212adb7..2ee22981f 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Position.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Position.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
using Windows.Foundation;
using Windows.Foundation.Metadata;
diff --git a/src/dev/impl/DevToys.MonacoEditor/Monaco/Range.cs b/src/dev/impl/DevToys.MonacoEditor/Monaco/Range.cs
index 03c6f0d1c..8b43e0afc 100644
--- a/src/dev/impl/DevToys.MonacoEditor/Monaco/Range.cs
+++ b/src/dev/impl/DevToys.MonacoEditor/Monaco/Range.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.MonacoEditor.Monaco
{
diff --git a/src/dev/impl/DevToys/Api/Core/InAppNotificationAddedEventArgs.cs b/src/dev/impl/DevToys/Api/Core/InAppNotificationAddedEventArgs.cs
index f5ab531c9..1081feb63 100644
--- a/src/dev/impl/DevToys/Api/Core/InAppNotificationAddedEventArgs.cs
+++ b/src/dev/impl/DevToys/Api/Core/InAppNotificationAddedEventArgs.cs
@@ -1,7 +1,7 @@
#nullable enable
-using DevToys.Core;
using System;
+using DevToys.Core;
namespace DevToys.Api.Core
{
diff --git a/src/dev/impl/DevToys/Api/Core/Navigation/NavigationParameter.cs b/src/dev/impl/DevToys/Api/Core/Navigation/NavigationParameter.cs
index c9eb8b5dc..929a1d89b 100644
--- a/src/dev/impl/DevToys/Api/Core/Navigation/NavigationParameter.cs
+++ b/src/dev/impl/DevToys/Api/Core/Navigation/NavigationParameter.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.ComponentModel;
using DevToys.Api.Core.Injection;
using DevToys.Core;
-using System.ComponentModel;
namespace DevToys.Api.Core.Navigation
{
diff --git a/src/dev/impl/DevToys/Api/Tools/MatchedToolProvider.cs b/src/dev/impl/DevToys/Api/Tools/MatchedToolProvider.cs
index 6e300566e..ef7f4cd78 100644
--- a/src/dev/impl/DevToys/Api/Tools/MatchedToolProvider.cs
+++ b/src/dev/impl/DevToys/Api/Tools/MatchedToolProvider.cs
@@ -1,8 +1,8 @@
#nullable enable
-using DevToys.Core;
using System;
using System.ComponentModel;
+using DevToys.Core;
namespace DevToys.Api.Tools
{
diff --git a/src/dev/impl/DevToys/App.xaml.cs b/src/dev/impl/DevToys/App.xaml.cs
index 2caec4c7a..d05604d91 100644
--- a/src/dev/impl/DevToys/App.xaml.cs
+++ b/src/dev/impl/DevToys/App.xaml.cs
@@ -1,5 +1,8 @@
#nullable enable
+using System;
+using System.Linq;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Injection;
using DevToys.Api.Core.Navigation;
@@ -10,9 +13,6 @@ using DevToys.Core.Settings;
using DevToys.Core.Threading;
using DevToys.Views;
using Microsoft.Graphics.Canvas.Text;
-using System;
-using System.Linq;
-using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
@@ -100,7 +100,7 @@ namespace DevToys
{
Frame rootFrame = await EnsureWindowIsInitializedAsync();
- var mefComposer = await _mefComposer;
+ MefComposer? mefComposer = await _mefComposer;
if (e.PrelaunchActivated == false)
{
// On Windows 10 version 1607 or later, this code signals that this app wants to participate in prelaunch
@@ -127,7 +127,7 @@ namespace DevToys
{
Frame rootFrame = await EnsureWindowIsInitializedAsync();
- var mefComposer = await _mefComposer;
+ MefComposer? mefComposer = await _mefComposer;
if (args.Kind == ActivationKind.Protocol)
{
var eventArgs = (ProtocolActivatedEventArgs)args;
@@ -164,7 +164,7 @@ namespace DevToys
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
- var deferral = e.SuspendingOperation.GetDeferral();
+ SuspendingDeferral? deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
try
@@ -189,7 +189,7 @@ namespace DevToys
private async Task<Frame> EnsureWindowIsInitializedAsync()
{
- ApplicationView applicationView = ApplicationView.GetForCurrentView();
+ var applicationView = ApplicationView.GetForCurrentView();
applicationView.SetPreferredMinSize(new Windows.Foundation.Size(300, 200));
// Do not repeat app initialization when the Window already has content,
@@ -197,8 +197,10 @@ namespace DevToys
if (Window.Current.Content is not Frame rootFrame)
{
// Create a Frame to act as the navigation context and navigate to the first page
- rootFrame = new Frame();
- rootFrame.CacheSize = 10;
+ rootFrame = new Frame
+ {
+ CacheSize = 10
+ };
rootFrame.NavigationFailed += OnNavigationFailed;
// Place the frame in the current Window
@@ -206,7 +208,7 @@ namespace DevToys
}
// Set the user-defined language.
- string languageIdentifier = (await _mefComposer).ExportProvider.GetExport<ISettingsProvider>().GetSetting(PredefinedSettings.Language);
+ string? languageIdentifier = (await _mefComposer).ExportProvider.GetExport<ISettingsProvider>().GetSetting(PredefinedSettings.Language);
LanguageDefinition languageDefinition
= LanguageManager.Instance.AvailableLanguages.FirstOrDefault(l => string.Equals(l.InternalName, languageIdentifier))
?? LanguageManager.Instance.AvailableLanguages[0];
@@ -225,7 +227,7 @@ namespace DevToys
{
if (rootFrame.Content == null)
{
- var mefComposer = await _mefComposer;
+ MefComposer? mefComposer = await _mefComposer;
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
@@ -244,8 +246,8 @@ namespace DevToys
await TaskScheduler.Default;
ISettingsProvider settingsProvider = await _settingsProvider.GetValueAsync();
- string currentFont = settingsProvider.GetSetting(PredefinedSettings.TextEditorFont);
- string[] systemFonts = CanvasTextFormat.GetSystemFontFamilies();
+ string? currentFont = settingsProvider.GetSetting(PredefinedSettings.TextEditorFont);
+ string[]? systemFonts = CanvasTextFormat.GetSystemFontFamilies();
if (!systemFonts.Contains(currentFont))
{
@@ -260,4 +262,4 @@ namespace DevToys
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dev/impl/DevToys/Core/AssetsHelper.cs b/src/dev/impl/DevToys/Core/AssetsHelper.cs
index 50b02b1cb..889d3ac8c 100644
--- a/src/dev/impl/DevToys/Core/AssetsHelper.cs
+++ b/src/dev/impl/DevToys/Core/AssetsHelper.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Core.Threading;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
+using DevToys.Core.Threading;
using Windows.Storage;
namespace DevToys.Core
@@ -13,28 +13,28 @@ namespace DevToys.Core
{
public static async Task<string> GetReleaseNoteAsync()
{
- string result = await GetLocalFileContentAsync($"Assets\\ReleaseNote.txt").ConfigureAwait(false);
+ string? result = await GetLocalFileContentAsync($"Assets\\ReleaseNote.txt").ConfigureAwait(false);
return result;
}
public static async Task<string> GetPrivacyStatementAsync()
{
- string result = await GetLocalFileContentAsync($"Assets\\PRIVACY-POLICY.md").ConfigureAwait(false);
+ string? result = await GetLocalFileContentAsync($"Assets\\PRIVACY-POLICY.md").ConfigureAwait(false);
return result;
}
public static async Task<string> GetThirdPartyNoticesAsync()
{
- string result = await GetLocalFileContentAsync($"Assets\\THIRD-PARTY-NOTICES.md").ConfigureAwait(false);
+ string? result = await GetLocalFileContentAsync($"Assets\\THIRD-PARTY-NOTICES.md").ConfigureAwait(false);
return result;
}
public static async Task<string> GetLicenseAsync()
{
- string result = await GetLocalFileContentAsync($"Assets\\LICENSE.md").ConfigureAwait(false);
+ string? result = await GetLocalFileContentAsync($"Assets\\LICENSE.md").ConfigureAwait(false);
return result;
}
diff --git a/src/dev/impl/DevToys/Core/Clipboard.cs b/src/dev/impl/DevToys/Core/Clipboard.cs
index a7ab4650f..e41d27d0d 100644
--- a/src/dev/impl/DevToys/Core/Clipboard.cs
+++ b/src/dev/impl/DevToys/Core/Clipboard.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Api.Core;
-using DevToys.Core.Threading;
using System;
using System.Composition;
using System.Threading.Tasks;
+using DevToys.Api.Core;
+using DevToys.Core.Threading;
using Windows.ApplicationModel.DataTransfer;
using Windows.Security.EnterpriseData;
using Windows.UI.Xaml;
diff --git a/src/dev/impl/DevToys/Core/Collections/OrderedObservableCollection.cs b/src/dev/impl/DevToys/Core/Collections/OrderedObservableCollection.cs
index 87847765d..966fd8e2a 100644
--- a/src/dev/impl/DevToys/Core/Collections/OrderedObservableCollection.cs
+++ b/src/dev/impl/DevToys/Core/Collections/OrderedObservableCollection.cs
@@ -14,7 +14,7 @@ namespace DevToys.Core.Collections
internal void Update(IEnumerable<T> newItems)
{
// First, remove the items that aren't part of the new list items.
- List<T> oldToolsMenuItems = this.ToList();
+ var oldToolsMenuItems = this.ToList();
for (int i = 0; i < oldToolsMenuItems.Count; i++)
{
T item = oldToolsMenuItems[i];
@@ -27,8 +27,8 @@ namespace DevToys.Core.Collections
// Then:
// 1. If an item from newItems already exist in the collection, but at a different position, move it to the desired index.
// 2. If an item from newItems doesn't exist in the collection, insert it with respect of the position of older items in the collection.
- var insertionIndex = 0;
- foreach (var item in newItems)
+ int insertionIndex = 0;
+ foreach (T? item in newItems)
{
int indexOfItemInOldMenu = IndexOf(item);
if (indexOfItemInOldMenu > -1)
diff --git a/src/dev/impl/DevToys/Core/Logger.cs b/src/dev/impl/DevToys/Core/Logger.cs
index bfc3ed48d..44ac9ffc3 100644
--- a/src/dev/impl/DevToys/Core/Logger.cs
+++ b/src/dev/impl/DevToys/Core/Logger.cs
@@ -1,11 +1,11 @@
#nullable enable
-using DevToys.Core.Threading;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
+using DevToys.Core.Threading;
using Windows.Storage;
using Windows.System;
@@ -15,7 +15,7 @@ namespace DevToys.Core
{
private const string LogFileName = "logs.txt";
- private readonly static DisposableSempahore _semaphore = new DisposableSempahore();
+ private static readonly DisposableSempahore _semaphore = new();
internal static async Task OpenLogsAsync()
{
diff --git a/src/dev/impl/DevToys/Core/MarketingService.cs b/src/dev/impl/DevToys/Core/MarketingService.cs
index 51d6eaec4..da105d9f4 100644
--- a/src/dev/impl/DevToys/Core/MarketingService.cs
+++ b/src/dev/impl/DevToys/Core/MarketingService.cs
@@ -1,13 +1,13 @@
#nullable enable
-using DevToys.Api.Core;
-using DevToys.Core.Threading;
-using DevToys.Models;
-using Newtonsoft.Json;
using System;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
+using DevToys.Api.Core;
+using DevToys.Core.Threading;
+using DevToys.Models;
+using Newtonsoft.Json;
using Windows.Services.Store;
using Windows.Storage;
@@ -20,11 +20,11 @@ namespace DevToys.Core
private const string StoredFileName = "marketingInfo.json";
private readonly INotificationService _notificationService;
- private readonly DisposableSempahore _semaphore = new DisposableSempahore();
- private readonly object _lock = new object();
+ private readonly DisposableSempahore _semaphore = new();
+ private readonly AsyncLazy<MarketingState> _marketingState;
+ private readonly object _lock = new();
private bool _rateOfferInProgress;
- private AsyncLazy<MarketingState> _marketingState;
[ImportingConstructor]
public MarketingService(INotificationService notificationService)
@@ -119,7 +119,7 @@ namespace DevToys.Core
state.LastAppRatingOfferDate = DateTime.Now;
});
- StoreContext storeContext = StoreContext.GetDefault();
+ var storeContext = StoreContext.GetDefault();
StoreRateAndReviewResult result = await ThreadHelper.RunOnUIThreadAsync(async () =>
{
@@ -246,7 +246,7 @@ namespace DevToys.Core
StorageFile file = await localCacheFolder.CreateFileAsync(StoredFileName, CreationCollisionOption.ReplaceExisting);
- string fileContent
+ string? fileContent
= JsonConvert.SerializeObject(
state,
Formatting.Indented);
@@ -271,10 +271,10 @@ namespace DevToys.Core
IStorageItem? file = await localCacheFolder.TryGetItemAsync(StoredFileName);
- if (file is not null && file is StorageFile storageFile)
+ if (file is not null and StorageFile storageFile)
{
- string fileContent = await FileIO.ReadTextAsync(storageFile);
- var result = JsonConvert.DeserializeObject<MarketingState>(fileContent);
+ string? fileContent = await FileIO.ReadTextAsync(storageFile);
+ MarketingState? result = JsonConvert.DeserializeObject<MarketingState>(fileContent);
if (result is not null)
{
return result;
diff --git a/src/dev/impl/DevToys/Core/MefComposer.cs b/src/dev/impl/DevToys/Core/MefComposer.cs
index 80d0ad193..0243a906c 100644
--- a/src/dev/impl/DevToys/Core/MefComposer.cs
+++ b/src/dev/impl/DevToys/Core/MefComposer.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Api.Core.Injection;
using System;
using System.Collections.Generic;
using System.Composition.Hosting;
using System.Reflection;
+using DevToys.Api.Core.Injection;
namespace DevToys.Core
{
@@ -63,7 +63,7 @@ namespace DevToys.Core
var assemblies = new HashSet<Assembly>(_assemblies);
- var configuration = new ContainerConfiguration()
+ ContainerConfiguration? configuration = new ContainerConfiguration()
.WithAssemblies(assemblies);
ExportProvider = configuration.CreateContainer();
diff --git a/src/dev/impl/DevToys/Core/MefProvider.cs b/src/dev/impl/DevToys/Core/MefProvider.cs
index bb6bf2dd1..80083a97a 100644
--- a/src/dev/impl/DevToys/Core/MefProvider.cs
+++ b/src/dev/impl/DevToys/Core/MefProvider.cs
@@ -1,9 +1,9 @@
#nullable enable
-using DevToys.Api.Core.Injection;
using System.Collections.Generic;
using System.Composition;
using System.Composition.Hosting;
+using DevToys.Api.Core.Injection;
namespace DevToys.Core
{
diff --git a/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs b/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs
index 9a150f5a8..dbeaec091 100644
--- a/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs
+++ b/src/dev/impl/DevToys/Core/Navigation/WindowManager.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Api.Core.Navigation;
-using DevToys.Core.Threading;
using System;
using System.Composition;
using System.Threading.Tasks;
+using DevToys.Api.Core.Navigation;
+using DevToys.Core.Threading;
using Windows.ApplicationModel;
using Windows.UI.Xaml.Controls;
diff --git a/src/dev/impl/DevToys/Core/NotificationService.cs b/src/dev/impl/DevToys/Core/NotificationService.cs
index 0459398bf..9253b1c99 100644
--- a/src/dev/impl/DevToys/Core/NotificationService.cs
+++ b/src/dev/impl/DevToys/Core/NotificationService.cs
@@ -1,8 +1,8 @@
#nullable enable
-using DevToys.Api.Core;
using System;
using System.Composition;
+using DevToys.Api.Core;
namespace DevToys.Core
{
diff --git a/src/dev/impl/DevToys/Core/Settings/SettingsProvider.cs b/src/dev/impl/DevToys/Core/Settings/SettingsProvider.cs
index d3410666b..1d1cc52f3 100644
--- a/src/dev/impl/DevToys/Core/Settings/SettingsProvider.cs
+++ b/src/dev/impl/DevToys/Core/Settings/SettingsProvider.cs
@@ -1,11 +1,11 @@
#nullable enable
-using DevToys.Api.Core.Settings;
-using Newtonsoft.Json;
using System;
using System.Collections;
using System.Composition;
using System.Globalization;
+using DevToys.Api.Core.Settings;
+using Newtonsoft.Json;
using Windows.Storage;
namespace DevToys.Core.Settings
diff --git a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs b/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
index bffebdb22..bcf6b8b46 100644
--- a/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
+++ b/src/dev/impl/DevToys/Core/Theme/ThemeListener.cs
@@ -1,11 +1,11 @@
#nullable enable
+using System;
+using System.Composition;
using DevToys.Api.Core.Settings;
using DevToys.Api.Core.Theme;
using DevToys.Core.Settings;
using DevToys.Core.Threading;
-using System;
-using System.Composition;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
diff --git a/src/dev/impl/DevToys/Core/Threading/AsyncLazy.cs b/src/dev/impl/DevToys/Core/Threading/AsyncLazy.cs
index a07837e9e..62a046b47 100644
--- a/src/dev/impl/DevToys/Core/Threading/AsyncLazy.cs
+++ b/src/dev/impl/DevToys/Core/Threading/AsyncLazy.cs
@@ -51,7 +51,7 @@ namespace DevToys.Core.Threading
public async Task<T> GetValueAsync()
{
- return IsValueCreated? await _innerLazy.Value : _innerLazy.Value.Result;
+ return IsValueCreated ? await _innerLazy.Value : _innerLazy.Value.Result;
}
}
}
diff --git a/src/dev/impl/DevToys/Core/Threading/TaskCompletionNotifier.cs b/src/dev/impl/DevToys/Core/Threading/TaskCompletionNotifier.cs
index 0b14b6294..e31a8834d 100644
--- a/src/dev/impl/DevToys/Core/Threading/TaskCompletionNotifier.cs
+++ b/src/dev/impl/DevToys/Core/Threading/TaskCompletionNotifier.cs
@@ -20,7 +20,7 @@ namespace DevToys.Core.Threading
/// <summary>
/// Gets the result of the task. Returns the default value of TResult if the task has not completed successfully.
/// </summary>
- public TResult? Result => (Task != null && Task.Status == TaskStatus.RanToCompletion) ? Task.Result : default(TResult);
+ public TResult? Result => (Task != null && Task.Status == TaskStatus.RanToCompletion) ? Task.Result : default;
/// <summary>
/// Gets whether the task has completed.
@@ -58,13 +58,13 @@ namespace DevToys.Core.Threading
Task = task;
if (task != null && !task.IsCompleted)
{
- var scheduler = (SynchronizationContext.Current == null) ? TaskScheduler.Current : TaskScheduler.FromCurrentSynchronizationContext();
+ TaskScheduler? scheduler = (SynchronizationContext.Current == null) ? TaskScheduler.Current : TaskScheduler.FromCurrentSynchronizationContext();
task
.ContinueWith(
async t =>
{
- var propertyChanged = PropertyChanged;
+ PropertyChangedEventHandler? propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
await ThreadHelper.RunOnUIThreadAsync(() =>
diff --git a/src/dev/impl/DevToys/Core/Threading/ThreadHelper.cs b/src/dev/impl/DevToys/Core/Threading/ThreadHelper.cs
index be9ed0305..67dcce977 100644
--- a/src/dev/impl/DevToys/Core/Threading/ThreadHelper.cs
+++ b/src/dev/impl/DevToys/Core/Threading/ThreadHelper.cs
@@ -9,7 +9,7 @@ namespace DevToys.Core.Threading
{
internal static class ThreadHelper
{
- private readonly static CoreDispatcher _uiDispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
+ private static readonly CoreDispatcher _uiDispatcher = CoreApplication.MainView.CoreWindow.Dispatcher;
internal static void ThrowIfNotOnUIThread()
{
@@ -138,17 +138,13 @@ namespace DevToys.Core.Threading
private static CoreDispatcherPriority GetDispatcherPriority(ThreadPriority priority)
{
- switch (priority)
+ return priority switch
{
- case ThreadPriority.Low:
- return CoreDispatcherPriority.Low;
- case ThreadPriority.Normal:
- return CoreDispatcherPriority.Normal;
- case ThreadPriority.High:
- return CoreDispatcherPriority.High;
- default:
- throw new NotSupportedException();
- }
+ ThreadPriority.Low => CoreDispatcherPriority.Low,
+ ThreadPriority.Normal => CoreDispatcherPriority.Normal,
+ ThreadPriority.High => CoreDispatcherPriority.High,
+ _ => throw new NotSupportedException(),
+ };
}
}
}
diff --git a/src/dev/impl/DevToys/Core/TitleBar.cs b/src/dev/impl/DevToys/Core/TitleBar.cs
index e8ed7f775..e17a174f7 100644
--- a/src/dev/impl/DevToys/Core/TitleBar.cs
+++ b/src/dev/impl/DevToys/Core/TitleBar.cs
@@ -1,13 +1,13 @@
#nullable enable
+using System.ComponentModel;
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Core.Theme;
using DevToys.Core.Settings;
using DevToys.Core.Threading;
-using System.ComponentModel;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.ApplicationModel.Core;
using Windows.UI;
using Windows.UI.Core;
diff --git a/src/dev/impl/DevToys/Core/ToolProviderFactory.cs b/src/dev/impl/DevToys/Core/ToolProviderFactory.cs
index 8e8604997..27cb4c027 100644
--- a/src/dev/impl/DevToys/Core/ToolProviderFactory.cs
+++ b/src/dev/impl/DevToys/Core/ToolProviderFactory.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Api.Tools;
using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
+using DevToys.Api.Tools;
namespace DevToys.Providers.Impl
{
@@ -45,7 +45,7 @@ namespace DevToys.Providers.Impl
if (searchQueries is not null)
{
- foreach (string query in searchQueries)
+ foreach (string? query in searchQueries)
{
int i = 0;
while (i < provider.Value.DisplayName?.Length && i > -1)
@@ -82,7 +82,7 @@ namespace DevToys.Providers.Impl
public IEnumerable<MatchedToolProvider> GetFooterTools()
{
- var matches = Array.Empty<MatchSpan>();
+ MatchSpan[]? matches = Array.Empty<MatchSpan>();
foreach (Lazy<IToolProvider, ToolProviderMetadata> provider
in _providers.Where(item => item.Metadata.IsFooterItem)
.OrderBy(item => item.Metadata.Order ?? int.MaxValue)
diff --git a/src/dev/impl/DevToys/Core/UriActivationProtocolService.cs b/src/dev/impl/DevToys/Core/UriActivationProtocolService.cs
index 2f32716c3..7809f9287 100644
--- a/src/dev/impl/DevToys/Core/UriActivationProtocolService.cs
+++ b/src/dev/impl/DevToys/Core/UriActivationProtocolService.cs
@@ -1,11 +1,11 @@
#nullable enable
-using DevToys.Api.Core;
-using DevToys.Core.Threading;
using System;
using System.Composition;
using System.Globalization;
using System.Threading.Tasks;
+using DevToys.Api.Core;
+using DevToys.Core.Threading;
using Windows.ApplicationModel;
using Windows.System;
@@ -19,7 +19,7 @@ namespace DevToys.Core
{
return await ThreadHelper.RunOnUIThreadAsync(async () =>
{
- string uriToLaunch = Constants.UriActivationProtocolName;
+ string? uriToLaunch = Constants.UriActivationProtocolName;
try
{
diff --git a/src/dev/impl/DevToys/Helpers/JsonHelper.cs b/src/dev/impl/DevToys/Helpers/JsonHelper.cs
index d667aaf96..84e3ae930 100644
--- a/src/dev/impl/DevToys/Helpers/JsonHelper.cs
+++ b/src/dev/impl/DevToys/Helpers/JsonHelper.cs
@@ -1,12 +1,12 @@
#nullable enable
+using System;
+using System.IO;
+using System.Text;
using DevToys.Core;
using DevToys.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using System;
-using System.IO;
-using System.Text;
namespace DevToys.Helpers
{
@@ -29,7 +29,7 @@ namespace DevToys.Helpers
{
try
{
- JToken? jtoken = JToken.Parse(input);
+ var jtoken = JToken.Parse(input);
return jtoken is not null;
}
catch (JsonReaderException)
@@ -61,7 +61,7 @@ namespace DevToys.Helpers
try
{
- JToken? jtoken = JToken.Parse(input!);
+ var jtoken = JToken.Parse(input!);
if (jtoken is not null)
{
var stringBuilder = new StringBuilder();
diff --git a/src/dev/impl/DevToys/Helpers/JwtHelper.cs b/src/dev/impl/DevToys/Helpers/JwtHelper.cs
index 562035224..9dd7bddff 100644
--- a/src/dev/impl/DevToys/Helpers/JwtHelper.cs
+++ b/src/dev/impl/DevToys/Helpers/JwtHelper.cs
@@ -21,7 +21,7 @@ namespace DevToys.Helpers
try
{
- JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
+ var handler = new JwtSecurityTokenHandler();
JwtSecurityToken jwtSecurityToken = handler.ReadJwtToken(input);
return jwtSecurityToken is not null;
}
diff --git a/src/dev/impl/DevToys/Helpers/YamlHelper.cs b/src/dev/impl/DevToys/Helpers/YamlHelper.cs
index a12f4468b..ffef294d2 100644
--- a/src/dev/impl/DevToys/Helpers/YamlHelper.cs
+++ b/src/dev/impl/DevToys/Helpers/YamlHelper.cs
@@ -21,8 +21,8 @@ namespace DevToys.Helpers
try
{
- object result = new DeserializerBuilder().Build().Deserialize<object>(input);
- return result is not null && result is not string;
+ object? result = new DeserializerBuilder().Build().Deserialize<object>(input);
+ return result is not null and not string;
}
catch (Exception)
{
diff --git a/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs b/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs
index e51da4fec..45991dde5 100644
--- a/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs
+++ b/src/dev/impl/DevToys/Models/IndentationDisplayPair.cs
@@ -6,13 +6,13 @@ namespace DevToys.Models
{
private static JsonFormatterStrings Strings => LanguageManager.Instance.JsonFormatter;
- public static readonly IndentationDisplayPair TwoSpaces = new IndentationDisplayPair(Strings.TwoSpaces, Indentation.TwoSpaces);
+ public static readonly IndentationDisplayPair TwoSpaces = new(Strings.TwoSpaces, Indentation.TwoSpaces);
- public static readonly IndentationDisplayPair FourSpaces = new IndentationDisplayPair(Strings.FourSpaces, Indentation.FourSpaces);
+ public static readonly IndentationDisplayPair FourSpaces = new(Strings.FourSpaces, Indentation.FourSpaces);
- public static readonly IndentationDisplayPair OneTab = new IndentationDisplayPair(Strings.OneTab, Indentation.OneTab);
+ public static readonly IndentationDisplayPair OneTab = new(Strings.OneTab, Indentation.OneTab);
- public static readonly IndentationDisplayPair Minified = new IndentationDisplayPair(Strings.Minified, Indentation.Minified);
+ public static readonly IndentationDisplayPair Minified = new(Strings.Minified, Indentation.Minified);
public string DisplayName { get; }
diff --git a/src/dev/impl/DevToys/Models/MarketingState.cs b/src/dev/impl/DevToys/Models/MarketingState.cs
index 7084ca03f..a4f00e3b9 100644
--- a/src/dev/impl/DevToys/Models/MarketingState.cs
+++ b/src/dev/impl/DevToys/Models/MarketingState.cs
@@ -1,7 +1,7 @@
#nullable enable
-using Newtonsoft.Json;
using System;
+using Newtonsoft.Json;
namespace DevToys.Models
{
diff --git a/src/dev/impl/DevToys/Models/MatchedToolProviderViewData.cs b/src/dev/impl/DevToys/Models/MatchedToolProviderViewData.cs
index ecf2ff171..293f33404 100644
--- a/src/dev/impl/DevToys/Models/MatchedToolProviderViewData.cs
+++ b/src/dev/impl/DevToys/Models/MatchedToolProviderViewData.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Threading.Tasks;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
-using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
namespace DevToys.Models
diff --git a/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs b/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs
index d3a256fee..7e2518047 100644
--- a/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs
+++ b/src/dev/impl/DevToys/UI/Controls/CodeEditor.xaml.cs
@@ -1,10 +1,10 @@
#nullable enable
+using System;
using DevToys.Api.Core.Settings;
using DevToys.Core;
using DevToys.Core.Settings;
using DevToys.MonacoEditor.Monaco.Editor;
-using System;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.Storage.Pickers;
@@ -361,7 +361,7 @@ namespace DevToys.UI.Controls
{
try
{
- string text = await FileIO.ReadTextAsync(file);
+ string? text = await FileIO.ReadTextAsync(file);
await Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>
diff --git a/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs b/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs
index af24b2f36..b2691bc7e 100644
--- a/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs
+++ b/src/dev/impl/DevToys/UI/Controls/CustomTextBox.xaml.cs
@@ -1,10 +1,10 @@
#nullable enable
-using DevToys.Core;
-using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
+using DevToys.Core;
+using Microsoft.Toolkit.Mvvm.Input;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using Windows.Storage.Pickers;
@@ -259,7 +259,7 @@ namespace DevToys.UI.Controls
return;
}
- var richEditBox = GetRichEditBox();
+ RichEditBox? richEditBox = GetRichEditBox();
richEditBox.TextDocument.BatchDisplayUpdates();
if (highlightsToRemove is not null)
@@ -300,10 +300,10 @@ namespace DevToys.UI.Controls
else
{
var grid = (Grid)VisualTreeHelper.GetChild(TextBox, 0);
- for (var i = 0; i <= VisualTreeHelper.GetChildrenCount(grid) - 1; i++)
+ for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(grid) - 1; i++)
{
object obj = VisualTreeHelper.GetChild(grid, i);
- if (!(obj is ScrollViewer))
+ if (obj is not ScrollViewer)
{
continue;
}
@@ -324,7 +324,7 @@ namespace DevToys.UI.Controls
if (IsRichTextEdit)
{
- var richEditBox = GetRichEditBox();
+ RichEditBox? richEditBox = GetRichEditBox();
richEditBox.Visibility = Visibility.Visible;
richEditBox.TextChanging += RichEditBox_TextChanging;
richEditBox.SelectionFlyout = null;
@@ -440,7 +440,7 @@ namespace DevToys.UI.Controls
private void CopyTextBoxSelectionToClipboard()
{
- DataPackage dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
+ var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
dataPackage.SetText(TextBox.SelectedText);
Clipboard.SetContentWithOptions(dataPackage, new ClipboardContentOptions() { IsAllowedInHistory = true, IsRoamable = true });
Clipboard.Flush(); // This method allows the content to remain available after the application shuts down.
@@ -448,8 +448,8 @@ namespace DevToys.UI.Controls
private void CopyRichEditBoxSelectionToClipboard()
{
- RichEditBox.Document.Selection.GetText(TextGetOptions.UseCrlf, out string text);
- DataPackage dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
+ RichEditBox.Document.Selection.GetText(TextGetOptions.UseCrlf, out string? text);
+ var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
dataPackage.SetText(text);
Clipboard.SetContentWithOptions(dataPackage, new ClipboardContentOptions() { IsAllowedInHistory = true, IsRoamable = true });
Clipboard.Flush(); // This method allows the content to remain available after the application shuts down.
@@ -469,7 +469,7 @@ namespace DevToys.UI.Controls
{
if (IsRichTextEdit)
{
- var richEditBox = GetRichEditBox();
+ RichEditBox? richEditBox = GetRichEditBox();
if (!richEditBox.TextDocument.CanPaste())
{
return;
@@ -528,7 +528,7 @@ namespace DevToys.UI.Controls
{
try
{
- string text = await FileIO.ReadTextAsync(file);
+ string? text = await FileIO.ReadTextAsync(file);
await Dispatcher.RunAsync(
Windows.UI.Core.CoreDispatcherPriority.Normal,
() =>
@@ -554,7 +554,7 @@ namespace DevToys.UI.Controls
{
if (!_isTextPendingUpdate)
{
- RichEditBox.TextDocument.GetText(TextGetOptions.UseCrlf, out var document);
+ RichEditBox.TextDocument.GetText(TextGetOptions.UseCrlf, out string? document);
_isTextPendingUpdate = true;
Text = document;
SetHighlights(_highlightedSpans);
diff --git a/src/dev/impl/DevToys/UI/Controls/Notification.xaml.cs b/src/dev/impl/DevToys/UI/Controls/Notification.xaml.cs
index 1b490458b..bfdbb3ec7 100644
--- a/src/dev/impl/DevToys/UI/Controls/Notification.xaml.cs
+++ b/src/dev/impl/DevToys/UI/Controls/Notification.xaml.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Collections.ObjectModel;
using DevToys.Api.Core;
using DevToys.Core.Threading;
-using System.Collections.ObjectModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -58,7 +58,7 @@ namespace DevToys.UI.Controls
private static void OnNotificationServicePropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
- INotificationService? notificationService = e.NewValue as INotificationService;
+ var notificationService = e.NewValue as INotificationService;
if (notificationService is not null)
{
((Notification)d).ListenToNotifications(notificationService);
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToGridLengthConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToGridLengthConverter.cs
index e473a97f3..088288581 100644
--- a/src/dev/impl/DevToys/UI/Converters/BooleanToGridLengthConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToGridLengthConverter.cs
@@ -23,7 +23,7 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToScrollModeConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToScrollModeConverter.cs
index feb05b413..77b8ae89d 100644
--- a/src/dev/impl/DevToys/UI/Converters/BooleanToScrollModeConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToScrollModeConverter.cs
@@ -24,7 +24,7 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToTextWrappingConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToTextWrappingConverter.cs
index 43199161d..b9028adf6 100644
--- a/src/dev/impl/DevToys/UI/Converters/BooleanToTextWrappingConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToTextWrappingConverter.cs
@@ -23,7 +23,7 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys/UI/Converters/BooleanToVisibilityConverter.cs b/src/dev/impl/DevToys/UI/Converters/BooleanToVisibilityConverter.cs
index c832f1b7f..94439be94 100644
--- a/src/dev/impl/DevToys/UI/Converters/BooleanToVisibilityConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/BooleanToVisibilityConverter.cs
@@ -18,7 +18,7 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys/UI/Converters/EnumToBooleanConverter.cs b/src/dev/impl/DevToys/UI/Converters/EnumToBooleanConverter.cs
index 5120f10ab..4a76efcd6 100644
--- a/src/dev/impl/DevToys/UI/Converters/EnumToBooleanConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/EnumToBooleanConverter.cs
@@ -15,15 +15,15 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- if (value is null || parameter is null || !(value is Enum))
+ if (value is null || parameter is null || value is not Enum)
{
return IsInverted;
}
- var currentState = value.ToString();
- var stateStrings = parameter.ToString();
+ string? currentState = value.ToString();
+ string? stateStrings = parameter.ToString();
- string[] stateStringsSplitted = stateStrings.Split(',');
+ string[]? stateStringsSplitted = stateStrings.Split(',');
for (int i = 0; i < stateStringsSplitted.Length; i++)
{
if (string.Equals(currentState, stateStringsSplitted[i].Trim(), StringComparison.Ordinal))
@@ -37,9 +37,8 @@ namespace DevToys.UI.Converters
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
- string? parameterString = parameter as string;
- var valueBool = value as bool?;
- if (parameterString is null || valueBool is null)
+ bool? valueBool = value as bool?;
+ if (parameter is not string parameterString || valueBool is null)
{
return DependencyProperty.UnsetValue;
}
diff --git a/src/dev/impl/DevToys/UI/Converters/EnumToThicknessConverter.cs b/src/dev/impl/DevToys/UI/Converters/EnumToThicknessConverter.cs
index 410570097..a9dc8da4b 100644
--- a/src/dev/impl/DevToys/UI/Converters/EnumToThicknessConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/EnumToThicknessConverter.cs
@@ -23,15 +23,15 @@ namespace DevToys.UI.Converters
public object Convert(object value, Type targetType, object parameter, string language)
{
- if (value == null || parameter == null || !(value is Enum))
+ if (value == null || parameter == null || value is not Enum)
{
return ThicknessOnEnumNotDetected;
}
- var currentState = value.ToString();
- var stateStrings = parameter.ToString();
+ string? currentState = value.ToString();
+ string? stateStrings = parameter.ToString();
- string[] stateStringsSplitted = stateStrings.Split(',');
+ string[]? stateStringsSplitted = stateStrings.Split(',');
for (int i = 0; i < stateStringsSplitted.Length; i++)
{
if (string.Equals(currentState, stateStringsSplitted[i].Trim(), StringComparison.Ordinal))
diff --git a/src/dev/impl/DevToys/UI/Converters/InvertedBooleanConverter.cs b/src/dev/impl/DevToys/UI/Converters/InvertedBooleanConverter.cs
index e8946f5b7..b5c81acae 100644
--- a/src/dev/impl/DevToys/UI/Converters/InvertedBooleanConverter.cs
+++ b/src/dev/impl/DevToys/UI/Converters/InvertedBooleanConverter.cs
@@ -13,7 +13,7 @@ namespace DevToys.UI.Converters
{
public object Convert(object value, Type targetType, object parameter, string language)
{
- var valueBool = value as bool?;
+ bool? valueBool = value as bool?;
if (valueBool == null)
{
return DependencyProperty.UnsetValue;
diff --git a/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs b/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
index 6b55d289a..cdbaa56fa 100644
--- a/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
+++ b/src/dev/impl/DevToys/UI/Extensions/HighlighterExtension.cs
@@ -1,8 +1,8 @@
#nullable enable
-using DevToys.Api.Tools;
using System;
using System.Collections.Generic;
+using DevToys.Api.Tools;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -59,7 +59,7 @@ namespace DevToys.UI.Extensions
if (value.Length > 0)
{
- TextHighlighter highlighter = new TextHighlighter()
+ var highlighter = new TextHighlighter()
{
Background = new SolidColorBrush(Colors.Yellow)
};
diff --git a/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs b/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
index acfa2208d..d5da6ff94 100644
--- a/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/MainPageViewModel.cs
@@ -1,5 +1,14 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Composition;
+using System.Globalization;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Web;
using DevToys.Api.Core;
using DevToys.Api.Core.Navigation;
using DevToys.Api.Core.Settings;
@@ -14,18 +23,8 @@ using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using Microsoft.Toolkit.Mvvm.Messaging;
using Microsoft.UI.Xaml.Controls;
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Composition;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Web;
using Windows.ApplicationModel;
using Windows.Foundation;
-using Windows.Management.Deployment;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using ThreadPriority = DevToys.Core.Threading.ThreadPriority;
@@ -235,7 +234,7 @@ namespace DevToys.ViewModels
{
Assumes.NotNull(SelectedMenuItem, nameof(SelectedMenuItem));
- ViewModePreferences compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
+ var compactOptions = ViewModePreferences.CreateDefault(ApplicationViewMode.CompactOverlay);
compactOptions.CustomSize = new Size(SelectedMenuItem!.Metadata.CompactOverlayWidth, SelectedMenuItem.Metadata.CompactOverlayHeight);
if (await ApplicationView.GetForCurrentView().TryEnterViewModeAsync(applicationViewMode, compactOptions))
@@ -383,11 +382,11 @@ namespace DevToys.ViewModels
ThreadPriority.Low,
() =>
{
- var oldSelectedItem = SelectedMenuItem;
+ MatchedToolProviderViewData? oldSelectedItem = SelectedMenuItem;
ToolsMenuItems.Clear();
SetSelectedMenuItem(null, null);
- foreach (var item in newToolsMenuitems)
+ foreach (KeyValuePair<MatchedToolProviderViewData, MatchSpan[]?> item in newToolsMenuitems)
{
if (item.Value is not null)
{
@@ -502,8 +501,8 @@ namespace DevToys.ViewModels
await TaskScheduler.Default;
PackageVersion v = Package.Current.Id.Version;
- string currentVersion = $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision}";
- string lastVersion = _settingsProvider.GetSetting(PredefinedSettings.LastVersionRan);
+ string? currentVersion = $"{v.Major}.{v.Minor}.{v.Build}.{v.Revision}";
+ string? lastVersion = _settingsProvider.GetSetting(PredefinedSettings.LastVersionRan);
if (!_settingsProvider.GetSetting(PredefinedSettings.FirstTimeStart) && currentVersion != lastVersion)
{
@@ -531,7 +530,7 @@ namespace DevToys.ViewModels
PackageUpdateAvailabilityResult result = await Package.Current.CheckUpdateAvailabilityAsync();
- if (result.Availability == PackageUpdateAvailability.Required || result.Availability == PackageUpdateAvailability.Available)
+ if (result.Availability is PackageUpdateAvailability.Required or PackageUpdateAvailability.Available)
{
_notificationService.ShowInAppNotification(
Strings.NotificationUpdateAvailableTitle,
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolProvider.cs
index 0c311f96a..cc5b65ee0 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolProvider.cs
@@ -1,11 +1,11 @@
#nullable enable
-using DevToys.Api.Core.Injection;
-using DevToys.Api.Tools;
using System;
using System.Composition;
using System.Text;
using System.Text.RegularExpressions;
+using DevToys.Api.Core.Injection;
+using DevToys.Api.Tools;
namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
{
@@ -62,8 +62,8 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
return false;
}
- var equalIndex = data.IndexOf('=');
- var length = data.Length;
+ int equalIndex = data.IndexOf('=');
+ int length = data.Length;
if (!(equalIndex == -1 || equalIndex == length - 1 || (equalIndex == length - 2 && data[length - 1] == '=')))
{
@@ -74,7 +74,7 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
try
{
- byte[] decodedData = Convert.FromBase64String(data);
+ byte[]? decodedData = Convert.FromBase64String(data);
decoded = Encoding.UTF8.GetString(decodedData);
}
catch (Exception)
@@ -92,12 +92,14 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
return false;
}
+#pragma warning disable IDE0078 // Use pattern matching
if (!(current == 0x9
|| current == 0xA
|| current == 0xD
|| (current >= 0x20 && current <= 0xD7FF)
|| (current >= 0xE000 && current <= 0xFFFD)
|| (current >= 0x10000 && current <= 0x10FFFF)))
+#pragma warning restore IDE0078 // Use pattern matching
{
return false;
}
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolViewModel.cs
index 9551bc725..fee8eec21 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Base64EncoderDecoder/Base64EncoderDecoderToolViewModel.cs
@@ -1,5 +1,10 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Text;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -7,11 +12,6 @@ using DevToys.Core;
using DevToys.Core.Threading;
using DevToys.Views.Tools.Base64EncoderDecoder;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Text;
-using System.Threading.Tasks;
namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
{
@@ -142,7 +142,7 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
await TaskScheduler.Default;
- while (_conversionQueue.TryDequeue(out string text))
+ while (_conversionQueue.TryDequeue(out string? text))
{
string conversionResult;
if (string.Equals(ConversionMode, DefaultConversion, StringComparison.Ordinal))
@@ -178,12 +178,11 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
await TaskScheduler.Default;
- string encoded = string.Empty;
-
+ string? encoded;
try
{
Encoding encoder = GetEncoder();
- byte[] dataBytes = encoder.GetBytes(data);
+ byte[]? dataBytes = encoder.GetBytes(data);
encoded = Convert.ToBase64String(dataBytes);
}
catch (Exception ex)
@@ -203,11 +202,11 @@ namespace DevToys.ViewModels.Tools.Base64EncoderDecoder
}
await TaskScheduler.Default;
- string decoded = string.Empty;
+ string? decoded = string.Empty;
try
{
- byte[] decodedData = Convert.FromBase64String(data);
+ byte[]? decodedData = Convert.FromBase64String(data);
Encoding encoder = GetEncoder();
decoded = encoder.GetString(decodedData);
}
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolProvider.cs
index bb100080e..dd771b817 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolProvider.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
-using System.Composition;
namespace DevToys.ViewModels.Tools.GuidGenerator
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolViewModel.cs
index 6f9ebf7e6..df6516437 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/GuidGenerator/GuidGeneratorToolViewModel.cs
@@ -1,5 +1,8 @@
#nullable enable
+using System;
+using System.Composition;
+using System.Text;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -7,9 +10,6 @@ using DevToys.UI.Controls;
using DevToys.Views.Tools.GuidGenerator;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
-using System;
-using System.Composition;
-using System.Text;
namespace DevToys.ViewModels.Tools.GuidGenerator
{
@@ -128,7 +128,7 @@ namespace DevToys.ViewModels.Tools.GuidGenerator
var newGuids = new StringBuilder();
for (int i = 0; i < NumberOfGuidsToGenerate; i++)
{
- string guid = Guid.NewGuid().ToString(guidStringFormat);
+ string? guid = Guid.NewGuid().ToString(guidStringFormat);
if (IsUppercase)
{
guid = guid.ToUpperInvariant();
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolProvider.cs
index 7e3fa2090..655bcee46 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolProvider.cs
@@ -1,10 +1,10 @@
#nullable enable
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
namespace DevToys.ViewModels.Tools.HashGenerator
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolViewModel.cs
index 2d0636545..dd588cc17 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/HashGenerator/HashGeneratorToolViewModel.cs
@@ -1,5 +1,9 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -7,10 +11,6 @@ using DevToys.Core;
using DevToys.Core.Threading;
using DevToys.Views.Tools.HashGenerator;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
@@ -117,7 +117,7 @@ namespace DevToys.ViewModels.Tools.HashGenerator
await TaskScheduler.Default;
- while (_hashCalculationQueue.TryDequeue(out string text))
+ while (_hashCalculationQueue.TryDequeue(out string? text))
{
Task<string> md5CalculationTask = CalculateHashAsync(HashAlgorithmNames.Md5, text);
Task<string> sha1CalculationTask = CalculateHashAsync(HashAlgorithmNames.Sha1, text);
@@ -155,12 +155,12 @@ namespace DevToys.ViewModels.Tools.HashGenerator
try
{
- HashAlgorithmProvider algorithmProvider = HashAlgorithmProvider.OpenAlgorithm(alrogithmName);
+ var algorithmProvider = HashAlgorithmProvider.OpenAlgorithm(alrogithmName);
IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);
buffer = algorithmProvider.HashData(buffer);
- string hash = CryptographicBuffer.EncodeToHexString(buffer);
+ string? hash = CryptographicBuffer.EncodeToHexString(buffer);
if (IsUppercase)
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolProvider.cs
index dd564c318..8c9b846d5 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolProvider.cs
@@ -1,9 +1,9 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Helpers;
-using System.Composition;
namespace DevToys.ViewModels.Tools.JsonFormatter
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs
index 857421e99..415f7392a 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JsonFormatter/JsonFormatterToolViewModel.cs
@@ -1,5 +1,11 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Composition;
+using System.Linq;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -8,12 +14,6 @@ using DevToys.Helpers;
using DevToys.Models;
using DevToys.Views.Tools.JsonFormatter;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Composition;
-using System.Linq;
-using System.Threading.Tasks;
namespace DevToys.ViewModels.Tools.JsonFormatter
{
@@ -49,7 +49,7 @@ namespace DevToys.ViewModels.Tools.JsonFormatter
get
{
Indentation settingsValue = SettingsProvider.GetSetting(Indentation);
- var indentation = Indentations.FirstOrDefault(x => x.Value == settingsValue);
+ IndentationDisplayPair? indentation = Indentations.FirstOrDefault(x => x.Value == settingsValue);
return indentation ?? IndentationDisplayPair.TwoSpaces;
}
set
@@ -118,7 +118,7 @@ namespace DevToys.ViewModels.Tools.JsonFormatter
await TaskScheduler.Default;
- while (_formattingQueue.TryDequeue(out string text))
+ while (_formattingQueue.TryDequeue(out string? text))
{
string? result = JsonHelper.Format(text, IndentationMode.Value);
if (result != null)
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolProvider.cs
index 62ebdfdd2..7fa456ac0 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolProvider.cs
@@ -1,9 +1,9 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Helpers;
-using System.Composition;
namespace DevToys.ViewModels.Tools.JsonYaml
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolViewModel.cs
index 1b97e3db3..66ea5090b 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JsonYaml/JsonYamlToolViewModel.cs
@@ -1,5 +1,12 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Dynamic;
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -9,13 +16,6 @@ using DevToys.Helpers;
using DevToys.Views.Tools.JsonYaml;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Dynamic;
-using System.IO;
-using System.Text;
-using System.Threading.Tasks;
using YamlDotNet.Core;
using YamlDotNet.Serialization;
@@ -191,7 +191,7 @@ namespace DevToys.ViewModels.Tools.JsonYaml
await TaskScheduler.Default;
- while (_conversionQueue.TryDequeue(out string text))
+ while (_conversionQueue.TryDequeue(out string? text))
{
bool success;
string result;
@@ -230,23 +230,15 @@ namespace DevToys.ViewModels.Tools.JsonYaml
try
{
dynamic jsonObject = JsonConvert.DeserializeObject<ExpandoObject>(input);
- if (jsonObject is not null && jsonObject is not string)
+ if (jsonObject is not null and not string)
{
int indent = 0;
- switch (IndentationMode)
+ indent = IndentationMode switch
{
- case TwoSpaceIndentation:
- indent = 2;
- break;
-
- case FourSpaceIndentation:
- indent = 4;
- break;
-
- default:
- throw new NotSupportedException();
- }
-
+ TwoSpaceIndentation => 2,
+ FourSpaceIndentation => 4,
+ _ => throw new NotSupportedException(),
+ };
var serializer
= Serializer.FromValueSerializer(
new SerializerBuilder().BuildValueSerializer(),
@@ -287,7 +279,7 @@ namespace DevToys.ViewModels.Tools.JsonYaml
var deserializer = new Deserializer();
object? yamlObject = deserializer.Deserialize(stringReader);
- if (yamlObject is null || yamlObject is string)
+ if (yamlObject is null or string)
{
output = Strings.InvalidYaml;
return false;
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs
index a06f28ae9..6eaa36199 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolProvider.cs
@@ -1,9 +1,9 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Helpers;
-using System.Composition;
namespace DevToys.ViewModels.Tools.JwtDecoderEncoder
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs
index a9e03bbb7..788ec8312 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/JwtDecoderEncoder/JwtDecoderEncoderToolViewModel.cs
@@ -1,5 +1,10 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.IdentityModel.Tokens.Jwt;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
@@ -7,11 +12,6 @@ using DevToys.Helpers;
using DevToys.Models;
using DevToys.Views.Tools.JwtDecoderEncoder;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.IdentityModel.Tokens.Jwt;
-using System.Threading.Tasks;
namespace DevToys.ViewModels.Tools.JwtDecoderEncoder
{
@@ -85,9 +85,9 @@ namespace DevToys.ViewModels.Tools.JwtDecoderEncoder
await TaskScheduler.Default;
- while (_decodingQueue.TryDequeue(out string text))
+ while (_decodingQueue.TryDequeue(out string? text))
{
- JwtDecode(text, out string header, out string payload);
+ JwtDecode(text, out string? header, out string? payload);
ThreadHelper.RunOnUIThreadAsync(ThreadPriority.Low, () =>
{
JwtHeader = header;
@@ -115,7 +115,7 @@ namespace DevToys.ViewModels.Tools.JwtDecoderEncoder
try
{
- JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
+ var handler = new JwtSecurityTokenHandler();
JwtSecurityToken jwtSecurityToken = handler.ReadJwtToken(input);
header = JsonHelper.Format(jwtSecurityToken.Header.SerializeToJson(), Indentation.TwoSpaces);
payload = JsonHelper.Format(jwtSecurityToken.Payload.SerializeToJson(), Indentation.TwoSpaces);
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolProvider.cs
index 3f28ad64b..1f869877a 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolProvider.cs
@@ -1,9 +1,9 @@
#nullable enable
-using DevToys.Api.Core.Injection;
-using DevToys.Api.Tools;
using System.Composition;
using System.Text.RegularExpressions;
+using DevToys.Api.Core.Injection;
+using DevToys.Api.Tools;
namespace DevToys.ViewModels.Tools.MarkdownPreview
{
@@ -14,7 +14,7 @@ namespace DevToys.ViewModels.Tools.MarkdownPreview
[NotScrollable]
internal sealed class MarkdownPreviewToolProvider : ToolProviderBase, IToolProvider
{
- private static readonly Regex MarkdownLinkDetection = new Regex(@"\[[^]]+\]\(https?:\/\/\S+\)", RegexOptions.Compiled);
+ private static readonly Regex MarkdownLinkDetection = new(@"\[[^]]+\]\(https?:\/\/\S+\)", RegexOptions.Compiled);
private readonly IMefProvider _mefProvider;
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
index e431b1ec1..a836044b2 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/MarkdownPreview/MarkdownPreviewToolViewModel.cs
@@ -1,5 +1,9 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Core.Theme;
@@ -11,10 +15,6 @@ using DevToys.Views.Tools.MarkdownPreview;
using Markdig;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Messaging;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.Storage;
using Windows.UI.Xaml;
@@ -110,9 +110,9 @@ namespace DevToys.ViewModels.Tools.MarkdownPreview
await TaskScheduler.Default;
- while (_workQueue.TryDequeue(out string text))
+ while (_workQueue.TryDequeue(out string? text))
{
- string html = await MarkdownToHtmlPageAsync(text, Theme);
+ string? html = await MarkdownToHtmlPageAsync(text, Theme);
ThreadHelper.RunOnUIThreadAsync(() =>
{
@@ -134,7 +134,7 @@ namespace DevToys.ViewModels.Tools.MarkdownPreview
await TaskScheduler.Default;
MarkdownPipeline pipeline = new MarkdownPipelineBuilder().UseEmojiAndSmiley().UseSmartyPants().UseAdvancedExtensions().Build();
- string htmlBody = Markdown.ToHtml(markdown, pipeline);
+ string? htmlBody = Markdown.ToHtml(markdown, pipeline);
if (string.IsNullOrEmpty(_htmlDocument))
{
@@ -144,7 +144,7 @@ namespace DevToys.ViewModels.Tools.MarkdownPreview
Assumes.NotNullOrEmpty(_htmlDocument, nameof(_htmlDocument));
- string htmlDocument
+ string? htmlDocument
= ((string)_htmlDocument!.Clone())
.Replace("{{renderTheme}}", theme.ToString().ToLower())
.Replace("{{backgroundColor}}", theme == ApplicationTheme.Dark ? "#0d1117" : "#ffffff")
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolProvider.cs
index 3e3a428d9..5f9c1a6e8 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolProvider.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
-using System.Composition;
namespace DevToys.ViewModels.Tools.RegEx
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
index 0a6f34d12..b5cb293e4 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/RegEx/RegExToolViewModel.cs
@@ -1,5 +1,10 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Composition;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
using DevToys.Api.Core;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
@@ -7,11 +12,6 @@ using DevToys.Core.Threading;
using DevToys.UI.Controls;
using DevToys.Views.Tools.RegEx;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Collections.Generic;
-using System.Composition;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
using Windows.UI;
namespace DevToys.ViewModels.Tools.RegEx
@@ -225,7 +225,7 @@ namespace DevToys.ViewModels.Tools.RegEx
try
{
- string pattern = data.pattern.Trim('/');
+ string? pattern = data.pattern.Trim('/');
var regex = new Regex(data.pattern, GetOptions());
MatchCollection matches = regex.Matches(data.text.Replace("\r\n", "\r"));
@@ -248,7 +248,7 @@ namespace DevToys.ViewModels.Tools.RegEx
}
ThreadHelper.RunOnUIThreadAsync(
- ThreadPriority.Low,
+ ThreadPriority.Low,
() =>
{
MatchTextBox?.SetHighlights(spans);
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolProvider.cs
index dbcafd463..a9e615dc6 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolProvider.cs
@@ -1,13 +1,13 @@
#nullable enable
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.AnimatedVisuals;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolViewModel.cs
index 1840e9494..168bf9dff 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/Settings/SettingsToolViewModel.cs
@@ -1,5 +1,11 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Composition;
+using System.Reflection;
+using System.Threading.Tasks;
using DevToys.Api.Core.Navigation;
using DevToys.Api.Core.Settings;
using DevToys.Api.Core.Theme;
@@ -11,12 +17,6 @@ using DevToys.Views.Tools.Settings;
using Microsoft.Graphics.Canvas.Text;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Composition;
-using System.Reflection;
-using System.Threading.Tasks;
using Windows.ApplicationModel;
using Windows.ApplicationModel.DataTransfer;
using Windows.Services.Store;
@@ -99,17 +99,17 @@ namespace DevToys.ViewModels.Settings
{
get
{
- string version = Strings.GetFormattedVersion(typeof(SettingsToolViewModel).GetTypeInfo().Assembly.GetName().Version.ToString());
+ string? version = Strings.GetFormattedVersion(typeof(SettingsToolViewModel).GetTypeInfo().Assembly.GetName().Version.ToString());
- string architecture = Package.Current.Id.Architecture.ToString();
+ string? architecture = Package.Current.Id.Architecture.ToString();
#if DEBUG
- string buildConfiguration = "DEBUG";
+ string? buildConfiguration = "DEBUG";
#else
string buildConfiguration = "RELEASE";
#endif
- string gitBranch = ThisAssembly.Git.Branch;
- string gitCommit = ThisAssembly.Git.Commit;
+ string? gitBranch = ThisAssembly.Git.Branch;
+ string? gitCommit = ThisAssembly.Git.Commit;
return $"{version} | {architecture} | {buildConfiguration} | {gitBranch} | {gitCommit}";
}
@@ -202,7 +202,7 @@ namespace DevToys.ViewModels.Settings
private async Task ExecuteRateAndReviewCommandAsync()
{
- StoreContext storeContext = StoreContext.GetDefault();
+ var storeContext = StoreContext.GetDefault();
StoreRateAndReviewResult result = await ThreadHelper.RunOnUIThreadAsync(async () =>
{
@@ -225,7 +225,7 @@ namespace DevToys.ViewModels.Settings
private void LoadFonts()
{
- string[] systemFonts = CanvasTextFormat.GetSystemFontFamilies();
+ string[]? systemFonts = CanvasTextFormat.GetSystemFontFamilies();
for (int i = 0; i < systemFonts.Length; i++)
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolProvider.cs
index 26648fdf4..33c704dff 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolProvider.cs
@@ -1,10 +1,10 @@
#nullable enable
+using System.Composition;
+using System.Threading.Tasks;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
using DevToys.Core.Threading;
-using System.Composition;
-using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
namespace DevToys.ViewModels.Tools.StringUtilities
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolViewModel.cs
index ecf65fa9a..d7dcb2fde 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/StringUtilities/StringUtilitiesToolViewModel.cs
@@ -1,11 +1,5 @@
#nullable enable
-using DevToys.Api.Core;
-using DevToys.Api.Tools;
-using DevToys.Core.Threading;
-using DevToys.Views.Tools.StringUtilities;
-using Microsoft.Toolkit.Mvvm.ComponentModel;
-using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Composition;
@@ -13,6 +7,12 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using DevToys.Api.Core;
+using DevToys.Api.Tools;
+using DevToys.Core.Threading;
+using DevToys.Views.Tools.StringUtilities;
+using Microsoft.Toolkit.Mvvm.ComponentModel;
+using Microsoft.Toolkit.Mvvm.Input;
namespace DevToys.ViewModels.Tools.StringUtilities
{
@@ -307,7 +307,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
}
var camelCaseStringBuilder = new StringBuilder();
- var nextLetterOrDigitShouldBeUppercase = false;
+ bool nextLetterOrDigitShouldBeUppercase = false;
for (int i = 0; i < text.Length; i++)
{
@@ -361,7 +361,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
}
var pascalCaseStringBuilder = new StringBuilder();
- var nextLetterOrDigitShouldBeUppercase = true;
+ bool nextLetterOrDigitShouldBeUppercase = true;
for (int i = 0; i < text.Length; i++)
{
@@ -410,7 +410,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
return;
}
- var snakeCase = SnakeConstantKebabCobolCaseConverter(text, '_', isUpperCase: false);
+ string? snakeCase = SnakeConstantKebabCobolCaseConverter(text, '_', isUpperCase: false);
lock (_lockObject)
{
@@ -434,7 +434,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
return;
}
- var constantCase = SnakeConstantKebabCobolCaseConverter(text, '_', isUpperCase: true);
+ string? constantCase = SnakeConstantKebabCobolCaseConverter(text, '_', isUpperCase: true);
lock (_lockObject)
{
@@ -458,7 +458,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
return;
}
- var kebabCase = SnakeConstantKebabCobolCaseConverter(text, '-', isUpperCase: false);
+ string? kebabCase = SnakeConstantKebabCobolCaseConverter(text, '-', isUpperCase: false);
lock (_lockObject)
{
@@ -482,7 +482,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
return;
}
- var cobolCase = SnakeConstantKebabCobolCaseConverter(text, '-', isUpperCase: true);
+ string? cobolCase = SnakeConstantKebabCobolCaseConverter(text, '-', isUpperCase: true);
lock (_lockObject)
{
@@ -508,7 +508,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
var snakeCaseStringBuilder = new StringBuilder();
- var nextNonLetterOrDigitShouldBeIgnored = true;
+ bool nextNonLetterOrDigitShouldBeIgnored = true;
for (int i = 0; i < text.Length; i++)
{
char currentChar = text[i];
@@ -629,7 +629,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
{
var snakeCaseStringBuilder = new StringBuilder();
- var nextNonLetterOrDigitShouldBeIgnored = true;
+ bool nextNonLetterOrDigitShouldBeIgnored = true;
for (int i = 0; i < text.Length; i++)
{
char currentChar = text[i];
@@ -691,8 +691,8 @@ namespace DevToys.ViewModels.Tools.StringUtilities
int sentences = 0;
int paragraphs = 1;
int bytes = 0;
- string wordDistribution = string.Empty;
- string characterDistribution = string.Empty;
+ string? wordDistribution = string.Empty;
+ string? characterDistribution = string.Empty;
if (!string.IsNullOrEmpty(text))
{
@@ -708,7 +708,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
// Word distribution
var stringBuilder = new StringBuilder();
- var wordFrequency
+ IOrderedEnumerable<IGrouping<string, Match>>? wordFrequency
= matches
.Where(m => m.Length > 0)
.GroupBy(m => m.Value)
@@ -774,7 +774,7 @@ namespace DevToys.ViewModels.Tools.StringUtilities
// Character distributions
stringBuilder.Clear();
- foreach (var item in characterFrequency.OrderByDescending(m => m.Value).ThenBy(m => m.Key))
+ foreach (KeyValuePair<char, int> item in characterFrequency.OrderByDescending(m => m.Value).ThenBy(m => m.Key))
{
stringBuilder.AppendLine($"{item.Key}: {item.Value}");
}
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolProvider.cs b/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolProvider.cs
index b4fc70535..8319fc2e0 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolProvider.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolProvider.cs
@@ -1,8 +1,8 @@
#nullable enable
+using System.Composition;
using DevToys.Api.Core.Injection;
using DevToys.Api.Tools;
-using System.Composition;
namespace DevToys.ViewModels.Tools.TextDiff
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolViewModel.cs b/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolViewModel.cs
index 097d2e1f5..ccebe11bf 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolViewModel.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/TextDiff/TextDiffToolViewModel.cs
@@ -1,11 +1,11 @@
#nullable enable
+using System;
+using System.Composition;
using DevToys.Api.Core.Settings;
using DevToys.Api.Tools;
using DevToys.Views.Tools.TextDiff;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System;
-using System.Composition;
namespace DevToys.ViewModels.Tools.TextDiff
{
diff --git a/src/dev/impl/DevToys/ViewModels/Tools/ToolProviderBase.cs b/src/dev/impl/DevToys/ViewModels/Tools/ToolProviderBase.cs
index 237494163..c3ddc1de0 100644
--- a/src/dev/impl/DevToys/ViewModels/Tools/ToolProviderBase.cs
+++ b/src/dev/impl/DevToys/ViewModels/Tools/ToolProviderBase.cs
@@ -1,9 +1,9 @@
#nullable enable
+using System.Threading.Tasks;
using DevToys.Core;
using DevToys.Core.Threading;
using Microsoft.Toolkit.Mvvm.ComponentModel;
-using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Markup;
diff --git a/src/dev/impl/DevToys/Views/MainPage.xaml.cs b/src/dev/impl/DevToys/Views/MainPage.xaml.cs
index 3ebe47d0f..b75ee2b33 100644
--- a/src/dev/impl/DevToys/Views/MainPage.xaml.cs
+++ b/src/dev/impl/DevToys/Views/MainPage.xaml.cs
@@ -167,4 +167,4 @@ namespace DevToys.Views
new EntranceNavigationTransitionInfo());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/dev/impl/DevToys/Views/Tools/Settings/MarkdownContentDialog.xaml.cs b/src/dev/impl/DevToys/Views/Tools/Settings/MarkdownContentDialog.xaml.cs
index 49a8b8271..1e4bb888e 100644
--- a/src/dev/impl/DevToys/Views/Tools/Settings/MarkdownContentDialog.xaml.cs
+++ b/src/dev/impl/DevToys/Views/Tools/Settings/MarkdownContentDialog.xaml.cs
@@ -18,7 +18,7 @@ namespace DevToys.Views.Tools.Settings
{
try
{
- string uriToLaunch = e.Link;
+ string? uriToLaunch = e.Link;
var uri = new Uri(uriToLaunch);
await Windows.System.Launcher.LaunchUriAsync(uri);
diff --git a/src/tests/DevToys.Tests/MefBaseTest.cs b/src/tests/DevToys.Tests/MefBaseTest.cs
index 0ce209bdd..ae94c403b 100644
--- a/src/tests/DevToys.Tests/MefBaseTest.cs
+++ b/src/tests/DevToys.Tests/MefBaseTest.cs
@@ -1,6 +1,6 @@
-using DevToys.Api.Core.Injection;
+using System;
+using DevToys.Api.Core.Injection;
using DevToys.Core;
-using System;
namespace DevToys.Tests
{
diff --git a/src/tests/DevToys.Tests/Providers/IToolProviderFactoryTest.cs b/src/tests/DevToys.Tests/Providers/IToolProviderFactoryTest.cs
index 6831a34ef..51a3b2aa7 100644
--- a/src/tests/DevToys.Tests/Providers/IToolProviderFactoryTest.cs
+++ b/src/tests/DevToys.Tests/Providers/IToolProviderFactoryTest.cs
@@ -1,6 +1,6 @@
-using DevToys.Api.Tools;
+using System.Linq;
+using DevToys.Api.Tools;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Linq;
namespace DevToys.Tests.Providers
{
@@ -17,8 +17,8 @@ namespace DevToys.Tests.Providers
[DataRow("ENCODER ", 1)]
public void GetTools(string searchquery, int expectedMatchSpanCount)
{
- var result = ExportProvider.Import<IToolProviderFactory>().GetTools(searchquery);
- var base64Tool = result.First(item => item.Metadata.ProtocolName == "base64");
+ System.Collections.Generic.IEnumerable<MatchedToolProvider> result = ExportProvider.Import<IToolProviderFactory>().GetTools(searchquery);
+ MatchedToolProvider base64Tool = result.First(item => item.Metadata.ProtocolName == "base64");
Assert.AreEqual(expectedMatchSpanCount, base64Tool.MatchedSpans.Length);
}
}
diff --git a/src/tests/DevToys.Tests/Providers/Tools/Base64EncoderDecoderTests.cs b/src/tests/DevToys.Tests/Providers/Tools/Base64EncoderDecoderTests.cs
index 4bc64363b..fb51d559c 100644
--- a/src/tests/DevToys.Tests/Providers/Tools/Base64EncoderDecoderTests.cs
+++ b/src/tests/DevToys.Tests/Providers/Tools/Base64EncoderDecoderTests.cs
@@ -1,9 +1,9 @@
-using DevToys.Api.Tools;
+using System.Linq;
+using System.Threading.Tasks;
+using DevToys.Api.Tools;
using DevToys.Core.Threading;
using DevToys.ViewModels.Tools.Base64EncoderDecoder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Linq;
-using System.Threading.Tasks;
namespace DevToys.Tests.Providers.Tools
{
@@ -20,8 +20,8 @@ namespace DevToys.Tests.Providers.Tools
[DataRow("SGVsbG8gVa29y", false)]
public void CanBeTreatedByTool(string input, bool expectedResult)
{
- var result = ExportProvider.Import<IToolProviderFactory>().GetTools(string.Empty);
- var base64Tool = result.First(item => item.Metadata.ProtocolName == "base64");
+ System.Collections.Generic.IEnumerable<MatchedToolProvider> result = ExportProvider.Import<IToolProviderFactory>().GetTools(string.Empty);
+ MatchedToolProvider base64Tool = result.First(item => item.Metadata.ProtocolName == "base64");
Assert.AreEqual(expectedResult, base64Tool.ToolProvider.CanBeTreatedByTool(input));
}
@@ -33,7 +33,7 @@ namespace DevToys.Tests.Providers.Tools
[DataRow("Hello There", "SGVsbG8gVGhlcmU=")]
public async Task EncoderAsync(string input, string expectedResult)
{
- var viewModel = ExportProvider.Import<Base64EncoderDecoderToolViewModel>();
+ Base64EncoderDecoderToolViewModel viewModel = ExportProvider.Import<Base64EncoderDecoderToolViewModel>();
await ThreadHelper.RunOnUIThreadAsync(() =>
{
@@ -53,7 +53,7 @@ namespace DevToys.Tests.Providers.Tools
[DataRow("SGVsbG8gVGhlcmU=", "Hello There")]
public async Task DecodeAsync(string input, string expectedResult)
{
- var viewModel = ExportProvider.Import<Base64EncoderDecoderToolViewModel>();
+ Base64EncoderDecoderToolViewModel viewModel = ExportProvider.Import<Base64EncoderDecoderToolViewModel>();
await ThreadHelper.RunOnUIThreadAsync(() =>
{
diff --git a/src/tests/DevToys.Tests/Providers/Tools/HashGeneratorTests.cs b/src/tests/DevToys.Tests/Providers/Tools/HashGeneratorTests.cs
index e088906c7..31e426c3b 100644
--- a/src/tests/DevToys.Tests/Providers/Tools/HashGeneratorTests.cs
+++ b/src/tests/DevToys.Tests/Providers/Tools/HashGeneratorTests.cs
@@ -1,7 +1,7 @@
-using DevToys.Core.Threading;
+using System.Threading.Tasks;
+using DevToys.Core.Threading;
using DevToys.ViewModels.Tools.HashGenerator;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Threading.Tasks;
namespace DevToys.Tests.Providers.Tools
{
@@ -15,7 +15,7 @@ namespace DevToys.Tests.Providers.Tools
[DataRow("Hello There", "4313da7166cfbabe16be21f43d5ba8f32ad7e7508a5754843ce6be3be00a24b0962e4b585ec9b8736774fbda649c8671440391705646254b79618b385395be13")]
public async Task LowerCaseHashingAsync(string input, string expectedResult)
{
- var viewModel = ExportProvider.Import<HashGeneratorToolViewModel>();
+ HashGeneratorToolViewModel viewModel = ExportProvider.Import<HashGeneratorToolViewModel>();
await ThreadHelper.RunOnUIThreadAsync(() =>
{
@@ -35,7 +35,7 @@ namespace DevToys.Tests.Providers.Tools
[DataRow("Hello There", "4313DA7166CFBABE16BE21F43D5BA8F32AD7E7508A5754843CE6BE3BE00A24B0962E4B585EC9B8736774FBDA649C8671440391705646254B79618B385395BE13")]
public async Task UpperCaseHashingAsync(string input, string expectedResult)
{
- var viewModel = ExportProvider.Import<HashGeneratorToolViewModel>();
+ HashGeneratorToolViewModel viewModel = ExportProvider.Import<HashGeneratorToolViewModel>();
await ThreadHelper.RunOnUIThreadAsync(() =>
{
diff --git a/src/tests/DevToys.Tests/Providers/Tools/StringUtilitiesTests.cs b/src/tests/DevToys.Tests/Providers/Tools/StringUtilitiesTests.cs
index f12fa50eb..a53925ec7 100644
--- a/src/tests/DevToys.Tests/Providers/Tools/StringUtilitiesTests.cs
+++ b/src/tests/DevToys.Tests/Providers/Tools/StringUtilitiesTests.cs
@@ -1,6 +1,6 @@
-using DevToys.ViewModels.Tools.StringUtilities;
+using System.Threading.Tasks;
+using DevToys.ViewModels.Tools.StringUtilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System.Threading.Tasks;
namespace DevToys.Tests.Providers.Tools
{
@@ -32,7 +32,7 @@ Let's look at these in more detail.";
[TestMethod]
public async Task CalculateSelectionStatisticsAsync()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
viewModel.SelectionStart = 0;
@@ -74,7 +74,7 @@ Let's look at these in more detail.";
[TestMethod]
public async Task CalculateTextStatisticsAsync()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -91,7 +91,7 @@ Let's look at these in more detail.";
[TestMethod]
public void SentenceCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -125,7 +125,7 @@ Let's look at these in more detail.";
[TestMethod]
public void LowerCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -159,7 +159,7 @@ let's look at these in more detail.";
[TestMethod]
public void UpperCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -193,7 +193,7 @@ LET'S LOOK AT THESE IN MORE DETAIL.";
[TestMethod]
public void TitleCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -227,7 +227,7 @@ Let'S Look At These In More Detail.";
[TestMethod]
public void CamelCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -261,7 +261,7 @@ LetSLookAtTheseInMoreDetail";
[TestMethod]
public void PascalCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -295,7 +295,7 @@ LetSLookAtTheseInMoreDetail";
[TestMethod]
public void SnakeCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -329,7 +329,7 @@ let_s_look_at_these_in_more_detail";
[TestMethod]
public void ConstantCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -363,7 +363,7 @@ LET_S_LOOK_AT_THESE_IN_MORE_DETAIL";
[TestMethod]
public void KebabCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -397,7 +397,7 @@ let-s-look-at-these-in-more-detail";
[TestMethod]
public void CobolCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -431,7 +431,7 @@ LET-S-LOOK-AT-THESE-IN-MORE-DETAIL";
[TestMethod]
public void TrainCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -465,7 +465,7 @@ Let-S-Look-At-These-In-More-Detail";
[TestMethod]
public void AlterningCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
@@ -499,7 +499,7 @@ LeT'S LoOk aT ThEsE In mOrE DeTaIl.";
[TestMethod]
public void InverseCase()
{
- var viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
+ StringUtilitiesToolViewModel viewModel = ExportProvider.Import<StringUtilitiesToolViewModel>();
viewModel.Text = Text;
diff --git a/src/tests/DevToys.Tests/UI/ConvertersTests.cs b/src/tests/DevToys.Tests/UI/ConvertersTests.cs
index 63f3adcd7..c644745d7 100644
--- a/src/tests/DevToys.Tests/UI/ConvertersTests.cs
+++ b/src/tests/DevToys.Tests/UI/ConvertersTests.cs
@@ -11,8 +11,10 @@ namespace DevToys.Tests.UI
[TestMethod]
public void BooleanToVisibilityConverterTest()
{
- var converter = new BooleanToVisibilityConverter();
- converter.IsInverted = false;
+ var converter = new BooleanToVisibilityConverter
+ {
+ IsInverted = false
+ };
Assert.AreEqual(Visibility.Visible, converter.Convert(true, typeof(Visibility), null, null));
Assert.AreEqual(Visibility.Collapsed, converter.Convert(false, typeof(Visibility), null, null));
@@ -26,8 +28,10 @@ namespace DevToys.Tests.UI
[TestMethod]
public void NullToBooleanConverterTest()
{
- var converter = new NullToBooleanConverter();
- converter.IsInverted = false;
+ var converter = new NullToBooleanConverter
+ {
+ IsInverted = false
+ };
Assert.IsTrue((bool)converter.Convert(null, typeof(bool), null, null));
Assert.IsFalse((bool)converter.Convert(1, typeof(bool), null, null));
@@ -51,9 +55,11 @@ namespace DevToys.Tests.UI
[TestMethod]
public void EnumToThicknessConverterTest()
{
- var converter = new EnumToThicknessConverter();
- converter.ThicknessOnEnumDetected = new Thickness(10);
- converter.ThicknessOnEnumNotDetected = new Thickness(0);
+ var converter = new EnumToThicknessConverter
+ {
+ ThicknessOnEnumDetected = new Thickness(10),
+ ThicknessOnEnumNotDetected = new Thickness(0)
+ };
Assert.AreEqual(converter.ThicknessOnEnumNotDetected, converter.Convert(null, null, "foo", null));
Assert.AreEqual(converter.ThicknessOnEnumNotDetected, converter.Convert(AppBarClosedDisplayMode.Compact, null, null, null));
diff --git a/src/tests/DevToys.Tests/UnitTestApp.xaml.cs b/src/tests/DevToys.Tests/UnitTestApp.xaml.cs
index f847904b6..bea5fdf5f 100644
--- a/src/tests/DevToys.Tests/UnitTestApp.xaml.cs
+++ b/src/tests/DevToys.Tests/UnitTestApp.xaml.cs
@@ -83,7 +83,7 @@ namespace DevToys.Tests
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
- var deferral = e.SuspendingOperation.GetDeferral();
+ SuspendingDeferral deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}