From 1e45b8ad611c3d6b6cd17b283da0a4b8b862a3a6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 21:43:34 -0700 Subject: [PATCH 01/31] Update Directory.Build.props to enable all analyzers --- Directory.Build.props | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index d1fa1a9e..972572ee 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,13 @@ Enable the latest warning wave, which shows additional warnings for invalid language features that are disabled by default. For additional info, see https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/warning-waves. --> - 7 + latest + + + latest-all + + + true strict + + true + $(NoWarn);CS8500 + + + true \ No newline at end of file From 3aff2446c72e1228d68fb5b855177b3a5fe27bc7 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 21:43:45 -0700 Subject: [PATCH 02/31] Port .editorconfig and .globalconfig from ComputeSharp --- .editorconfig | 262 ++++++++++++++++++++++++++++++++++++++++++++++++++ .globalconfig | 91 ++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 .editorconfig create mode 100644 .globalconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..bcfa1529 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,262 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# All files +[*] + +#### Core EditorConfig Options #### + +# Encoding +charset = utf-8 + +# Indentation and spacing +tab_width = 4 +indent_size = 4 +indent_style = space + +# New line preferences +end_of_line = lf +insert_final_newline = false +trim_trailing_whitespace = true + +#### Build files #### + +# Solution files +[*.{sln,slnx}] +tab_width = 4 +indent_size = 4 +indent_style = tab + +# Configuration files +[*.{json,xml,yml,config,runsettings}] +indent_size = 2 + +# MSBuild files +[*.{slnf,props,targets,projitems,csproj,shproj}] +indent_size = 2 + +#### Source files #### + +# Markdown files +[*.md] +indent_size = 2 +insert_final_newline = true + +# XAML files +[*.xaml] +indent_size = 4 + +## T4 files (these need CRLT of the T4 generator will add unwanted newlines) +[*.{tt,ttinclude}] +end_of_line = crlf + +# C# files +[*.cs] + +#### .NET Coding Conventions #### + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:warning +dotnet_style_qualification_for_field = true:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_property = false:warning + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:warning +dotnet_style_predefined_type_for_member_access = true:warning + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning + +# Modifier preferences (set to silent until https://github.com/dotnet/roslyn/issues/52904 is resolved) +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Code block preferences +dotnet_style_allow_multiple_blank_lines_experimental = false:warning +dotnet_style_allow_statement_immediately_after_block_experimental = false:warning + +# Expression-level preferences +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:warning +csharp_style_throw_expression = true:suggestion +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_object_initializer = 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 +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:warning +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning +csharp_style_implicit_object_creation_when_type_is_apparent = true:warning + +# Field preferences +dotnet_style_readonly_field = true:warning + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:warning +csharp_style_var_for_built_in_types = false:warning +csharp_style_var_when_type_is_apparent = false:warning + +# Expression-bodied members +csharp_style_expression_bodied_accessors = when_on_single_line:warning +csharp_style_expression_bodied_constructors = false:warning +csharp_style_expression_bodied_indexers = when_on_single_line:warning +csharp_style_expression_bodied_lambdas = when_on_single_line:warning +csharp_style_expression_bodied_methods = false:warning +csharp_style_expression_bodied_operators = when_on_single_line:warning +csharp_style_expression_bodied_properties = when_on_single_line:warning + +# Pattern matching preferences +csharp_style_prefer_pattern_matching = true:suggestion +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Code-block preferences +csharp_prefer_braces = true:suggestion +csharp_using_directive_placement = outside_namespace:warning +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_unused_value_assignment_preference = discard_variable:warning +csharp_style_unused_value_expression_statement_preference = discard_variable:warning +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:warning + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_prefer_static_local_function = true:warning +csharp_style_pattern_local_over_anonymous_function = true:warning + +#### C# Formatting Rules #### + +# New line preferences +csharp_new_line_before_catch = true +csharp_new_line_before_else = true +csharp_new_line_before_finally = true +csharp_new_line_before_members_in_anonymous_types = true +csharp_new_line_before_members_in_object_initializers = true +csharp_new_line_before_open_brace = all +csharp_new_line_between_query_expression_clauses = true + +# Indentation preferences +csharp_indent_block_contents = true +csharp_indent_braces = false +csharp_indent_case_contents = true +csharp_indent_case_contents_when_block = false +csharp_indent_labels = no_change +csharp_indent_switch_labels = true + +# Space preferences +csharp_space_after_cast = false +csharp_space_after_colon_in_inheritance_clause = true +csharp_space_after_comma = true +csharp_space_after_dot = false +csharp_space_after_keywords_in_control_flow_statements = true +csharp_space_after_semicolon_in_for_statement = true +csharp_space_around_binary_operators = before_and_after +csharp_space_around_declaration_statements = false +csharp_space_before_colon_in_inheritance_clause = true +csharp_space_before_comma = false +csharp_space_before_dot = false +csharp_space_before_open_square_brackets = false +csharp_space_before_semicolon_in_for_statement = false +csharp_space_between_empty_square_brackets = false +csharp_space_between_method_call_empty_parameter_list_parentheses = false +csharp_space_between_method_call_name_and_opening_parenthesis = false +csharp_space_between_method_call_parameter_list_parentheses = false +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +csharp_space_between_method_declaration_name_and_open_parenthesis = false +csharp_space_between_method_declaration_parameter_list_parentheses = false +csharp_space_between_parentheses = false +csharp_space_between_square_brackets = false + +# Wrapping preferences +csharp_preserve_single_line_blocks = true +csharp_preserve_single_line_statements = true + +# Naming Symbols + +# constant_fields - Define constant fields +dotnet_naming_symbols.constant_fields.applicable_accessibilities = * +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const +# static_readonly_fields - Define all static readonly fields +dotnet_naming_symbols.static_readonly_fields.applicable_accessibilities = * +dotnet_naming_symbols.static_readonly_fields.applicable_kinds = field +dotnet_naming_symbols.static_readonly_fields.required_modifiers = static, readonly +# non_private_fields - Define all fields that are not private +dotnet_naming_symbols.non_private_fields.applicable_accessibilities = public, internal, protected, protected_internal, private_protected +dotnet_naming_symbols.non_private_fields.applicable_kinds = field +# private_fields - Define all private fields +dotnet_naming_symbols.private_fields.applicable_accessibilities = private +dotnet_naming_symbols.private_fields.applicable_kinds = field +# public_symbols - Define any public symbol +dotnet_naming_symbols.public_symbols.applicable_accessibilities = * +dotnet_naming_symbols.public_symbols.applicable_kinds = method, property, event, delegate, class, struct, enum, delegate +# parameters - Defines any parameter +dotnet_naming_symbols.parameters.applicable_accessibilities = * +dotnet_naming_symbols.parameters.applicable_kinds = parameter +# interface_types - Defines interfaces +dotnet_naming_symbols.interface_types.applicable_accessibilities = * +dotnet_naming_symbols.interface_types.applicable_kinds = interface + +# Naming Styles + +# camel_case - Define the camelCase style +dotnet_naming_style.camel_case.capitalization = camel_case +# pascal_case - Define the PascalCase style +dotnet_naming_style.pascal_case.capitalization = pascal_case +# prefix_interface_interface_with_i - Interfaces must be PascalCase and the first character of an interface must be an 'I' +dotnet_naming_style.prefix_interface_interface_with_i.capitalization = pascal_case +dotnet_naming_style.prefix_interface_interface_with_i.required_prefix = I + +# Naming Rules + +# Async methods should have the "Async" suffix (disabled because it can't currently exclude async void methods) +dotnet_naming_rule.async_methods_end_in_async.severity = none +dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods +dotnet_naming_rule.async_methods_end_in_async.style = end_in_async + +dotnet_naming_symbols.any_async_methods.applicable_kinds = method +dotnet_naming_symbols.any_async_methods.applicable_accessibilities = * +dotnet_naming_symbols.any_async_methods.required_modifiers = async + +dotnet_naming_style.end_in_async.required_suffix = Async +dotnet_naming_style.end_in_async.capitalization = pascal_case + +# Private fields must be camelCase +dotnet_naming_rule.private_fields_must_be_pascal_case.severity = warning +dotnet_naming_rule.private_fields_must_be_pascal_case.symbols = private_fields +dotnet_naming_rule.private_fields_must_be_pascal_case.style = camel_case +# Constant fields must be PascalCase +dotnet_naming_rule.constant_fields_must_be_pascal_case.severity = warning +dotnet_naming_rule.constant_fields_must_be_pascal_case.symbols = constant_fields +dotnet_naming_rule.constant_fields_must_be_pascal_case.style = pascal_case +# Static readonly fields must be PascalCase +dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.severity = warning +dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.symbols = static_readonly_fields +dotnet_naming_rule.static_readonly_fields_must_be_pascal_case.style = pascal_case +# Non private fields must be PascalCase +dotnet_naming_rule.non_private_fields_must_be_pascal_case.severity = warning +dotnet_naming_rule.non_private_fields_must_be_pascal_case.symbols = non_private_fields +dotnet_naming_rule.non_private_fields_must_be_pascal_case.style = pascal_case +# Public symbols must be capitalized +dotnet_naming_rule.public_symbols_must_be_capitalized.severity = warning +dotnet_naming_rule.public_symbols_must_be_capitalized.symbols = public_symbols +dotnet_naming_rule.public_symbols_must_be_capitalized.style = pascal_case +# Parameters must be camelCase (ignored because some use PascalCase to match Win32 parameter names) +dotnet_naming_rule.parameters_must_be_camel_case.severity = none +dotnet_naming_rule.parameters_must_be_camel_case.symbols = parameters +dotnet_naming_rule.parameters_must_be_camel_case.style = camel_case +# Interfaces must be PascalCase and start with an 'I' +dotnet_naming_rule.interface_types_must_be_prefixed_with_i.severity = warning +dotnet_naming_rule.interface_types_must_be_prefixed_with_i.symbols = interface_types +dotnet_naming_rule.interface_types_must_be_prefixed_with_i.style = prefix_interface_interface_with_i diff --git a/.globalconfig b/.globalconfig new file mode 100644 index 00000000..06d62109 --- /dev/null +++ b/.globalconfig @@ -0,0 +1,91 @@ +is_global = true + +# .NET Code Analysis + +dotnet_diagnostic.CA1001.severity = warning +dotnet_diagnostic.CA1009.severity = warning +dotnet_diagnostic.CA1016.severity = warning +dotnet_diagnostic.CA1033.severity = warning +dotnet_diagnostic.CA1049.severity = warning +dotnet_diagnostic.CA1060.severity = warning +dotnet_diagnostic.CA1061.severity = warning +dotnet_diagnostic.CA1063.severity = warning +dotnet_diagnostic.CA1065.severity = warning +dotnet_diagnostic.CA1301.severity = warning +dotnet_diagnostic.CA1400.severity = warning +dotnet_diagnostic.CA1401.severity = warning +dotnet_diagnostic.CA1403.severity = warning +dotnet_diagnostic.CA1404.severity = warning +dotnet_diagnostic.CA1405.severity = warning +dotnet_diagnostic.CA1410.severity = warning +dotnet_diagnostic.CA1415.severity = warning +dotnet_diagnostic.CA1821.severity = warning +dotnet_diagnostic.CA1900.severity = warning +dotnet_diagnostic.CA1901.severity = warning +dotnet_diagnostic.CA2002.severity = warning +dotnet_diagnostic.CA2100.severity = warning +dotnet_diagnostic.CA2101.severity = warning +dotnet_diagnostic.CA2108.severity = warning +dotnet_diagnostic.CA2111.severity = warning +dotnet_diagnostic.CA2112.severity = warning +dotnet_diagnostic.CA2114.severity = warning +dotnet_diagnostic.CA2116.severity = warning +dotnet_diagnostic.CA2117.severity = warning +dotnet_diagnostic.CA2122.severity = warning +dotnet_diagnostic.CA2123.severity = warning +dotnet_diagnostic.CA2124.severity = warning +dotnet_diagnostic.CA2126.severity = warning +dotnet_diagnostic.CA2131.severity = warning +dotnet_diagnostic.CA2132.severity = warning +dotnet_diagnostic.CA2133.severity = warning +dotnet_diagnostic.CA2134.severity = warning +dotnet_diagnostic.CA2137.severity = warning +dotnet_diagnostic.CA2138.severity = warning +dotnet_diagnostic.CA2140.severity = warning +dotnet_diagnostic.CA2141.severity = warning +dotnet_diagnostic.CA2146.severity = warning +dotnet_diagnostic.CA2147.severity = warning +dotnet_diagnostic.CA2149.severity = warning +dotnet_diagnostic.CA2200.severity = warning +dotnet_diagnostic.CA2202.severity = warning +dotnet_diagnostic.CA2207.severity = warning +dotnet_diagnostic.CA2212.severity = warning +dotnet_diagnostic.CA2213.severity = warning +dotnet_diagnostic.CA2214.severity = warning +dotnet_diagnostic.CA2216.severity = warning +dotnet_diagnostic.CA2220.severity = warning +dotnet_diagnostic.CA2229.severity = warning +dotnet_diagnostic.CA2231.severity = warning +dotnet_diagnostic.CA2232.severity = warning +dotnet_diagnostic.CA2235.severity = warning +dotnet_diagnostic.CA2236.severity = warning +dotnet_diagnostic.CA2237.severity = warning +dotnet_diagnostic.CA2238.severity = warning +dotnet_diagnostic.CA2240.severity = warning +dotnet_diagnostic.CA2241.severity = warning +dotnet_diagnostic.CA2242.severity = warning + +## CodeStyle Code Analysis + +dotnet_diagnostic.IDE0010.severity = none +dotnet_diagnostic.IDE0130.severity = none +dotnet_diagnostic.IDE0060.severity = none +dotnet_diagnostic.IDE1006.severity = warning +dotnet_diagnostic.IDE0023.severity = none +dotnet_diagnostic.IDE0024.severity = none +dotnet_diagnostic.IDE0060.severity = none +dotnet_diagnostic.IDE0057.severity = none +dotnet_diagnostic.IDE0046.severity = none +dotnet_diagnostic.IDE0072.severity = none +dotnet_diagnostic.IDE0064.severity = none +dotnet_diagnostic.IDE0160.severity = none +dotnet_diagnostic.IDE0040.severity = none +dotnet_diagnostic.IDE0045.severity = none +dotnet_diagnostic.IDE0032.severity = none +dotnet_diagnostic.IDE0056.severity = none +dotnet_diagnostic.IDE0032.severity = none +dotnet_diagnostic.IDE0042.severity = none +dotnet_diagnostic.IDE0180.severity = none +dotnet_diagnostic.IDE0061.severity = none +dotnet_diagnostic.IDE0078.severity = none +dotnet_diagnostic.IDE0066.severity = none From 7183ef482a73d48ac6b9b8fce00271bb7004ec54 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 21:45:01 -0700 Subject: [PATCH 03/31] Fix IDE0009 (use 'this.' prefix) --- .../Brainf_ckBenchmark.cs | 12 +- src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs | 14 +- .../Analytics/AppCenterService.cs | 2 +- .../KeyboardListenerService.cs | 4 +- .../SettingsService.cs | 8 +- .../ShareService.cs | 20 +-- .../Store/ProductionStoreService.cs | 4 +- .../Models/Console/ConsoleCommand.cs | 8 +- .../Controls/Brainf_ckMemoryCellChunk.cs | 38 +++--- .../Controls/CompactMemoryViewerViewModel.cs | 4 +- .../ViewModels/Controls/StatusBarViewModel.cs | 46 +++---- .../Controls/StdinHeaderViewModel.cs | 8 +- .../SubPages/AboutSubPageViewModel.cs | 4 +- .../SubPages/CodeLibrarySubPageViewModel.cs | 46 +++---- .../SubPages/IdeResultSubPageViewModel.cs | 46 +++---- .../SubPages/ReviewPromptSubPageViewModel.cs | 18 +-- .../Abstract/SettingsSectionViewModelBase.cs | 6 +- .../Sections/IdeSettingsSectionViewModel.cs | 36 ++--- .../InterpreterSettingsSectionViewModel.cs | 14 +- .../Sections/UISettingsSectionViewModel.cs | 12 +- .../Controls/VirtualKeyboardViewModel.cs | 6 +- .../ViewModels/ShellViewModel.cs | 50 +++---- .../Views/Abstract/WorkspaceViewModelBase.cs | 26 ++-- .../ViewModels/Views/ConsoleViewModel.cs | 36 ++--- .../ViewModels/Views/IdeViewModel.cs | 56 ++++---- .../Brainf_ckEditBox.Events.cs | 2 +- .../Brainf_ckEditBox.Flyout.ICommand.cs | 4 +- .../Brainf_ckEditBox.Formatting.Lock.cs | 20 +-- .../Brainf_ckEditBox.Formatting.cs | 16 +-- .../Brainf_ckEditBox.Properties.cs | 4 +- .../Brainf_ckEditBox.Template.cs | 64 ++++----- .../Brainf_ckEditBox.Win2D.cs | 66 ++++----- .../Brainf_ckEditBox/Brainf_ckEditBox.cs | 42 +++--- .../Models/BracketsPairInfo.cs | 4 +- .../Models/ColumnGuideInfo.cs | 6 +- .../Brainf_ckIde/Brainf_ckIde.xaml.Methods.cs | 36 ++--- .../Brainf_ckIde.xaml.Properties.cs | 30 ++-- .../Brainf_ckIde.xaml.Win2D.Draw.cs | 8 +- .../Brainf_ckIde.xaml.Win2D.Load.cs | 38 +++--- .../Brainf_ckIde/Brainf_ckIde.xaml.cs | 52 +++---- .../Brainf_ckTheme.cs | 10 +- src/Brainf_ckSharp.Uwp/App.xaml.cs | 14 +- .../Behaviors/LockedPivotBehavior.cs | 24 ++-- .../DataTemplates/DeveloperTemplate.xaml.cs | 2 +- ...SemanticZoomZoomedOutViewHeaderTemplate.cs | 6 +- .../Controls/Host/Header/HeaderButton.cs | 4 +- .../InputPanel/Header/MinimalHeaderButton.cs | 4 +- .../Controls/Host/Shell.xaml.cs | 8 +- .../SubPages/Host/SubPageHost.xaml.cs | 58 ++++---- .../Templates/CodeSampleTemplate.xaml.cs | 4 +- .../Templates/OperatorInfoTemplate.xaml.cs | 12 +- .../Helpers/TimelineService.cs | 14 +- .../Views/ConsoleView.xaml.cs | 4 +- src/Brainf_ckSharp.Uwp/Views/IdeView.xaml.cs | 32 ++--- src/Brainf_ckSharp/Buffers/StdinBuffer.cs | 30 ++-- src/Brainf_ckSharp/Buffers/StdoutBuffer.cs | 30 ++-- .../Configurations/Configuration.Debug.cs | 24 ++-- .../Configurations/Configuration.Release.cs | 20 +-- .../IReadOnlyMachineState.Enumerator.cs | 14 +- .../TuringMachineState.ExecutionSession.cs | 10 +- .../Memory/TuringMachineState.cs | 56 ++++---- .../Models/Brainf_ckMemoryCell.cs | 10 +- src/Brainf_ckSharp/Models/Internal/Range.cs | 6 +- .../Models/Internal/StackFrame.cs | 6 +- .../Models/Internal/Timestamp.cs | 4 +- .../Models/InterpreterSession.cs | 128 +++++++++--------- .../UnauthenticatedHttpClientHandler.cs | 4 +- 67 files changed, 727 insertions(+), 727 deletions(-) diff --git a/profiling/Brainf_ckSharp.Profiler/Brainf_ckBenchmark.cs b/profiling/Brainf_ckSharp.Profiler/Brainf_ckBenchmark.cs index e5defd71..f6da3947 100644 --- a/profiling/Brainf_ckSharp.Profiler/Brainf_ckBenchmark.cs +++ b/profiling/Brainf_ckSharp.Profiler/Brainf_ckBenchmark.cs @@ -30,7 +30,7 @@ public void Setup() { TriggerTier1Jit(); - Script = ScriptLoader.LoadScriptByName(Name!); + this.Script = ScriptLoader.LoadScriptByName(Name!); } /// @@ -38,7 +38,7 @@ public void Setup() /// private void TriggerTier1Jit() { - Script = ScriptLoader.LoadScriptByName("HelloWorld"); + this.Script = ScriptLoader.LoadScriptByName("HelloWorld"); for (int i = 0; i < 1000; i++) { @@ -56,10 +56,10 @@ public string RunScript() { Option result = Brainf_ckInterpreter .CreateReleaseConfiguration() - .WithSource(Script!.Source) - .WithStdin(Script.Stdin) - .WithMemorySize(Script.MemorySize) - .WithOverflowMode(Script.OverflowMode) + .WithSource(this.Script!.Source) + .WithStdin(this.Script.Stdin) + .WithMemorySize(this.Script.MemorySize) + .WithOverflowMode(this.Script.OverflowMode) .TryRun(); result.Value!.MachineState.Dispose(); diff --git a/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs b/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs index 63e7863e..009fd459 100644 --- a/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs +++ b/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs @@ -32,7 +32,7 @@ namespace Brainf_ckSharp.Git.Buffers; /// private Pool() { - var items = _Items = new T[MinimumPoolSize]; + var items = this._Items = new T[MinimumPoolSize]; ref T r0 = ref items.DangerousGetReference(); @@ -56,12 +56,12 @@ private Pool() public T Rent() { // Expand the current pool, if needed - if (_Offset == _Items.Length) + if (this._Offset == this._Items.Length) { ExpandBuffer(); } - return _Items.DangerousGetReferenceAt(_Offset++); + return this._Items.DangerousGetReferenceAt(this._Offset++); } /// @@ -70,18 +70,18 @@ public T Rent() [MethodImpl(MethodImplOptions.NoInlining)] private void ExpandBuffer() { - T[] oldItems = _Items; + T[] oldItems = this._Items; T[] newItems = new T[oldItems.Length * 2]; // Copy over the previous elements oldItems.AsSpan().CopyTo(newItems); - _Items = newItems; + this._Items = newItems; ref T r0 = ref newItems.DangerousGetReference(); int end = newItems.Length; - for (int i = _Offset; i < end; i++) + for (int i = this._Offset; i < end; i++) { Unsafe.Add(ref r0, i) = new T(); } @@ -92,5 +92,5 @@ private void ExpandBuffer() /// /// This can cause previously rented objects to be reused [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Reset() => _Offset = 0; + public void Reset() => this._Offset = 0; } diff --git a/src/Brainf_ckSharp.Services.Uwp/Analytics/AppCenterService.cs b/src/Brainf_ckSharp.Services.Uwp/Analytics/AppCenterService.cs index 661ee9a7..2db8deea 100644 --- a/src/Brainf_ckSharp.Services.Uwp/Analytics/AppCenterService.cs +++ b/src/Brainf_ckSharp.Services.Uwp/Analytics/AppCenterService.cs @@ -22,7 +22,7 @@ public sealed class AppCenterService : IAnalyticsService /// public void Initialize(string secret) { - if (Interlocked.CompareExchange(ref _IsInitialized, 1, 0) != 0) + if (Interlocked.CompareExchange(ref this._IsInitialized, 1, 0) != 0) { ThrowHelper.ThrowInvalidOperationException("The service has already been initialized"); } diff --git a/src/Brainf_ckSharp.Services.Uwp/KeyboardListenerService.cs b/src/Brainf_ckSharp.Services.Uwp/KeyboardListenerService.cs index 6ac09301..d3c68e60 100644 --- a/src/Brainf_ckSharp.Services.Uwp/KeyboardListenerService.cs +++ b/src/Brainf_ckSharp.Services.Uwp/KeyboardListenerService.cs @@ -27,7 +27,7 @@ event Action IKeyboardListenerService.CharacterReceived { add { - lock (Lock) + lock (this.Lock) { if (CharacterReceived is null) { @@ -39,7 +39,7 @@ event Action IKeyboardListenerService.CharacterReceived } remove { - lock (Lock) + lock (this.Lock) { CharacterReceived -= value; diff --git a/src/Brainf_ckSharp.Services.Uwp/SettingsService.cs b/src/Brainf_ckSharp.Services.Uwp/SettingsService.cs index 5aff8c9c..142b46fd 100644 --- a/src/Brainf_ckSharp.Services.Uwp/SettingsService.cs +++ b/src/Brainf_ckSharp.Services.Uwp/SettingsService.cs @@ -43,15 +43,15 @@ public void SetValue(string key, T value, bool overwrite = true) } // Store the new value - if (!SettingsStorage.ContainsKey(key)) SettingsStorage.Add(key, serializable); - else if (overwrite) SettingsStorage[key] = serializable; + if (!this.SettingsStorage.ContainsKey(key)) this.SettingsStorage.Add(key, serializable); + else if (overwrite) this.SettingsStorage[key] = serializable; } /// public T GetValue(string key, bool fallback = false) { // Try to get the setting value - if (!SettingsStorage.TryGetValue(key, out object value)) + if (!this.SettingsStorage.TryGetValue(key, out object value)) { if (fallback) return default!; @@ -65,5 +65,5 @@ public T GetValue(string key, bool fallback = false) } /// - public void Clear() => SettingsStorage.Clear(); + public void Clear() => this.SettingsStorage.Clear(); } diff --git a/src/Brainf_ckSharp.Services.Uwp/ShareService.cs b/src/Brainf_ckSharp.Services.Uwp/ShareService.cs index 41afd6f4..1985cb7c 100644 --- a/src/Brainf_ckSharp.Services.Uwp/ShareService.cs +++ b/src/Brainf_ckSharp.Services.Uwp/ShareService.cs @@ -26,10 +26,10 @@ public sealed class ShareService : IShareService private void InitializeDataTransferManager() { - if (_DataTransferManager is not null) return; + if (this._DataTransferManager is not null) return; - _DataTransferManager = DataTransferManager.GetForCurrentView(); - _DataTransferManager.DataRequested += DataTransferManager_DataRequested; + this._DataTransferManager = DataTransferManager.GetForCurrentView(); + this._DataTransferManager.DataRequested += DataTransferManager_DataRequested; } /// @@ -40,25 +40,25 @@ private void InitializeDataTransferManager() private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args) { // Make sure there is some content to share - if (_Info == null) ThrowHelper.ThrowInvalidOperationException("There isn't a valid content to share"); + if (this._Info == null) ThrowHelper.ThrowInvalidOperationException("There isn't a valid content to share"); DataRequest request = args.Request; // Set the data to share - request.Data.Properties.Title = _Info.Title; + request.Data.Properties.Title = this._Info.Title; request.Data.Properties.Description = "Shared from Brainf*ck#"; - switch (_Info) + switch (this._Info) { case FileShareInfo fileShare: request.Data.SetStorageItems(new [] { fileShare.File }, true); break; default: - ThrowHelper.ThrowArgumentException(nameof(_Info), "Invalid share info type"); + ThrowHelper.ThrowArgumentException(nameof(this._Info), "Invalid share info type"); break; } - _Info = null; + this._Info = null; } /// @@ -70,7 +70,7 @@ public void Share(string title, IFile file) InitializeDataTransferManager(); - _Info = new FileShareInfo(title, storageFile); + this._Info = new FileShareInfo(title, storageFile); try { @@ -79,7 +79,7 @@ public void Share(string title, IFile file) catch (COMException) { // Busy application: there is another pending share request - _Info = null; + this._Info = null; } } diff --git a/src/Brainf_ckSharp.Services.Uwp/Store/ProductionStoreService.cs b/src/Brainf_ckSharp.Services.Uwp/Store/ProductionStoreService.cs index 71bf8e7c..8a2ecc9c 100644 --- a/src/Brainf_ckSharp.Services.Uwp/Store/ProductionStoreService.cs +++ b/src/Brainf_ckSharp.Services.Uwp/Store/ProductionStoreService.cs @@ -25,7 +25,7 @@ public Task RequestReviewAsync() /// public async Task IsProductPurchasedAsync(string id) { - if (await StoreContext.GetAppLicenseAsync() is not StoreAppLicense license) return false; + if (await this.StoreContext.GetAppLicenseAsync() is not StoreAppLicense license) return false; return license.AddOnLicenses .FirstOrDefault(pair => pair.Value.InAppOfferToken.Equals(id)) @@ -38,7 +38,7 @@ public async Task TryPurchaseProductAsync(string id) try { - var result = await StoreContext.RequestPurchaseAsync(id); + var result = await this.StoreContext.RequestPurchaseAsync(id); return result.Status switch { diff --git a/src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs b/src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs index c6e355c2..3003c57b 100644 --- a/src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs +++ b/src/Brainf_ckSharp.Shared/Models/Console/ConsoleCommand.cs @@ -15,8 +15,8 @@ public sealed class ConsoleCommand : ObservableObject, IConsoleEntry /// public string Command { - get => _Command; - set => SetProperty(ref _Command, value); + get => this._Command; + set => SetProperty(ref this._Command, value); } private bool _IsActive = true; @@ -26,7 +26,7 @@ public string Command /// public bool IsActive { - get => _IsActive; - set => SetProperty(ref _IsActive, value); + get => this._IsActive; + set => SetProperty(ref this._IsActive, value); } } diff --git a/src/Brainf_ckSharp.Shared/Models/Console/Controls/Brainf_ckMemoryCellChunk.cs b/src/Brainf_ckSharp.Shared/Models/Console/Controls/Brainf_ckMemoryCellChunk.cs index 6413cc64..4c086c70 100644 --- a/src/Brainf_ckSharp.Shared/Models/Console/Controls/Brainf_ckMemoryCellChunk.cs +++ b/src/Brainf_ckSharp.Shared/Models/Console/Controls/Brainf_ckMemoryCellChunk.cs @@ -19,12 +19,12 @@ public Brainf_ckMemoryCellChunk(IReadOnlyMachineState state, int offset) { BaseOffset = offset; - _Zero = state[BaseOffset]; - _One = state[BaseOffset + 1]; - _Two = state[BaseOffset + 2]; - _Three = state[BaseOffset + 3]; + this._Zero = state[BaseOffset]; + this._One = state[BaseOffset + 1]; + this._Two = state[BaseOffset + 2]; + this._Three = state[BaseOffset + 3]; - _SelectedIndex = state.Position; + this._SelectedIndex = state.Position; } private Brainf_ckMemoryCell _Zero; @@ -34,8 +34,8 @@ public Brainf_ckMemoryCellChunk(IReadOnlyMachineState state, int offset) /// public Brainf_ckMemoryCell Zero { - get => _Zero; - set => SetProperty(ref _Zero, value); + get => this._Zero; + set => SetProperty(ref this._Zero, value); } private Brainf_ckMemoryCell _One; @@ -45,8 +45,8 @@ public Brainf_ckMemoryCell Zero /// public Brainf_ckMemoryCell One { - get => _One; - set => SetProperty(ref _One, value); + get => this._One; + set => SetProperty(ref this._One, value); } private Brainf_ckMemoryCell _Two; @@ -56,8 +56,8 @@ public Brainf_ckMemoryCell One /// public Brainf_ckMemoryCell Two { - get => _Two; - set => SetProperty(ref _Two, value); + get => this._Two; + set => SetProperty(ref this._Two, value); } private Brainf_ckMemoryCell _Three; @@ -67,8 +67,8 @@ public Brainf_ckMemoryCell Two /// public Brainf_ckMemoryCell Three { - get => _Three; - set => SetProperty(ref _Three, value); + get => this._Three; + set => SetProperty(ref this._Three, value); } /// @@ -79,10 +79,10 @@ public Brainf_ckMemoryCell Three /// /// Gets whether or not the current position is within the current chunk /// - public bool IsChunkSelected => _Zero.IsSelected || - _One.IsSelected || - _Two.IsSelected || - _Three.IsSelected; + public bool IsChunkSelected => this._Zero.IsSelected || + this._One.IsSelected || + this._Two.IsSelected || + this._Three.IsSelected; private int _SelectedIndex; @@ -94,7 +94,7 @@ public int SelectedIndex { get { - int index = _SelectedIndex - BaseOffset; + int index = this._SelectedIndex - BaseOffset; if (index > 3) return 3; if (index < 0) return 0; @@ -119,7 +119,7 @@ public void UpdateFromState(IReadOnlyMachineState state) Two = state[BaseOffset + 2]; Three = state[BaseOffset + 3]; - _SelectedIndex = state.Position; + this._SelectedIndex = state.Position; OnPropertyChanged(nameof(IsChunkSelected)); OnPropertyChanged(nameof(SelectedIndex)); diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/CompactMemoryViewerViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/CompactMemoryViewerViewModel.cs index 640a3c22..598143c2 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/CompactMemoryViewerViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/CompactMemoryViewerViewModel.cs @@ -43,10 +43,10 @@ protected override void OnActivated() /// public IReadOnlyMachineState? MachineState { - get => _MachineState; + get => this._MachineState; set { - if (SetProperty(ref _MachineState, value)) + if (SetProperty(ref this._MachineState, value)) { UpdateFromState(value); } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs index 7f9bcfbe..8492f972 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs @@ -65,9 +65,9 @@ public sealed class StatusBarViewModel : ObservableRecipient public StatusBarViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger) { - SettingsService = settingsService; - Context = SynchronizationContext.Current; - Timer = new Timer(vm => ((StatusBarViewModel)vm).RunBackgroundCode(), this, default, TimeSpan.FromSeconds(2)); + this.SettingsService = settingsService; + this.Context = SynchronizationContext.Current; + this.Timer = new Timer(vm => ((StatusBarViewModel)vm).RunBackgroundCode(), this, default, TimeSpan.FromSeconds(2)); } /// @@ -83,12 +83,12 @@ protected override void OnActivated() /// public Option? BackgroundExecutionResult { - get => _BackgroundExecutionResult; + get => this._BackgroundExecutionResult; private set { - _BackgroundExecutionResult?.Value?.MachineState.Dispose(); + this._BackgroundExecutionResult?.Value?.MachineState.Dispose(); - _BackgroundExecutionResult = value; + this._BackgroundExecutionResult = value; OnPropertyChanged(); } @@ -101,8 +101,8 @@ private set /// public WorkspaceViewModelBase? WorkspaceViewModel { - get => _WorkspaceViewModel; - private set => SetProperty(ref _WorkspaceViewModel, value); + get => this._WorkspaceViewModel; + private set => SetProperty(ref this._WorkspaceViewModel, value); } /// @@ -115,7 +115,7 @@ private void SetupActiveViewModel(WorkspaceViewModelBase viewModel) // Restart the time to make sure to update the background // execution result immediately when the workspace changes. - Timer.Change(default, TimeSpan.FromSeconds(2)); + this.Timer.Change(default, TimeSpan.FromSeconds(2)); } /// @@ -130,25 +130,25 @@ private void RunBackgroundCode() // stored arguments to be able to skip the execution if there were no changes. ReadOnlyMemory source = viewModel.Text; string stdin = Messenger.Send(new StdinRequestMessage(true)); - int memorySize = SettingsService.GetValue(SettingsKeys.MemorySize); - OverflowMode overflowMode = SettingsService.GetValue(SettingsKeys.OverflowMode); + int memorySize = this.SettingsService.GetValue(SettingsKeys.MemorySize); + OverflowMode overflowMode = this.SettingsService.GetValue(SettingsKeys.OverflowMode); IReadOnlyMachineState? machineState = (viewModel as ConsoleViewModel)?.MachineState; - if (source.Span.SequenceEqual(_Source.Span) && - stdin.Equals(_Stdin) && - memorySize == _MemorySize && - overflowMode == _OverflowMode && - (machineState is null && _MachineState is null || - machineState?.Equals(_MachineState!) == true)) + if (source.Span.SequenceEqual(this._Source.Span) && + stdin.Equals(this._Stdin) && + memorySize == this._MemorySize && + overflowMode == this._OverflowMode && + (machineState is null && this._MachineState is null || + machineState?.Equals(this._MachineState!) == true)) { return; } - _Source = source; - _Stdin = stdin; - _MemorySize = memorySize; - _OverflowMode = overflowMode; - _MachineState = machineState; + this._Source = source; + this._Stdin = stdin; + this._MemorySize = memorySize; + this._OverflowMode = overflowMode; + this._MachineState = machineState; CancellationTokenSource tokenSource = new(TimeSpan.FromSeconds(2)); @@ -162,7 +162,7 @@ private void RunBackgroundCode() .TryRun(); // Update the property from the original synchronization context - Context.Post(_ => BackgroundExecutionResult = result, null); + this.Context.Post(_ => BackgroundExecutionResult = result, null); } /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs index b7670d9b..04a5a395 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs @@ -21,7 +21,7 @@ public sealed class StdinHeaderViewModel : ObservableRecipient public StdinHeaderViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger) { - SettingsService = settingsService; + this.SettingsService = settingsService; } /// @@ -37,8 +37,8 @@ protected override void OnActivated() /// public string Text { - get => _Text; - set => SetProperty(ref _Text, value); + get => this._Text; + set => SetProperty(ref this._Text, value); } /// @@ -48,7 +48,7 @@ private void GetStdinBuffer(StdinRequestMessage request) // Clear the buffer if requested, and if not from a background execution if (!request.IsFromBackgroundExecution && - SettingsService.GetValue(SettingsKeys.ClearStdinBufferOnRequest)) + this.SettingsService.GetValue(SettingsKeys.ClearStdinBufferOnRequest)) { Text = string.Empty; } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/AboutSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/AboutSubPageViewModel.cs index d67be5d8..a3dc40d6 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/AboutSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/AboutSubPageViewModel.cs @@ -26,7 +26,7 @@ public sealed partial class AboutSubPageViewModel : ObservableObject /// The instance to use public AboutSubPageViewModel(IGitHubService gitHubService) { - GitHubService = gitHubService; + this.GitHubService = gitHubService; } /// @@ -86,7 +86,7 @@ public async Task LoadDataAsync() try { - Developers = new[] { await GitHubService.GetUserAsync(DeveloperInfo.GitHubUsername) }; + Developers = new[] { await this.GitHubService.GetUserAsync(DeveloperInfo.GitHubUsername) }; FeaturedLinks = new[] { DeveloperInfo.PayPalMeUrl }; } catch diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs index 2c8d3284..e4b6e6c6 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs @@ -83,9 +83,9 @@ private async ValueTask> GetSampleCodesAsync() { return _SampleCodes ??= await Task.WhenAll(SampleFilesMapping.Select(async item => { - string installationPath = FilesService.InstallationPath; + string installationPath = this.FilesService.InstallationPath; string path = Path.Combine(installationPath, SampleFilesRelativePath, $"{item.Filename}.txt"); - IFile file = await FilesService.GetFileFromPathAsync(path); + IFile file = await this.FilesService.GetFileFromPathAsync(path); CodeLibraryEntry? entry = await CodeLibraryEntry.TryLoadFromFileAsync(file, item.Title); @@ -107,11 +107,11 @@ private async ValueTask> GetSampleCodesAsync() public CodeLibrarySubPageViewModel(IMessenger messenger, IAnalyticsService analyticsService, IFilesService filesService, IFilesHistoryService filesHistoryService, IClipboardService clipboardService, IShareService shareService) : base(messenger) { - AnalyticsService = analyticsService; - FilesService = filesService; - FilesHistoryService = filesHistoryService; - ClipboardService = clipboardService; - ShareService = shareService; + this.AnalyticsService = analyticsService; + this.FilesService = filesService; + this.FilesHistoryService = filesHistoryService; + this.ClipboardService = clipboardService; + this.ShareService = shareService; } /// @@ -128,7 +128,7 @@ private async Task LoadDataAsync() List recent = new(); // Load the recent files - await foreach ((IFile file, string data) in FilesService.GetFutureAccessFilesAsync()) + await foreach ((IFile file, string data) in this.FilesService.GetFutureAccessFilesAsync()) { // Deserialize the metadata and prepare the model CodeMetadata? metadata = string.IsNullOrEmpty(data) ? new() : JsonSerializer.Deserialize(data, Brainf_ckSharpJsonSerializerContext.Default.CodeMetadata); @@ -183,7 +183,7 @@ private async Task OpenFileAsync(CodeLibraryEntry entry) { if (entry.File.IsReadOnly) { - AnalyticsService.Log(EventNames.SampleCodeSelected, (nameof(SourceCode.File), entry.File.DisplayName)); + this.AnalyticsService.Log(EventNames.SampleCodeSelected, (nameof(SourceCode.File), entry.File.DisplayName)); SourceCode code = await SourceCode.LoadFromReferenceFileAsync(entry.File); @@ -205,8 +205,8 @@ private async Task OpenFileAsync(CodeLibraryEntry entry) private void ToggleFavorite(CodeLibraryEntry? entry) { Guard.IsNotNull(entry); - - AnalyticsService.Log(EventNames.ToggleFavoriteSourceCode, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); + + this.AnalyticsService.Log(EventNames.ToggleFavoriteSourceCode, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); // If the current item is favorited, set is as not favorited // and move it back into the recent files section. @@ -237,12 +237,12 @@ private void ToggleFavorite(CodeLibraryEntry? entry) private async Task CopyToClipboardAsync(CodeLibraryEntry? entry) { Guard.IsNotNull(entry); - - AnalyticsService.Log(EventNames.CopySourceCode); + + this.AnalyticsService.Log(EventNames.CopySourceCode); string text = await entry.File.ReadAllTextAsync(); - ClipboardService.TryCopy(text); + this.ClipboardService.TryCopy(text); } /// @@ -253,10 +253,10 @@ private async Task CopyToClipboardAsync(CodeLibraryEntry? entry) private void Share(CodeLibraryEntry? entry) { Guard.IsNotNull(entry); - - AnalyticsService.Log(EventNames.ShareSourceCode); - ShareService.Share(entry.Title, entry.File); + this.AnalyticsService.Log(EventNames.ShareSourceCode); + + this.ShareService.Share(entry.Title, entry.File); } /// @@ -281,12 +281,12 @@ private void RemoveTrackedSourceCode(CodeLibraryEntry entry) private Task RemoveFromLibraryAsync(CodeLibraryEntry? entry) { Guard.IsNotNull(entry); - - AnalyticsService.Log(EventNames.RemoveFromLibrary, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); + + this.AnalyticsService.Log(EventNames.RemoveFromLibrary, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); RemoveTrackedSourceCode(entry); - return FilesHistoryService.RemoveActivityAsync(entry.File); + return this.FilesHistoryService.RemoveActivityAsync(entry.File); } /// @@ -297,15 +297,15 @@ private Task RemoveFromLibraryAsync(CodeLibraryEntry? entry) private Task DeleteAsync(CodeLibraryEntry? entry) { Guard.IsNotNull(entry); - - AnalyticsService.Log(EventNames.DeleteSourceCode, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); + + this.AnalyticsService.Log(EventNames.DeleteSourceCode, (nameof(CodeMetadata.IsFavorited), entry.Metadata.IsFavorited.ToString())); RemoveTrackedSourceCode(entry); // We can remove the item from history and delete the file in parallel, // since removing a tracked item from history requires no file access. return Task.WhenAll( - FilesHistoryService.RemoveActivityAsync(entry.File), + this.FilesHistoryService.RemoveActivityAsync(entry.File), entry.File.DeleteAsync()); } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs index e83e9a66..92d60580 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs @@ -55,7 +55,7 @@ public sealed partial class IdeResultSubPageViewModel : ObservableRecipient public IdeResultSubPageViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger) { - SettingsService = settingsService; + this.SettingsService = settingsService; } /// @@ -77,17 +77,17 @@ public IdeResultSubPageViewModel(IMessenger messenger, ISettingsService settings /// /// Gets whether or not the debugger is currently stopped at a breakpoint /// - public bool IsAtBreakpoint => _DebugSession?.Current.ExitCode.HasFlag(ExitCode.BreakpointReached) == true; + public bool IsAtBreakpoint => this._DebugSession?.Current.ExitCode.HasFlag(ExitCode.BreakpointReached) == true; /// protected override async void OnDeactivated() { - _ExecutionTokenSource?.Cancel(); - _DebugTokenSource?.Cancel(); + this._ExecutionTokenSource?.Cancel(); + this._DebugTokenSource?.Cancel(); - using (await LoadingMutex.LockAsync()) + using (await this.LoadingMutex.LockAsync()) { - _DebugSession?.Dispose(); + this._DebugSession?.Dispose(); } } @@ -99,14 +99,14 @@ private async Task LoadDataAsync() { Guard.IsNotNull(Source); - using (await LoadingMutex.LockAsync()) + using (await this.LoadingMutex.LockAsync()) { - _ExecutionTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); + this._ExecutionTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10)); // Execution arguments and options string stdin = Messenger.Send(new StdinRequestMessage(false)); - int memorySize = SettingsService.GetValue(SettingsKeys.MemorySize); - OverflowMode overflowMode = SettingsService.GetValue(SettingsKeys.OverflowMode); + int memorySize = this.SettingsService.GetValue(SettingsKeys.MemorySize); + OverflowMode overflowMode = this.SettingsService.GetValue(SettingsKeys.OverflowMode); // Run in RELEASE mode if (Breakpoints is null) @@ -119,7 +119,7 @@ private async Task LoadDataAsync() .WithStdin(stdin) .WithMemorySize(memorySize) .WithOverflowMode(overflowMode) - .WithExecutionToken(_ExecutionTokenSource.Token) + .WithExecutionToken(this._ExecutionTokenSource.Token) .TryRun() .Value!; }); @@ -128,10 +128,10 @@ private async Task LoadDataAsync() } else { - _DebugTokenSource = new CancellationTokenSource(); + this._DebugTokenSource = new CancellationTokenSource(); // Run in DEBUG mode - _DebugSession = await Task.Run(() => + this._DebugSession = await Task.Run(() => { var session = Brainf_ckInterpreter .CreateDebugConfiguration() @@ -140,8 +140,8 @@ private async Task LoadDataAsync() .WithBreakpoints(Breakpoints.Memory) .WithMemorySize(memorySize) .WithOverflowMode(overflowMode) - .WithExecutionToken(_ExecutionTokenSource.Token) - .WithDebugToken(_DebugTokenSource.Token) + .WithExecutionToken(this._ExecutionTokenSource.Token) + .WithDebugToken(this._DebugTokenSource.Token) .TryRun() .Value!; @@ -150,7 +150,7 @@ private async Task LoadDataAsync() return session; }); - LoadResults(_DebugSession.Current); + LoadResults(this._DebugSession.Current); OnPropertyChanged(nameof(IsAtBreakpoint)); } @@ -163,11 +163,11 @@ private async Task LoadDataAsync() [RelayCommand] private async Task ContinueAsync() { - using (await LoadingMutex.LockAsync()) + using (await this.LoadingMutex.LockAsync()) { - await Task.Run(() => _DebugSession!.MoveNext()); + await Task.Run(() => this._DebugSession!.MoveNext()); - LoadResults(_DebugSession!.Current); + LoadResults(this._DebugSession!.Current); OnPropertyChanged(nameof(IsAtBreakpoint)); } @@ -179,13 +179,13 @@ private async Task ContinueAsync() [RelayCommand] private async Task SkipAsync() { - using (await LoadingMutex.LockAsync()) + using (await this.LoadingMutex.LockAsync()) { - _DebugTokenSource!.Cancel(); + this._DebugTokenSource!.Cancel(); - await Task.Run(() => _DebugSession!.MoveNext()); + await Task.Run(() => this._DebugSession!.MoveNext()); - LoadResults(_DebugSession!.Current); + LoadResults(this._DebugSession!.Current); OnPropertyChanged(nameof(IsAtBreakpoint)); } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/ReviewPromptSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/ReviewPromptSubPageViewModel.cs index f37ac886..dcab3436 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/ReviewPromptSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/ReviewPromptSubPageViewModel.cs @@ -35,16 +35,16 @@ public sealed partial class ReviewPromptSubPageViewModel : ObservableObject /// The instance to use public ReviewPromptSubPageViewModel(IEmailService emailService, IStoreService storeService, ISystemInformationService systemInformationService) { - EmailService = emailService; - StoreService = storeService; - SystemInformationService = systemInformationService; + this.EmailService = emailService; + this.StoreService = storeService; + this.SystemInformationService = systemInformationService; } /// [RelayCommand] private Task RequestReviewAsync() { - return StoreService.RequestReviewAsync(); + return this.StoreService.RequestReviewAsync(); } /// @@ -58,13 +58,13 @@ private Task SendFeedbackEmailAsync() builder.AppendLine(); builder.AppendLine(); builder.AppendLine("=========================="); - builder.AppendLine($"[AppVersion]: {SystemInformationService.ApplicationVersion}"); - builder.AppendLine($"[CPU architecture]: {SystemInformationService.CpuArchitecture}"); - builder.AppendLine($"[OS]: {SystemInformationService.OperatingSystemVersion}"); - builder.AppendLine($"[OS build]: {SystemInformationService.OperatingSystemVersion}"); + builder.AppendLine($"[AppVersion]: {this.SystemInformationService.ApplicationVersion}"); + builder.AppendLine($"[CPU architecture]: {this.SystemInformationService.CpuArchitecture}"); + builder.AppendLine($"[OS]: {this.SystemInformationService.OperatingSystemVersion}"); + builder.AppendLine($"[OS build]: {this.SystemInformationService.OperatingSystemVersion}"); string body = builder.ToString(); - return EmailService.TryComposeEmailAsync(DeveloperInfo.FeedbackEmail, "Brainf*ck# feedback", body); + return this.EmailService.TryComposeEmailAsync(DeveloperInfo.FeedbackEmail, "Brainf*ck# feedback", body); } } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/Abstract/SettingsSectionViewModelBase.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/Abstract/SettingsSectionViewModelBase.cs index 3a35a71d..9f815876 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/Abstract/SettingsSectionViewModelBase.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/Abstract/SettingsSectionViewModelBase.cs @@ -25,7 +25,7 @@ public abstract class SettingsSectionViewModelBase : ObservableRecipient protected SettingsSectionViewModelBase(IMessenger messenger, ISettingsService settingsService) : base(messenger) { - SettingsService = settingsService; + this.SettingsService = settingsService; } /// @@ -40,7 +40,7 @@ protected SettingsSectionViewModelBase(IMessenger messenger, ISettingsService se { if (base.SetProperty(ref field, value, name)) { - SettingsService.SetValue(name!, value); + this.SettingsService.SetValue(name!, value); } } @@ -58,7 +58,7 @@ protected bool SetProperty(ref T field, T value, [CallerMemberName] { if (base.SetProperty(ref field, value, name)) { - SettingsService.SetValue(name!, value); + this.SettingsService.SetValue(name!, value); TMessage message = (TMessage)Activator.CreateInstance(typeof(TMessage), value); diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs index 168a911f..8408a0eb 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs @@ -40,13 +40,13 @@ public sealed partial class IdeSettingsSectionViewModel : SettingsSectionViewMod public IdeSettingsSectionViewModel(IMessenger messenger, IAnalyticsService analyticsService, IStoreService storeService, ISettingsService settingsService, AppConfiguration configuration) : base(messenger, settingsService) { - AnalyticsService = analyticsService; - StoreService = storeService; - Configuration = configuration; + this.AnalyticsService = analyticsService; + this.StoreService = storeService; + this.Configuration = configuration; - _IdeTheme = SettingsService.GetValue(SettingsKeys.IdeTheme); - _BracketsFormattingStyle = SettingsService.GetValue(SettingsKeys.BracketsFormattingStyle); - _RenderWhitespaces = SettingsService.GetValue(SettingsKeys.RenderWhitespaces); + this._IdeTheme = this.SettingsService.GetValue(SettingsKeys.IdeTheme); + this._BracketsFormattingStyle = this.SettingsService.GetValue(SettingsKeys.BracketsFormattingStyle); + this._RenderWhitespaces = this.SettingsService.GetValue(SettingsKeys.RenderWhitespaces); } /// @@ -61,12 +61,12 @@ public IdeSettingsSectionViewModel(IMessenger messenger, IAnalyticsService analy /// public IdeTheme IdeTheme { - get => _IdeTheme; + get => this._IdeTheme; set { - if (SetProperty(ref _IdeTheme, value)) + if (SetProperty(ref this._IdeTheme, value)) { - AnalyticsService.Log(EventNames.ThemeChanged, (nameof(Enums.Settings.IdeTheme), value.ToString())); + this.AnalyticsService.Log(EventNames.ThemeChanged, (nameof(Enums.Settings.IdeTheme), value.ToString())); } } } @@ -94,8 +94,8 @@ public bool IsThemeSelectorAvailable /// public BracketsFormattingStyle BracketsFormattingStyle { - get => _BracketsFormattingStyle; - set => SetProperty(ref _BracketsFormattingStyle, value); + get => this._BracketsFormattingStyle; + set => SetProperty(ref this._BracketsFormattingStyle, value); } private bool _RenderWhitespaces; @@ -105,8 +105,8 @@ public BracketsFormattingStyle BracketsFormattingStyle /// public bool RenderWhitespaces { - get => _RenderWhitespaces; - set => SetProperty(ref _RenderWhitespaces, value); + get => this._RenderWhitespaces; + set => SetProperty(ref this._RenderWhitespaces, value); } /// @@ -117,9 +117,9 @@ private async Task InitializeAsync() { if (!IsThemeSelectorAvailable) { - Guard.IsNotNull(Configuration.UnlockThemesIapId, nameof(AppConfiguration.UnlockThemesIapId)); + Guard.IsNotNull(this.Configuration.UnlockThemesIapId, nameof(AppConfiguration.UnlockThemesIapId)); - IsThemeSelectorAvailable = await StoreService.IsProductPurchasedAsync(Configuration.UnlockThemesIapId); + IsThemeSelectorAvailable = await this.StoreService.IsProductPurchasedAsync(this.Configuration.UnlockThemesIapId); } } @@ -129,13 +129,13 @@ private async Task InitializeAsync() [RelayCommand] private async Task TryUnlockThemesSelectorAsync() { - Guard.IsNotNull(Configuration.UnlockThemesIapId, nameof(AppConfiguration.UnlockThemesIapId)); + Guard.IsNotNull(this.Configuration.UnlockThemesIapId, nameof(AppConfiguration.UnlockThemesIapId)); - var result = await StoreService.TryPurchaseProductAsync(Configuration.UnlockThemesIapId); + var result = await this.StoreService.TryPurchaseProductAsync(this.Configuration.UnlockThemesIapId); IsThemeSelectorAvailable = result == StorePurchaseResult.Success || result == StorePurchaseResult.AlreadyPurchased; - AnalyticsService.Log(EventNames.ThemesUnlockRequest, (nameof(StorePurchaseResult), result.ToString())); + this.AnalyticsService.Log(EventNames.ThemesUnlockRequest, (nameof(StorePurchaseResult), result.ToString())); } } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs index 57c1329d..285fc283 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using Brainf_ckSharp.Enums; using Brainf_ckSharp.Services; using Brainf_ckSharp.Shared.Constants; @@ -18,8 +18,8 @@ public sealed class InterpreterSettingsSectionViewModel : SettingsSectionViewMod public InterpreterSettingsSectionViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger, settingsService) { - _OverflowMode = SettingsService.GetValue(SettingsKeys.OverflowMode); - _MemorySize = SettingsService.GetValue(SettingsKeys.MemorySize); + this._OverflowMode = this.SettingsService.GetValue(SettingsKeys.OverflowMode); + this._MemorySize = this.SettingsService.GetValue(SettingsKeys.MemorySize); } /// @@ -34,8 +34,8 @@ public InterpreterSettingsSectionViewModel(IMessenger messenger, ISettingsServic /// public OverflowMode OverflowMode { - get => _OverflowMode; - set => SetProperty(ref _OverflowMode, value); + get => this._OverflowMode; + set => SetProperty(ref this._OverflowMode, value); } /// @@ -50,7 +50,7 @@ public OverflowMode OverflowMode /// public int MemorySize { - get => _MemorySize; - set => SetProperty(ref _MemorySize, value); + get => this._MemorySize; + set => SetProperty(ref this._MemorySize, value); } } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs index 5e262dee..80bc2f52 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs @@ -16,8 +16,8 @@ public sealed class UISettingsSectionViewModel : SettingsSectionViewModelBase public UISettingsSectionViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger, settingsService) { - _ClearStdinBufferOnRequest = SettingsService.GetValue(SettingsKeys.ClearStdinBufferOnRequest); - _ShowPBrainButtons = SettingsService.GetValue(SettingsKeys.ShowPBrainButtons); + this._ClearStdinBufferOnRequest = this.SettingsService.GetValue(SettingsKeys.ClearStdinBufferOnRequest); + this._ShowPBrainButtons = this.SettingsService.GetValue(SettingsKeys.ShowPBrainButtons); } private bool _ClearStdinBufferOnRequest; @@ -27,8 +27,8 @@ public UISettingsSectionViewModel(IMessenger messenger, ISettingsService setting /// public bool ClearStdinBufferOnRequest { - get => _ClearStdinBufferOnRequest; - set => SetProperty(ref _ClearStdinBufferOnRequest, value); + get => this._ClearStdinBufferOnRequest; + set => SetProperty(ref this._ClearStdinBufferOnRequest, value); } private bool _ShowPBrainButtons; @@ -38,7 +38,7 @@ public bool ClearStdinBufferOnRequest /// public bool ShowPBrainButtons { - get => _ShowPBrainButtons; - set => SetProperty(ref _ShowPBrainButtons, value); + get => this._ShowPBrainButtons; + set => SetProperty(ref this._ShowPBrainButtons, value); } } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs index 308a6a98..0d33ef00 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs @@ -18,7 +18,7 @@ public sealed partial class VirtualKeyboardViewModel : ObservableRecipient public VirtualKeyboardViewModel(IMessenger messenger, ISettingsService settingsService) : base(messenger) { - _IsPBrainModeEnabled = settingsService.GetValue(SettingsKeys.ShowPBrainButtons); + this._IsPBrainModeEnabled = settingsService.GetValue(SettingsKeys.ShowPBrainButtons); } /// @@ -34,8 +34,8 @@ protected override void OnActivated() /// public bool IsPBrainModeEnabled { - get => _IsPBrainModeEnabled; - private set => SetProperty(ref _IsPBrainModeEnabled, value); + get => this._IsPBrainModeEnabled; + private set => SetProperty(ref this._IsPBrainModeEnabled, value); } /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs index 0171fe33..16725f82 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs @@ -58,11 +58,11 @@ public sealed class ShellViewModel : ObservableRecipient public ShellViewModel(IMessenger messenger, ISettingsService settingsService, IAnalyticsService analyticsService) : base(messenger) { - SettingsService = settingsService; - AnalyticsService = analyticsService; + this.SettingsService = settingsService; + this.AnalyticsService = analyticsService; - _SelectedView = SettingsService.GetValue(SettingsKeys.SelectedView); - _IsVirtualKeyboardEnabled = SettingsService.GetValue(SettingsKeys.IsVirtualKeyboardEnabled); + this._SelectedView = this.SettingsService.GetValue(SettingsKeys.SelectedView); + this._IsVirtualKeyboardEnabled = this.SettingsService.GetValue(SettingsKeys.IsVirtualKeyboardEnabled); } private ViewType _SelectedView; @@ -72,12 +72,12 @@ public ShellViewModel(IMessenger messenger, ISettingsService settingsService, IA /// public ViewType SelectedView { - get => _SelectedView; + get => this._SelectedView; set { - if (SetProperty(ref _SelectedView, value)) + if (SetProperty(ref this._SelectedView, value)) { - SettingsService.SetValue(SettingsKeys.SelectedView, value); + this.SettingsService.SetValue(SettingsKeys.SelectedView, value); } } } @@ -89,12 +89,12 @@ public ViewType SelectedView /// public bool IsVirtualKeyboardEnabled { - get => _IsVirtualKeyboardEnabled; + get => this._IsVirtualKeyboardEnabled; set { - if (SetProperty(ref _IsVirtualKeyboardEnabled, value)) + if (SetProperty(ref this._IsVirtualKeyboardEnabled, value)) { - SettingsService.SetValue(SettingsKeys.IsVirtualKeyboardEnabled, value); + this.SettingsService.SetValue(SettingsKeys.IsVirtualKeyboardEnabled, value); } } } @@ -104,7 +104,7 @@ public bool IsVirtualKeyboardEnabled /// public void RunConsoleScript() { - AnalyticsService.Log(EventNames.ConsoleRun); + this.AnalyticsService.Log(EventNames.ConsoleRun); Messenger.Send(); } @@ -124,7 +124,7 @@ public void RunConsoleScript() /// public void ClearConsoleScreen() { - AnalyticsService.Log(EventNames.ClearScreen); + this.AnalyticsService.Log(EventNames.ClearScreen); Messenger.Send(); } @@ -134,7 +134,7 @@ public void ClearConsoleScreen() /// public void RepeatLastConsoleScript() { - AnalyticsService.Log(EventNames.RepeatLastScript); + this.AnalyticsService.Log(EventNames.RepeatLastScript); Messenger.Send(); } @@ -144,7 +144,7 @@ public void RepeatLastConsoleScript() /// public void RestartConsole() { - AnalyticsService.Log(EventNames.Restart); + this.AnalyticsService.Log(EventNames.Restart); Messenger.Send(); } @@ -154,7 +154,7 @@ public void RestartConsole() /// public void RunIdeScript() { - AnalyticsService.Log(EventNames.IdeRun); + this.AnalyticsService.Log(EventNames.IdeRun); Messenger.Send(); } @@ -164,7 +164,7 @@ public void RunIdeScript() /// public void DebugIdeScript() { - AnalyticsService.Log(EventNames.IdeDebug); + this.AnalyticsService.Log(EventNames.IdeDebug); Messenger.Send(); } @@ -174,7 +174,7 @@ public void DebugIdeScript() /// public void NewIdeFile() { - AnalyticsService.Log(EventNames.NewFile); + this.AnalyticsService.Log(EventNames.NewFile); Messenger.Send(); } @@ -194,7 +194,7 @@ public void NewIdeFile() /// public void OpenFile() { - AnalyticsService.Log(EventNames.OpenFile); + this.AnalyticsService.Log(EventNames.OpenFile); Messenger.Send(new PickOpenFileRequestMessage(false)); } @@ -204,7 +204,7 @@ public void OpenFile() /// public void SaveFile() { - AnalyticsService.Log(EventNames.Save); + this.AnalyticsService.Log(EventNames.Save); Messenger.Send(); } @@ -214,7 +214,7 @@ public void SaveFile() /// public void SaveFileAs() { - AnalyticsService.Log(EventNames.SaveAs); + this.AnalyticsService.Log(EventNames.SaveAs); Messenger.Send(); } @@ -224,7 +224,7 @@ public void SaveFileAs() /// public void RequestUnicodeMap() { - AnalyticsService.Log(EventNames.UnicodeCharactersMapOpened); + this.AnalyticsService.Log(EventNames.UnicodeCharactersMapOpened); UnicodeMapRequested?.Invoke(this, EventArgs.Empty); } @@ -234,7 +234,7 @@ public void RequestUnicodeMap() /// public void RequestAboutInfo() { - AnalyticsService.Log(EventNames.AboutPageOpened); + this.AnalyticsService.Log(EventNames.AboutPageOpened); AboutInfoRequested?.Invoke(this, EventArgs.Empty); } @@ -244,7 +244,7 @@ public void RequestAboutInfo() /// public void RequestUserGuide() { - AnalyticsService.Log(EventNames.UserGuideOpened); + this.AnalyticsService.Log(EventNames.UserGuideOpened); UserGuideRequested?.Invoke(this, EventArgs.Empty); } @@ -254,7 +254,7 @@ public void RequestUserGuide() /// public void RequestSettings() { - AnalyticsService.Log(EventNames.SettingsOpened); + this.AnalyticsService.Log(EventNames.SettingsOpened); SettingsRequested?.Invoke(this, EventArgs.Empty); } @@ -264,7 +264,7 @@ public void RequestSettings() /// public void RequestCodeLibrary() { - AnalyticsService.Log(EventNames.OpenCodeLibrary); + this.AnalyticsService.Log(EventNames.OpenCodeLibrary); CodeLibraryRequested?.Invoke(this, EventArgs.Empty); } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Views/Abstract/WorkspaceViewModelBase.cs b/src/Brainf_ckSharp.Shared/ViewModels/Views/Abstract/WorkspaceViewModelBase.cs index 5a257dcd..f087d31b 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Views/Abstract/WorkspaceViewModelBase.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Views/Abstract/WorkspaceViewModelBase.cs @@ -27,10 +27,10 @@ protected WorkspaceViewModelBase(IMessenger messenger) : base(messenger) /// public SourceCode Code { - get => _Code; + get => this._Code; protected set { - if (SetProperty(ref _Code, value)) + if (SetProperty(ref this._Code, value)) { OnCodeChanged(value); } @@ -44,12 +44,12 @@ protected set /// public ReadOnlyMemory Text { - get => _Text; + get => this._Text; set { - if (_Text.Span.SequenceEqual(value.Span)) return; + if (this._Text.Span.SequenceEqual(value.Span)) return; - _Text = value; + this._Text = value; OnPropertyChanged(); @@ -66,8 +66,8 @@ public ReadOnlyMemory Text /// public bool IsUnsavedEditPending { - get => _IsUnsavedEditPending; - private set => SetProperty(ref _IsUnsavedEditPending, value); + get => this._IsUnsavedEditPending; + private set => SetProperty(ref this._IsUnsavedEditPending, value); } private SyntaxValidationResult _ValidationResult; @@ -77,8 +77,8 @@ public bool IsUnsavedEditPending /// public SyntaxValidationResult ValidationResult { - get => _ValidationResult; - set => SetProperty(ref _ValidationResult, value); + get => this._ValidationResult; + set => SetProperty(ref this._ValidationResult, value); } private int _Row = 1; @@ -88,12 +88,12 @@ public SyntaxValidationResult ValidationResult /// public int Row { - get => _Row; + get => this._Row; set { Guard.IsGreaterThan(value, 0); - SetProperty(ref _Row, value); + SetProperty(ref this._Row, value); } } @@ -104,12 +104,12 @@ public int Row /// public int Column { - get => _Column; + get => this._Column; set { Guard.IsGreaterThan(value, 0); - SetProperty(ref _Column, value); + SetProperty(ref this._Column, value); } } diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs index b785bd12..a8664107 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs @@ -54,13 +54,13 @@ public sealed class ConsoleViewModel : WorkspaceViewModelBase public ConsoleViewModel(IMessenger messenger, ISettingsService settingsService, IKeyboardListenerService keyboardListenerService) : base(messenger) { - SettingsService = settingsService; - KeyboardListenerService = keyboardListenerService; + this.SettingsService = settingsService; + this.KeyboardListenerService = keyboardListenerService; // Initialize the machine state with the current user settings - _MachineState = MachineStateProvider.Create( - SettingsService.GetValue(SettingsKeys.MemorySize), - SettingsService.GetValue(SettingsKeys.OverflowMode)); + this._MachineState = MachineStateProvider.Create( + this.SettingsService.GetValue(SettingsKeys.MemorySize), + this.SettingsService.GetValue(SettingsKeys.OverflowMode)); } /// @@ -77,7 +77,7 @@ protected override void OnActivated() Messenger.Register(this, (r, m) => _ = r.RestartAsync()); Messenger.Register(this, (r, m) => _ = r.TryAddOperatorAsync(m.Value)); - KeyboardListenerService.CharacterReceived += TryAddOperator; + this.KeyboardListenerService.CharacterReceived += TryAddOperator; } /// @@ -85,7 +85,7 @@ protected override void OnDeactivated() { base.OnDeactivated(); - KeyboardListenerService.CharacterReceived -= TryAddOperator; + this.KeyboardListenerService.CharacterReceived -= TryAddOperator; } /// @@ -107,8 +107,8 @@ protected override void OnTextChanged(ReadOnlyMemory text) /// public IReadOnlyMachineState MachineState { - get => _MachineState; - private set => SetProperty(ref _MachineState, value, true); + get => this._MachineState; + private set => SetProperty(ref this._MachineState, value, true); } /// @@ -126,7 +126,7 @@ private void TryAddOperator(char c) /// The current operator to add private async Task TryAddOperatorAsync(char c) { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (!Brainf_ckParser.IsOperator(c)) return; if (Source.LastOrDefault() is ConsoleCommand command) @@ -144,7 +144,7 @@ private async Task TryAddOperatorAsync(char c) /// private async Task DeleteLastOperatorAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (Source.LastOrDefault() is ConsoleCommand command) { @@ -163,7 +163,7 @@ private async Task DeleteLastOperatorAsync() /// private async Task ResetCommandAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (Source.LastOrDefault() is ConsoleCommand command) { @@ -180,7 +180,7 @@ private async Task ResetCommandAsync() /// private async Task RestartAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (Source.LastOrDefault() is ConsoleCommand command) { @@ -191,8 +191,8 @@ private async Task RestartAsync() Source.Add(new ConsoleRestart()); MachineState = MachineStateProvider.Create( - SettingsService.GetValue(SettingsKeys.MemorySize), - SettingsService.GetValue(SettingsKeys.OverflowMode)); + this.SettingsService.GetValue(SettingsKeys.MemorySize), + this.SettingsService.GetValue(SettingsKeys.OverflowMode)); Source.Add(new ConsoleCommand()); @@ -205,7 +205,7 @@ private async Task RestartAsync() /// private async Task ClearScreenAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { Source.Clear(); @@ -220,7 +220,7 @@ private async Task ClearScreenAsync() /// private async Task ExecuteCommandAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (Source.LastOrDefault() is not ConsoleCommand command) { @@ -283,7 +283,7 @@ private async Task ExecuteCommandAsync(string command) /// private async Task RepeatLastScriptAsync() { - using (await ExecutionMutex.LockAsync()) + using (await this.ExecutionMutex.LockAsync()) { if (Source.Reverse().OfType().Skip(1).FirstOrDefault() is ConsoleCommand previous) { diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs index 4c7526e8..233aafcc 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs @@ -86,10 +86,10 @@ public sealed class IdeViewModel : WorkspaceViewModelBase public IdeViewModel(IMessenger messenger, IAnalyticsService analyticsService, IFilesService filesService, IFilesManagerService filesManagerService, IFilesHistoryService filesHistoryService) : base(messenger) { - AnalyticsService = analyticsService; - FilesService = filesService; - FilesManagerService = filesManagerService; - FilesHistoryService = filesHistoryService; + this.AnalyticsService = analyticsService; + this.FilesService = filesService; + this.FilesManagerService = filesManagerService; + this.FilesHistoryService = filesHistoryService; } /// @@ -110,7 +110,7 @@ protected override void OnActivated() /// protected override void OnCodeChanged(SourceCode code) { - FilesManagerService.RegisterFile(code.File); + this.FilesManagerService.RegisterFile(code.File); } /// @@ -119,12 +119,12 @@ protected override void OnCodeChanged(SourceCode code) /// The source code to load private void LoadSourceCode(SourceCode code) { - AnalyticsService.Log(EventNames.LoadLibrarySourceCode); + this.AnalyticsService.Log(EventNames.LoadLibrarySourceCode); if (code.File is not null && - FilesManagerService.TrySwitchTo(code.File)) + this.FilesManagerService.TrySwitchTo(code.File)) { - AnalyticsService.Log(EventNames.SwitchToFile); + this.AnalyticsService.Log(EventNames.SwitchToFile); return; } @@ -133,7 +133,7 @@ private void LoadSourceCode(SourceCode code) if (code.File is not null) { - _ = FilesHistoryService.LogOrUpdateActivityAsync(code.File); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(code.File); } CodeLoaded?.Invoke(this, Code.Content); @@ -146,7 +146,7 @@ private void LoadNewFile() { Code = SourceCode.CreateEmpty(); - _ = FilesHistoryService.DismissCurrentActivityAsync(); + _ = this.FilesHistoryService.DismissCurrentActivityAsync(); CodeLoaded?.Invoke(this, Code.Content); } @@ -157,18 +157,18 @@ private void LoadNewFile() /// Whether to immediately mark the item as favorite private async Task TryLoadTextFromFileAsync(bool favorite) { - AnalyticsService.Log(EventNames.PickFileRequest); + this.AnalyticsService.Log(EventNames.PickFileRequest); - if (await FilesService.TryPickOpenFileAsync(".bfs") is not IFile file) return; + if (await this.FilesService.TryPickOpenFileAsync(".bfs") is not IFile file) return; - if (FilesManagerService.TrySwitchTo(file)) + if (this.FilesManagerService.TrySwitchTo(file)) { - AnalyticsService.Log(EventNames.SwitchToFile); + this.AnalyticsService.Log(EventNames.SwitchToFile); return; } - AnalyticsService.Log(EventNames.LoadPickedFile, (nameof(CodeMetadata.IsFavorited), favorite.ToString())); + this.AnalyticsService.Log(EventNames.LoadPickedFile, (nameof(CodeMetadata.IsFavorited), favorite.ToString())); if (await SourceCode.TryLoadFromEditableFileAsync(file) is SourceCode code) { @@ -182,7 +182,7 @@ private async Task TryLoadTextFromFileAsync(bool favorite) Code = code; - _ = FilesHistoryService.LogOrUpdateActivityAsync(code.File!); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(code.File!); CodeLoaded?.Invoke(this, Code.Content); } @@ -198,7 +198,7 @@ private async Task TryLoadTextFromFileAsync(IFile file) { Code = code; - _ = FilesHistoryService.LogOrUpdateActivityAsync(code.File!); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(code.File!); CodeLoaded?.Invoke(this, Code.Content); } @@ -216,7 +216,7 @@ private async Task TrySaveTextAsync() await Code.TrySaveAsync(); - _ = FilesHistoryService.LogOrUpdateActivityAsync(Code.File!); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(Code.File!); CodeSaved?.Invoke(this, EventArgs.Empty); @@ -229,11 +229,11 @@ private async Task TrySaveTextAsync() /// private async Task TrySaveTextAsAsync() { - if (await FilesService.TryPickSaveFileAsync(string.Empty, (string.Empty, ".bfs")) is not IFile file) return; + if (await this.FilesService.TryPickSaveFileAsync(string.Empty, (string.Empty, ".bfs")) is not IFile file) return; - if (FilesManagerService.TrySwitchTo(file)) + if (this.FilesManagerService.TrySwitchTo(file)) { - AnalyticsService.Log(EventNames.SwitchToFile); + this.AnalyticsService.Log(EventNames.SwitchToFile); return; } @@ -242,7 +242,7 @@ private async Task TrySaveTextAsAsync() await Code.TrySaveAsAsync(file); - _ = FilesHistoryService.LogOrUpdateActivityAsync(Code.File!); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(Code.File!); CodeSaved?.Invoke(this, EventArgs.Empty); @@ -257,10 +257,10 @@ public async Task SaveStateAsync() IdeState state = new(Text.ToString(), Row, Column, Code.File?.Path); string - temporaryPath = FilesService.TemporaryFilesPath, + temporaryPath = this.FilesService.TemporaryFilesPath, statePath = Path.Combine(temporaryPath, "state.json"); - IFile file = await FilesService.CreateOrOpenFileFromPathAsync(statePath); + IFile file = await this.FilesService.CreateOrOpenFileFromPathAsync(statePath); using Stream stream = await file.OpenStreamForWriteAsync(); @@ -278,10 +278,10 @@ public async Task RestoreStateAsync(IFile? file) if (file is null) { string - temporaryPath = FilesService.TemporaryFilesPath, + temporaryPath = this.FilesService.TemporaryFilesPath, statePath = Path.Combine(temporaryPath, "state.json"); - if (await FilesService.TryGetFileFromPathAsync(statePath) is not IFile jsonFile) + if (await this.FilesService.TryGetFileFromPathAsync(statePath) is not IFile jsonFile) return; IdeState? state; @@ -296,7 +296,7 @@ public async Task RestoreStateAsync(IFile? file) if (state.FilePath is null) Code = SourceCode.CreateEmpty(); else { - IFile? sourceFile = await FilesService.TryGetFileFromPathAsync(state.FilePath); + IFile? sourceFile = await this.FilesService.TryGetFileFromPathAsync(state.FilePath); if (sourceFile is null) Code = SourceCode.CreateEmpty(); else Code = await SourceCode.TryLoadFromEditableFileAsync(sourceFile) ?? SourceCode.CreateEmpty(); @@ -308,7 +308,7 @@ public async Task RestoreStateAsync(IFile? file) if (Code.File is not null) { - _ = FilesHistoryService.LogOrUpdateActivityAsync(Code.File); + _ = this.FilesHistoryService.LogOrUpdateActivityAsync(Code.File); } StateRestored?.Invoke(this, state); diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Events.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Events.cs index 9378b7e1..33a4eebb 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Events.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Events.cs @@ -40,6 +40,6 @@ internal sealed partial class Brainf_ckEditBox /// public void InvalidateOverlays() { - _TextOverlaysCanvas!.Invalidate(); + this._TextOverlaysCanvas!.Invalidate(); } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Flyout.ICommand.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Flyout.ICommand.cs index aee3d645..7addd86e 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Flyout.ICommand.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Flyout.ICommand.cs @@ -27,7 +27,7 @@ private sealed class Command : ICommand /// The to invoke public Command(Action action) { - Action = action; + this.Action = action; } /// @@ -39,7 +39,7 @@ public bool CanExecute(object parameter) /// public void Execute(object parameter) { - Action(); + this.Action(); } /// diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.Lock.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.Lock.cs index c0e38e45..2382e051 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.Lock.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.Lock.cs @@ -24,7 +24,7 @@ private readonly ref struct FormattingLock /// The current instance private FormattingLock(Brainf_ckEditBox @this) { - This = @this; + this.This = @this; @this.TextChanging -= @this.MarkdownRichEditBox_TextChanging; ((RichEditBox)@this).TextChanged -= @this.MarkdownRichEditBox_TextChanged; @@ -43,20 +43,20 @@ private FormattingLock(Brainf_ckEditBox @this) /// public void Dispose() { - This.TextChanging += This.MarkdownRichEditBox_TextChanging; - ((RichEditBox)This).TextChanged += This.MarkdownRichEditBox_TextChanged; - This.Document.ApplyDisplayUpdates(); - This.IsUndoGroupingEnabled = false; + this.This.TextChanging += this.This.MarkdownRichEditBox_TextChanging; + ((RichEditBox)this.This).TextChanged += this.This.MarkdownRichEditBox_TextChanged; + this.This.Document.ApplyDisplayUpdates(); + this.This.IsUndoGroupingEnabled = false; // Redraw the overlays, if needed - This.TryUpdateBracketsList(); - if (This.RenderWhitespaceCharacters) This.TryUpdateWhitespaceCharactersList(); - This.TryProcessErrorCoordinate(); + this.This.TryUpdateBracketsList(); + if (this.This.RenderWhitespaceCharacters) this.This.TryUpdateWhitespaceCharactersList(); + this.This.TryProcessErrorCoordinate(); // Notify external subscribers - This.FormattingCompleted?.Invoke(This, EventArgs.Empty); + this.This.FormattingCompleted?.Invoke(this.This, EventArgs.Empty); - This._TextOverlaysCanvas!.Invalidate(); + this.This._TextOverlaysCanvas!.Invalidate(); } } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.cs index 3396ff67..4ec37755 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Formatting.cs @@ -60,23 +60,23 @@ private void ApplySyntaxHighlight() // - As a last resort, just format the entire text from start to finish. if (selectionLength == 0 && selectionStart > 0 && - (_SelectionLength == 0 && textLength == oldText.Length + 1) || - _SelectionLength > 1) + (this._SelectionLength == 0 && textLength == oldText.Length + 1) || + this._SelectionLength > 1) { FormatSingleCharacter(ref newText, selectionStart); } else if (selectionLength == 0 && - _SelectionLength == 0 && + this._SelectionLength == 0 && textLength == oldText.Length - 1 && - selectionStart == _SelectionStart) + selectionStart == this._SelectionStart) { // This branch also captures single character deletions. // Set the property to false to make sure the formatting // isn't compromised in future runs by the property // remaining true because this branch took precedence. - _IsDeleteRequested = false; + this._IsDeleteRequested = false; } - else if (_IsDeleteRequested) _IsDeleteRequested = false; + else if (this._IsDeleteRequested) this._IsDeleteRequested = false; else FormatRange(newText, 0, textLength); Text = newText; @@ -95,7 +95,7 @@ private void FormatSingleCharacter(ref string text, int start) char c = text[start - 1]; - if (c == Characters.LoopStart && _SyntaxValidationResult.IsSuccessOrEmptyScript) + if (c == Characters.LoopStart && this._SyntaxValidationResult.IsSuccessOrEmptyScript) { int depth = text.CalculateIndentationDepth(start - 1); ITextRange range = Document.GetRange(start - 1, start); @@ -128,7 +128,7 @@ private void FormatSingleCharacter(ref string text, int start) text = Document.GetText(); } - else if (c == Characters.CarriageReturn && _SyntaxValidationResult.IsSuccessOrEmptyScript) + else if (c == Characters.CarriageReturn && this._SyntaxValidationResult.IsSuccessOrEmptyScript) { int depth = text.CalculateIndentationDepth(start); string autocomplete = new(Characters.Tab, depth); diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Properties.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Properties.cs index 101cc9bf..c0dc041d 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Properties.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Properties.cs @@ -26,9 +26,9 @@ private set { SetValue(TextProperty, value); - _SyntaxValidationResult = Brainf_ckParser.ValidateSyntax(value); + this._SyntaxValidationResult = Brainf_ckParser.ValidateSyntax(value); - TextChanged?.Invoke(this, new TextChangedEventArgs(value, _SyntaxValidationResult)); + TextChanged?.Invoke(this, new TextChangedEventArgs(value, this._SyntaxValidationResult)); } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Template.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Template.cs index 62af3d55..673369e7 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Template.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Template.cs @@ -106,34 +106,34 @@ protected override void OnApplyTemplate() { base.OnApplyTemplate(); - _BackgroundCanvas = (Canvas)GetTemplateChild(BackgroundCanvasName); - _TextOverlaysCanvas = (CanvasControl)GetTemplateChild(TextOverlaysCanvasName); - _SelectionHighlightBorder = (Border)GetTemplateChild(SelectionHighlightBorderName); - _CursorIndicatorRectangle = (Rectangle)GetTemplateChild(CursorIndicatorRectangleName); - _SyntaxErrorToolTip = (TeachingTip)GetTemplateChild(SyntaxErrorToolTipName); + this._BackgroundCanvas = (Canvas)GetTemplateChild(BackgroundCanvasName); + this._TextOverlaysCanvas = (CanvasControl)GetTemplateChild(TextOverlaysCanvasName); + this._SelectionHighlightBorder = (Border)GetTemplateChild(SelectionHighlightBorderName); + this._CursorIndicatorRectangle = (Rectangle)GetTemplateChild(CursorIndicatorRectangleName); + this._SyntaxErrorToolTip = (TeachingTip)GetTemplateChild(SyntaxErrorToolTipName); ContentScroller = (ScrollViewer)GetTemplateChild(ContentScrollerName); ContentElement = (ContentPresenter)GetTemplateChild(ContentElementName); - Guard.IsNotNull(_BackgroundCanvas, nameof(BackgroundCanvasName)); - Guard.IsNotNull(_TextOverlaysCanvas, nameof(TextOverlaysCanvasName)); - Guard.IsNotNull(_SelectionHighlightBorder, nameof(SelectionHighlightBorderName)); - Guard.IsNotNull(_CursorIndicatorRectangle, nameof(CursorIndicatorRectangleName)); - Guard.IsNotNull(_SyntaxErrorToolTip, SyntaxErrorToolTipName); + Guard.IsNotNull(this._BackgroundCanvas, nameof(BackgroundCanvasName)); + Guard.IsNotNull(this._TextOverlaysCanvas, nameof(TextOverlaysCanvasName)); + Guard.IsNotNull(this._SelectionHighlightBorder, nameof(SelectionHighlightBorderName)); + Guard.IsNotNull(this._CursorIndicatorRectangle, nameof(CursorIndicatorRectangleName)); + Guard.IsNotNull(this._SyntaxErrorToolTip, SyntaxErrorToolTipName); Guard.IsNotNull(ContentScroller, ContentScrollerName); Guard.IsNotNull(ContentElement, ContentElementName); - _BackgroundCanvas.SizeChanged += BackgroundCanvas_SizeChanged; - _TextOverlaysCanvas.CreateResources += _TextOverlaysCanvas_CreateResources; - _TextOverlaysCanvas.Draw += TextOverlaysCanvas_Draw; - _SyntaxErrorToolTip.Closed += delegate { ContentScroller.IsHitTestVisible = true; }; + this._BackgroundCanvas.SizeChanged += BackgroundCanvas_SizeChanged; + this._TextOverlaysCanvas.CreateResources += _TextOverlaysCanvas_CreateResources; + this._TextOverlaysCanvas.Draw += TextOverlaysCanvas_Draw; + this._SyntaxErrorToolTip.Closed += delegate { ContentScroller.IsHitTestVisible = true; }; ContentScroller.Loaded += ContentElement_Loaded; ContentElement.SizeChanged += ContentElement_SizeChanged; - ContentScroller.StartExpressionAnimation(_TextOverlaysCanvas, Axis.X, VisualProperty.Offset); - ContentScroller.StartExpressionAnimation(_TextOverlaysCanvas, Axis.Y, VisualProperty.Offset); - ContentScroller.StartExpressionAnimation(_SelectionHighlightBorder, Axis.Y, VisualProperty.Offset); - ContentScroller.StartExpressionAnimation(_CursorIndicatorRectangle, Axis.X, VisualProperty.Offset); - ContentScroller.StartExpressionAnimation(_CursorIndicatorRectangle, Axis.Y, VisualProperty.Offset); + ContentScroller.StartExpressionAnimation(this._TextOverlaysCanvas, Axis.X, VisualProperty.Offset); + ContentScroller.StartExpressionAnimation(this._TextOverlaysCanvas, Axis.Y, VisualProperty.Offset); + ContentScroller.StartExpressionAnimation(this._SelectionHighlightBorder, Axis.Y, VisualProperty.Offset); + ContentScroller.StartExpressionAnimation(this._CursorIndicatorRectangle, Axis.X, VisualProperty.Offset); + ContentScroller.StartExpressionAnimation(this._CursorIndicatorRectangle, Axis.Y, VisualProperty.Offset); UpdateVisualElementsOnThemeChanged(SyntaxHighlightTheme); } @@ -145,7 +145,7 @@ protected override void OnApplyTemplate() /// The for private void BackgroundCanvas_SizeChanged(object sender, SizeChangedEventArgs e) { - _SelectionHighlightBorder!.Width = e.NewSize.Width; + this._SelectionHighlightBorder!.Width = e.NewSize.Width; } /// @@ -155,11 +155,11 @@ private void BackgroundCanvas_SizeChanged(object sender, SizeChangedEventArgs e) /// The for private void ContentElement_Loaded(object sender, RoutedEventArgs e) { - _VerticalContentScrollBar = (ScrollBar?)ContentScroller!.FindDescendant(VerticalScrollBarName); + this._VerticalContentScrollBar = (ScrollBar?)ContentScroller!.FindDescendant(VerticalScrollBarName); - Guard.IsNotNull(_VerticalContentScrollBar, nameof(ContentScroller)); + Guard.IsNotNull(this._VerticalContentScrollBar, nameof(ContentScroller)); - _VerticalContentScrollBar.Margin = VerticalScrollBarMargin; + this._VerticalContentScrollBar.Margin = VerticalScrollBarMargin; } /// @@ -176,8 +176,8 @@ private void ContentElement_SizeChanged(object sender, SizeChangedEventArgs e) // overlays that were previously out of bounds can become visible. // The height is also considering the top padding set by the user, // plus 20 more DIPs just to be extra safe. - _TextOverlaysCanvas!.Height = e.NewSize.Height + Padding.Top + 20; - _TextOverlaysCanvas.Width = e.NewSize.Width; + this._TextOverlaysCanvas!.Height = e.NewSize.Height + Padding.Top + 20; + this._TextOverlaysCanvas.Width = e.NewSize.Width; } /// @@ -187,7 +187,7 @@ private void ContentElement_SizeChanged(object sender, SizeChangedEventArgs e) /// Whether or not the theme change was applied private bool TryUpdateVisualElementsOnThemeChanged(Brainf_ckTheme theme) { - if (_SelectionHighlightBorder is null) return false; + if (this._SelectionHighlightBorder is null) return false; UpdateVisualElementsOnThemeChanged(theme); @@ -203,14 +203,14 @@ private void UpdateVisualElementsOnThemeChanged(Brainf_ckTheme theme) switch (theme.LineHighlightStyle) { case LineHighlightStyle.Outline: - _SelectionHighlightBorder!.BorderThickness = new Thickness(2); - _SelectionHighlightBorder.BorderBrush = new SolidColorBrush(theme.LineHighlightColor); - _SelectionHighlightBorder.Background = null; + this._SelectionHighlightBorder!.BorderThickness = new Thickness(2); + this._SelectionHighlightBorder.BorderBrush = new SolidColorBrush(theme.LineHighlightColor); + this._SelectionHighlightBorder.Background = null; break; case LineHighlightStyle.Fill: - _SelectionHighlightBorder!.BorderThickness = default; - _SelectionHighlightBorder.BorderBrush = null; - _SelectionHighlightBorder.Background = new SolidColorBrush(theme.LineHighlightColor); + this._SelectionHighlightBorder!.BorderThickness = default; + this._SelectionHighlightBorder.BorderBrush = null; + this._SelectionHighlightBorder.Background = new SolidColorBrush(theme.LineHighlightColor); break; default: ThrowHelper.ThrowArgumentException("Invalid line highlight style"); diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Win2D.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Win2D.cs index d607340f..9a8f9048 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Win2D.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.Win2D.cs @@ -93,7 +93,7 @@ private void _TextOverlaysCanvas_CreateResources(CanvasControl sender, CanvasCre CanvasGeometry canvasGeometry = CanvasGeometry.CreatePath(pathBuilder); - _SquigglyLineGeometry = CanvasCachedGeometry.CreateStroke(canvasGeometry, 1); + this._SquigglyLineGeometry = CanvasCachedGeometry.CreateStroke(canvasGeometry, 1); CreateOverlayResources?.Invoke(sender, args); } @@ -108,18 +108,18 @@ private void TextOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs a float offset = (float)Padding.Top; // Error - if (_ErrorPosition is Vector2 errorPosition) + if (this._ErrorPosition is Vector2 errorPosition) { // Center the line indicator and move it below the referenced text float x = MathF.Max(errorPosition.X, 4), y = errorPosition.Y + offset + 20; - args.DrawingSession.DrawCachedGeometry(_SquigglyLineGeometry, x, y, Colors.Red); + args.DrawingSession.DrawCachedGeometry(this._SquigglyLineGeometry, x, y, Colors.Red); } // Spaces - foreach (Rect spaceArea in _SpaceAreas.Span) + foreach (Rect spaceArea in this._SpaceAreas.Span) { Rect dot = new() { @@ -132,7 +132,7 @@ private void TextOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs a } // Tabs - foreach (Rect tabArea in _TabAreas.Span) + foreach (Rect tabArea in this._TabAreas.Span) { double width = tabArea.Right - tabArea.Left; if (width < 12) @@ -161,16 +161,16 @@ private void TextOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs a } // Column guides - foreach (ColumnGuideInfo guideInfo in _ColumnGuides.Span) + foreach (ColumnGuideInfo guideInfo in this._ColumnGuides.Span) { args.DrawingSession.DrawLine( guideInfo.X + 0.5f, guideInfo.Y - 0.5f + offset, guideInfo.X + 0.5f, guideInfo.Y + guideInfo.Height + 0.5f + offset, - _DashStrokeColor, + this._DashStrokeColor, 1, - _DashStrokeStyle); + this._DashStrokeStyle); } DrawOverlays?.Invoke(sender, args); @@ -181,10 +181,10 @@ private void TextOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs a /// private void ResetWhitespaceCharactersList() { - _SpaceIndices = MemoryOwner.Empty; - _SpaceAreas = MemoryOwner.Empty; - _TabIndices = MemoryOwner.Empty; - _TabAreas = MemoryOwner.Empty; + this._SpaceIndices = MemoryOwner.Empty; + this._SpaceAreas = MemoryOwner.Empty; + this._TabIndices = MemoryOwner.Empty; + this._TabAreas = MemoryOwner.Empty; } /// @@ -222,17 +222,17 @@ private void TryUpdateWhitespaceCharactersList() } // Dispose the previous buffers - _SpaceIndices.Dispose(); - _TabIndices.Dispose(); - _SpaceAreas.Dispose(); - _TabAreas.Dispose(); + this._SpaceIndices.Dispose(); + this._TabIndices.Dispose(); + this._SpaceAreas.Dispose(); + this._TabAreas.Dispose(); // Update the current data - _SpaceIndices = spaces.Slice(0, spacesCount); - _TabIndices = tabs.Slice(0, tabsCount); + this._SpaceIndices = spaces.Slice(0, spacesCount); + this._TabIndices = tabs.Slice(0, tabsCount); - ProcessWhitespaceCharactersList(ref _SpaceIndices, out _SpaceAreas); - ProcessWhitespaceCharactersList(ref _TabIndices, out _TabAreas); + ProcessWhitespaceCharactersList(ref this._SpaceIndices, out this._SpaceAreas); + ProcessWhitespaceCharactersList(ref this._TabIndices, out this._TabAreas); } /// @@ -266,10 +266,10 @@ private void ProcessWhitespaceCharactersList(ref MemoryOwner indices, out M /// private void TryUpdateBracketsList() { - if (!_SyntaxValidationResult.IsSuccessOrEmptyScript) + if (!this._SyntaxValidationResult.IsSuccessOrEmptyScript) { - _BracketPairs = MemoryOwner.Empty; - _ColumnGuides = MemoryOwner.Empty; + this._BracketPairs = MemoryOwner.Empty; + this._ColumnGuides = MemoryOwner.Empty; return; } @@ -340,7 +340,7 @@ private void TryUpdateBracketsList() } // Skip the update if both sequences match - if (_BracketPairs.Span.AsBytes().SequenceEqual(jumpTable.Span.AsBytes())) + if (this._BracketPairs.Span.AsBytes().SequenceEqual(jumpTable.Span.AsBytes())) { jumpTable.Dispose(); @@ -348,8 +348,8 @@ private void TryUpdateBracketsList() } // Update the current brackets sequence - _BracketPairs.Dispose(); - _BracketPairs = jumpTable.Slice(0, jumps); + this._BracketPairs.Dispose(); + this._BracketPairs = jumpTable.Slice(0, jumps); // Processes the computed data ProcessBracketsList(); @@ -360,13 +360,13 @@ private void TryUpdateBracketsList() /// private void ProcessBracketsList() { - _ColumnGuides.Dispose(); + this._ColumnGuides.Dispose(); // Update the target buffer - MemoryOwner bracketPairs = _BracketPairs; + MemoryOwner bracketPairs = this._BracketPairs; MemoryOwner columnGuides = MemoryOwner.Allocate(bracketPairs.Length); - _ColumnGuides = columnGuides; + this._ColumnGuides = columnGuides; // Skip if there are no brackets to render if (columnGuides.Length == 0) return; @@ -397,16 +397,16 @@ private void ProcessBracketsList() /// private void TryProcessErrorCoordinate() { - if (_SyntaxValidationResult.IsSuccessOrEmptyScript) + if (this._SyntaxValidationResult.IsSuccessOrEmptyScript) { - _ErrorPosition = null; + this._ErrorPosition = null; return; } // Get the range for the current error - Document.GetRangeAt(_SyntaxValidationResult.ErrorOffset).GetRect(PointOptions.Transform, out Rect rect, out _); + Document.GetRangeAt(this._SyntaxValidationResult.ErrorOffset).GetRect(PointOptions.Transform, out Rect rect, out _); - _ErrorPosition = new Vector2((float)rect.Left, (float)rect.Top); + this._ErrorPosition = new Vector2((float)rect.Left, (float)rect.Top); } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.cs index 5daac771..d9771a0f 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Brainf_ckEditBox.cs @@ -59,8 +59,8 @@ public Brainf_ckEditBox() /// The instance for the event private void Brainf_ckEditBox_SelectionChanging(RichEditBox sender, RichEditBoxSelectionChangingEventArgs args) { - _SelectionStart = args.SelectionStart; - _SelectionLength = args.SelectionLength; + this._SelectionStart = args.SelectionStart; + this._SelectionLength = args.SelectionLength; IsTextSelected = args.SelectionLength > 0; } @@ -78,20 +78,20 @@ private void Brainf_ckEditBox_SelectionChanged(object sender, RoutedEventArgs e) // Both elements are translated to the right position and made visible // if the current selection is not collapsed to a single point, otherwise // they're both hidden. This is the same behavior of Visual Studio. - if (_SelectionLength > 0) + if (this._SelectionLength > 0) { - _SelectionHighlightBorder!.Opacity = 0; - _CursorIndicatorRectangle!.Visibility = Visibility.Collapsed; + this._SelectionHighlightBorder!.Opacity = 0; + this._CursorIndicatorRectangle!.Visibility = Visibility.Collapsed; } else { // Line highlight - _SelectionHighlightBorder!.Opacity = 1; - ((TranslateTransform)_SelectionHighlightBorder.RenderTransform).Y = rect.Top + Padding.Top; + this._SelectionHighlightBorder!.Opacity = 1; + ((TranslateTransform)this._SelectionHighlightBorder.RenderTransform).Y = rect.Top + Padding.Top; // Cursor indicator - _CursorIndicatorRectangle!.Visibility = Visibility.Visible; - TranslateTransform cursorTransform = (TranslateTransform)_CursorIndicatorRectangle.RenderTransform; + this._CursorIndicatorRectangle!.Visibility = Visibility.Visible; + TranslateTransform cursorTransform = (TranslateTransform)this._CursorIndicatorRectangle.RenderTransform; cursorTransform.X = rect.X + Padding.Left; cursorTransform.Y = rect.Y + Padding.Top; } @@ -152,12 +152,12 @@ private void ScrollToSelection(out Rect rect) /// public async void TryShowSyntaxErrorToolTip() { - if (_SyntaxValidationResult.IsSuccess) return; + if (this._SyntaxValidationResult.IsSuccess) return; - int errorPosition = _SyntaxValidationResult.IsEmptyScript switch + int errorPosition = this._SyntaxValidationResult.IsEmptyScript switch { true => int.MaxValue, - false => _SyntaxValidationResult.ErrorOffset + false => this._SyntaxValidationResult.ErrorOffset }; TaskCompletionSource tcs = new(); @@ -209,13 +209,13 @@ void NotifyViewChanging(object sender, ScrollViewerViewChangingEventArgs e) ContentScroller!.IsHitTestVisible = false; // Reset the target to ensure the right target coordinates are used - _SyntaxErrorToolTip!.IsOpen = false; - _SyntaxErrorToolTip.Target = null; + this._SyntaxErrorToolTip!.IsOpen = false; + this._SyntaxErrorToolTip.Target = null; // Setup and display the tooltip - _SyntaxErrorToolTip.Subtitle = ResourceLoader.GetString($"{nameof(SyntaxError)}/{_SyntaxValidationResult.ErrorType}"); - _SyntaxErrorToolTip.Target = _CursorIndicatorRectangle!; - _SyntaxErrorToolTip!.IsOpen = true; + this._SyntaxErrorToolTip.Subtitle = this.ResourceLoader.GetString($"{nameof(SyntaxError)}/{this._SyntaxValidationResult.ErrorType}"); + this._SyntaxErrorToolTip.Target = this._CursorIndicatorRectangle!; + this._SyntaxErrorToolTip!.IsOpen = true; } /// @@ -251,9 +251,9 @@ private bool IsUndoGroupingEnabled { set { - if (_IsUndoGroupingEnabled != value) + if (this._IsUndoGroupingEnabled != value) { - _IsUndoGroupingEnabled = value; + this._IsUndoGroupingEnabled = value; if (value) Document.BeginUndoGroup(); else Document.EndUndoGroup(); } @@ -281,7 +281,7 @@ protected override void OnKeyDown(KeyRoutedEventArgs e) { // Disable the unwanted shortcuts bool ctrl = VirtualKey.Control.IsDown(); - if (ctrl && IgnoredShortcuts.Contains(e.Key)) + if (ctrl && this.IgnoredShortcuts.Contains(e.Key)) { goto HandleAndReturn; } @@ -298,7 +298,7 @@ protected override void OnKeyDown(KeyRoutedEventArgs e) if (e.Key == VirtualKey.Back || e.Key == VirtualKey.Delete) { - _IsDeleteRequested = true; + this._IsDeleteRequested = true; goto BaseOnKeyDown; } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/BracketsPairInfo.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/BracketsPairInfo.cs index 13027f1d..6f1dc6f4 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/BracketsPairInfo.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/BracketsPairInfo.cs @@ -22,7 +22,7 @@ internal readonly struct BracketsPairInfo /// The offset of the right bracket public BracketsPairInfo(int start, int end) { - Start = start; - End = end; + this.Start = start; + this.End = end; } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/ColumnGuideInfo.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/ColumnGuideInfo.cs index 7a6bf798..4f4a56d4 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/ColumnGuideInfo.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckEditBox/Models/ColumnGuideInfo.cs @@ -28,8 +28,8 @@ internal readonly struct ColumnGuideInfo /// The line height public ColumnGuideInfo(float x, float y, float height) { - X = x; - Y = y; - Height = height; + this.X = x; + this.Y = y; + this.Height = height; } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Methods.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Methods.cs index cdc2fa74..7dbb91cb 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Methods.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Methods.cs @@ -26,13 +26,13 @@ public sealed partial class Brainf_ckIde /// public void LoadText(string text) { - _LoadedText = text.WithCarriageReturnLineEndings(); + this._LoadedText = text.WithCarriageReturnLineEndings(); - _DiffIndicators.Span.Clear(); + this._DiffIndicators.Span.Clear(); - BreakpointIndicators.Clear(); + this.BreakpointIndicators.Clear(); - CodeEditBox.Document.LoadFromString(text); + this.CodeEditBox.Document.LoadFromString(text); } /// @@ -40,11 +40,11 @@ public void LoadText(string text) /// public void MarkTextAsSaved() { - _LoadedText = CodeEditBox.Text; + this._LoadedText = this.CodeEditBox.Text; UpdateDiffInfo(); - IdeOverlaysCanvas.Invalidate(); + this.IdeOverlaysCanvas.Invalidate(); } /// @@ -53,7 +53,7 @@ public void MarkTextAsSaved() /// The character to type public void TypeCharacter(char character) { - CodeEditBox.Document.Selection.TypeText(character.ToString()); + this.CodeEditBox.Document.Selection.TypeText(character.ToString()); } /// @@ -62,7 +62,7 @@ public void TypeCharacter(char character) /// The source text to insert public void InsertText(string source) { - CodeEditBox.InsertText(source); + this.CodeEditBox.InsertText(source); } /// @@ -70,7 +70,7 @@ public void InsertText(string source) /// public void DeleteCharacter() { - CodeEditBox.DeleteSelectionOrCharacter(); + this.CodeEditBox.DeleteSelectionOrCharacter(); } /// @@ -82,16 +82,16 @@ public void Move(VirtualKey key) switch (key) { case VirtualKey.Up: - CodeEditBox.Document.Selection.MoveUp(TextRangeUnit.Line, 1, false); + this.CodeEditBox.Document.Selection.MoveUp(TextRangeUnit.Line, 1, false); break; case VirtualKey.Down: - CodeEditBox.Document.Selection.MoveDown(TextRangeUnit.Line, 1, false); + this.CodeEditBox.Document.Selection.MoveDown(TextRangeUnit.Line, 1, false); break; case VirtualKey.Left: - CodeEditBox.Document.Selection.MoveLeft(TextRangeUnit.Character, 1, false); + this.CodeEditBox.Document.Selection.MoveLeft(TextRangeUnit.Character, 1, false); break; case VirtualKey.Right: - CodeEditBox.Document.Selection.MoveRight(TextRangeUnit.Character, 1, false); + this.CodeEditBox.Document.Selection.MoveRight(TextRangeUnit.Character, 1, false); break; default: ThrowHelper.ThrowArgumentException(nameof(key), "Invalid virtual key"); @@ -108,7 +108,7 @@ public void Move(int row, int column) { int index = Text.CalculateIndex(row, column); - CodeEditBox.Document.Selection.SetRange(index, index); + this.CodeEditBox.Document.Selection.SetRange(index, index); } /// @@ -117,7 +117,7 @@ public void Move(int row, int column) /// A instance with the line numbers with a breakpoint. public IMemoryOwner GetBreakpoints() { - int count = BreakpointIndicators.Count; + int count = this.BreakpointIndicators.Count; if (count == 0) return MemoryOwner.Empty; @@ -128,7 +128,7 @@ public IMemoryOwner GetBreakpoints() int i = 0; // Copy the existing breakpoints - foreach (var pair in BreakpointIndicators) + foreach (var pair in this.BreakpointIndicators) { Unsafe.Add(ref bufferRef, i++) = pair.Key - 1; } @@ -145,7 +145,7 @@ public IMemoryOwner GetBreakpoints() i = 0; int j = 0, k = 0; - foreach (var line in CodeEditBox.Text.Tokenize(Characters.CarriageReturn)) + foreach (var line in this.CodeEditBox.Text.Tokenize(Characters.CarriageReturn)) { // If the current line is marked, do a linear search to find the first operator if (Unsafe.Add(ref bufferRef, i) == j) @@ -174,6 +174,6 @@ public IMemoryOwner GetBreakpoints() /// public void TryShowSyntaxErrorToolTip() { - CodeEditBox.TryShowSyntaxErrorToolTip(); + this.CodeEditBox.TryShowSyntaxErrorToolTip(); } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Properties.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Properties.cs index 2b9c25af..4df29af6 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Properties.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Properties.cs @@ -10,7 +10,7 @@ public sealed partial class Brainf_ckIde /// /// Gets the text currently displayed /// - public string Text => CodeEditBox.Text; + public string Text => this.CodeEditBox.Text; private double _HeaderSpacing; @@ -19,15 +19,15 @@ public sealed partial class Brainf_ckIde /// public double HeaderSpacing { - get => _HeaderSpacing; + get => this._HeaderSpacing; set { - _HeaderSpacing = value; + this._HeaderSpacing = value; - IdeOverlaysCanvasTransform.Y = value + 10; - LineBlockTransform.Y = value + 8; - CodeEditBox.Padding = new Thickness(4, value + 8, 8, FooterSpacing + 8); - CodeEditBox.VerticalScrollBarMargin = new Thickness(0, value, 0, FooterSpacing); + this.IdeOverlaysCanvasTransform.Y = value + 10; + this.LineBlockTransform.Y = value + 8; + this.CodeEditBox.Padding = new Thickness(4, value + 8, 8, FooterSpacing + 8); + this.CodeEditBox.VerticalScrollBarMargin = new Thickness(0, value, 0, FooterSpacing); } } @@ -38,13 +38,13 @@ public double HeaderSpacing /// public double FooterSpacing { - get => _FooterSpacing; + get => this._FooterSpacing; set { - _FooterSpacing = value; + this._FooterSpacing = value; - CodeEditBox.Padding = new Thickness(4, HeaderSpacing + 8, 8, value + 8); - CodeEditBox.VerticalScrollBarMargin = new Thickness(0, HeaderSpacing, 0, value); + this.CodeEditBox.Padding = new Thickness(4, HeaderSpacing + 8, 8, value + 8); + this.CodeEditBox.VerticalScrollBarMargin = new Thickness(0, HeaderSpacing, 0, value); } } @@ -53,8 +53,8 @@ public double FooterSpacing /// public FrameworkElement ContextMenuSecondaryContent { - get => CodeEditBox.ContextMenuSecondaryContent; - set => CodeEditBox.ContextMenuSecondaryContent = value; + get => this.CodeEditBox.ContextMenuSecondaryContent; + set => this.CodeEditBox.ContextMenuSecondaryContent = value; } /// @@ -62,8 +62,8 @@ public FrameworkElement ContextMenuSecondaryContent /// public bool RenderWhitespaceCharacters { - get => CodeEditBox.RenderWhitespaceCharacters; - set => CodeEditBox.RenderWhitespaceCharacters = value; + get => this.CodeEditBox.RenderWhitespaceCharacters; + set => this.CodeEditBox.RenderWhitespaceCharacters = value; } /// diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Draw.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Draw.cs index c1590929..7340dd18 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Draw.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Draw.cs @@ -48,7 +48,7 @@ private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs ar { // Git diff indicators int i = 0; - foreach (var modification in _DiffIndicators.Span) + foreach (var modification in this._DiffIndicators.Span) { switch (modification) { @@ -65,7 +65,7 @@ private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs ar // Indentation indicators i = 0; - foreach (var indicator in _IndentationIndicators.Span) + foreach (var indicator in this._IndentationIndicators.Span) { if (indicator is not null) { @@ -95,7 +95,7 @@ private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs ar } // Breakpoints markers - foreach (var pair in BreakpointIndicators) + foreach (var pair in this.BreakpointIndicators) { DrawBreakpointIndicator(args.DrawingSession, pair.Value); } @@ -109,7 +109,7 @@ private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs ar private void CodeEditBox_OnDrawOverlays(CanvasControl sender, CanvasDrawEventArgs args) { // Breakpoints areas - foreach (var rect in _BreakpointAreas.Span) + foreach (var rect in this._BreakpointAreas.Span) { DrawBreakpointArea(args.DrawingSession, rect); } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Load.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Load.cs index c32e55a6..84c77bd8 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Load.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.Win2D.Load.cs @@ -25,11 +25,11 @@ public sealed partial class Brainf_ckIde /// The current source code being displayed private void UpdateDiffInfo(string text) { - MemoryOwner diff = LineDiffer.ComputeDiff(_LoadedText, text, Characters.CarriageReturn); + MemoryOwner diff = LineDiffer.ComputeDiff(this._LoadedText, text, Characters.CarriageReturn); - ref LineModificationType oldRef = ref _DiffIndicators.DangerousGetReference(); + ref LineModificationType oldRef = ref this._DiffIndicators.DangerousGetReference(); ref LineModificationType newRef = ref diff.DangerousGetReference(); - int length = Math.Min(_DiffIndicators.Length, diff.Length); + int length = Math.Min(this._DiffIndicators.Length, diff.Length); // Maintain the saved indicators for (int i = 0; i < length; i++) @@ -37,12 +37,12 @@ private void UpdateDiffInfo(string text) Unsafe.Add(ref newRef, i) == LineModificationType.None) Unsafe.Add(ref newRef, i) = LineModificationType.Saved; - _DiffIndicators.Dispose(); + this._DiffIndicators.Dispose(); // The edit box always ends with a final \r that can't be removed by the user. // Slicing out the last item prevents the modified marker from being displayed // below the last line actually being typed by the user. - _DiffIndicators = diff.Slice(0, diff.Length - 1); + this._DiffIndicators = diff.Slice(0, diff.Length - 1); } /// @@ -50,11 +50,11 @@ private void UpdateDiffInfo(string text) /// private void UpdateDiffInfo() { - int size = _DiffIndicators.Length; + int size = this._DiffIndicators.Length; if (size == 0) return; - ref LineModificationType r0 = ref _DiffIndicators.DangerousGetReference(); + ref LineModificationType r0 = ref this._DiffIndicators.DangerousGetReference(); for (int i = 0; i < size; i++) if (Unsafe.Add(ref r0, i) == LineModificationType.Modified) @@ -70,18 +70,18 @@ private void UpdateDiffInfo() private void UpdateIndentationInfo(string text, bool isSyntaxValid, int numberOfLines) { // Return the previous buffer - _IndentationIndicators.Dispose(); + this._IndentationIndicators.Dispose(); // Skip if the current syntax is not valid if (!isSyntaxValid) { - _IndentationIndicators = MemoryOwner.Empty; + this._IndentationIndicators = MemoryOwner.Empty; return; } // Allocate the new buffer - MemoryOwner indicators = _IndentationIndicators = MemoryOwner.Allocate(numberOfLines); + MemoryOwner indicators = this._IndentationIndicators = MemoryOwner.Allocate(numberOfLines); ref IndentationIndicatorBase? indicatorsRef = ref indicators.DangerousGetReference(); // There's always at least one line // Reset the pools @@ -254,16 +254,16 @@ private void UpdateIndentationInfo(string text, bool isSyntaxValid, int numberOf /// private void UpdateBreakpointsInfo() { - int totalBreakpoints = BreakpointIndicators.Count; + int totalBreakpoints = this.BreakpointIndicators.Count; // If there are no breakpoints, do nothing if (totalBreakpoints == 0) { - if (_BreakpointAreas.Length != 0) + if (this._BreakpointAreas.Length != 0) { - _BreakpointAreas.Dispose(); + this._BreakpointAreas.Dispose(); - _BreakpointAreas = MemoryOwner.Empty; + this._BreakpointAreas = MemoryOwner.Empty; } return; @@ -275,7 +275,7 @@ private void UpdateBreakpointsInfo() int currentLineNumber = 0; // Copy the current line numbers to a buffer - foreach (var entry in BreakpointIndicators) + foreach (var entry in this.BreakpointIndicators) { Unsafe.Add(ref lineNumbersRef, currentLineNumber++) = entry.Key; } @@ -328,14 +328,14 @@ private void UpdateBreakpointsInfo() // If there are no operators left, remove the breakpoint if (firstOperatorOffset == -1) { - BreakpointIndicators.Remove(currentTargetLineNumber); + this.BreakpointIndicators.Remove(currentTargetLineNumber); totalBreakpoints--; } else { // Get the text range for the first operators interval - ITextRange range = CodeEditBox.Document.GetRange( + ITextRange range = this.CodeEditBox.Document.GetRange( currentTextIndex + firstOperatorOffset, currentTextIndex + lastOperatorOffset + 1); @@ -357,8 +357,8 @@ out Unsafe.Add(ref breakpointAreasRef, validatedBreakpoints++), currentTextIndex += line.Length + 1; } - _BreakpointAreas.Dispose(); + this._BreakpointAreas.Dispose(); - _BreakpointAreas = breakpointAreas.Slice(0, validatedBreakpoints); + this._BreakpointAreas = breakpointAreas.Slice(0, validatedBreakpoints); } } diff --git a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.cs b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.cs index 0ecbafcf..a6b90cb5 100644 --- a/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.cs +++ b/src/Brainf_ckSharp.Uwp.Controls.Ide/Brainf_ckIde/Brainf_ckIde.xaml.cs @@ -32,16 +32,16 @@ public Brainf_ckIde() /// The instance for the event private void Brainf_ckIde_Loaded(object sender, RoutedEventArgs e) { - CodeEditBox.ContentScroller!.StartExpressionAnimation(LineBlock, Axis.Y, VisualProperty.Offset); - CodeEditBox.ContentScroller.StartExpressionAnimation(IdeOverlaysCanvas, Axis.Y, VisualProperty.Offset); - CodeEditBox.ContentElement!.SizeChanged += Brainf_ckIde_SizeChanged; + this.CodeEditBox.ContentScroller!.StartExpressionAnimation(this.LineBlock, Axis.Y, VisualProperty.Offset); + this.CodeEditBox.ContentScroller.StartExpressionAnimation(this.IdeOverlaysCanvas, Axis.Y, VisualProperty.Offset); + this.CodeEditBox.ContentElement!.SizeChanged += Brainf_ckIde_SizeChanged; // Manually adjust the Win2D canvas size here, since when this handler runs // for the code editor, the first size changed event for the inner content // element has already been raised. Doing this fixes the Win2D canvas // size without the user having to first manually resize the app window. - IdeOverlaysCanvas.Height = CodeEditBox.ContentElement.ActualHeight; - IdeOverlaysCanvas.Width = CodeEditBox.ContentElement.ActualWidth + 72; + this.IdeOverlaysCanvas.Height = this.CodeEditBox.ContentElement.ActualHeight; + this.IdeOverlaysCanvas.Width = this.CodeEditBox.ContentElement.ActualWidth + 72; } /// @@ -51,8 +51,8 @@ private void Brainf_ckIde_Loaded(object sender, RoutedEventArgs e) /// The for private void Brainf_ckIde_SizeChanged(object sender, SizeChangedEventArgs e) { - IdeOverlaysCanvas.Height = e.NewSize.Height + 20; - IdeOverlaysCanvas.Width = e.NewSize.Width + 72; + this.IdeOverlaysCanvas.Height = e.NewSize.Height + 20; + this.IdeOverlaysCanvas.Width = e.NewSize.Width + 72; } /// @@ -80,7 +80,7 @@ private void CodeEditBox_TextChanged(Brainf_ckEditBox sender, TextChangedEventAr UpdateDiffInfo(args.PlainText); UpdateIndentationInfo(args.PlainText, args.ValidationResult.IsSuccessOrEmptyScript, numberOfLines); - IdeOverlaysCanvas.Invalidate(); + this.IdeOverlaysCanvas.Invalidate(); } /// @@ -99,7 +99,7 @@ private void CodeEditBox_CursorPositionChanged(Brainf_ckEditBox sender, CursorPo /// The current number of lines being displayed private void UpdateLineIndicators(int numberOfLines) { - LineBlock.Text = TextGenerator.GetLineNumbersText(numberOfLines); + this.LineBlock.Text = TextGenerator.GetLineNumbersText(numberOfLines); } /// @@ -112,40 +112,40 @@ private void BreakpointsCanvas_Tapped(object sender, TappedRoutedEventArgs e) // Calculate the target vertical offset for the tap double yOffset = e.GetPosition((Border)sender).Y - 8 - // Tap Y offset and adjustment - CodeEditBox.VerticalScrollBarMargin.Top + // Top internal padding - CodeEditBox.ContentScroller!.VerticalOffset; // Vertical scroll offset + this.CodeEditBox.VerticalScrollBarMargin.Top + // Top internal padding + this.CodeEditBox.ContentScroller!.VerticalOffset; // Vertical scroll offset // Get the range aligned to the left edge of the tapped line - ITextRange range = CodeEditBox.Document.GetRangeFromPoint(new Point(0, yOffset), PointOptions.ClientCoordinates); + ITextRange range = this.CodeEditBox.Document.GetRangeFromPoint(new Point(0, yOffset), PointOptions.ClientCoordinates); range.GetRect(PointOptions.Transform, out Rect line, out _); // Get the line number - int lineNumber = CodeEditBox.Text.AsSpan(0, range.StartPosition).Count(Characters.CarriageReturn) + 1; + int lineNumber = this.CodeEditBox.Text.AsSpan(0, range.StartPosition).Count(Characters.CarriageReturn) + 1; if (lineNumber == 1) return; // Store or remove the breakpoint - if (BreakpointIndicators.ContainsKey(lineNumber)) + if (this.BreakpointIndicators.ContainsKey(lineNumber)) { - BreakpointIndicators.Remove(lineNumber); + this.BreakpointIndicators.Remove(lineNumber); - if (BreakpointIndicators.Count == 0) BreakpointsBorder.ContextFlyout = null; + if (this.BreakpointIndicators.Count == 0) this.BreakpointsBorder.ContextFlyout = null; - BreakpointRemoved?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); + BreakpointRemoved?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, this.BreakpointIndicators.Count)); } else { - if (BreakpointIndicators.Count == 0) BreakpointsBorder.ContextFlyout = BreakpointsMenuFlyout; + if (this.BreakpointIndicators.Count == 0) this.BreakpointsBorder.ContextFlyout = this.BreakpointsMenuFlyout; - BreakpointIndicators.GetOrAddValueRef(lineNumber) = (float)line.Top; + this.BreakpointIndicators.GetOrAddValueRef(lineNumber) = (float)line.Top; - BreakpointAdded?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, BreakpointIndicators.Count)); + BreakpointAdded?.Invoke(this, new BreakpointToggleEventArgs(lineNumber, this.BreakpointIndicators.Count)); } UpdateBreakpointsInfo(); - IdeOverlaysCanvas.Invalidate(); - CodeEditBox.InvalidateOverlays(); + this.IdeOverlaysCanvas.Invalidate(); + this.CodeEditBox.InvalidateOverlays(); } /// @@ -155,13 +155,13 @@ private void BreakpointsCanvas_Tapped(object sender, TappedRoutedEventArgs e) /// The for the current event private void RemoveAllBreakpointsButton_Clicked(object sender, RoutedEventArgs e) { - BreakpointsCleared?.Invoke(this, BreakpointIndicators.Count); + BreakpointsCleared?.Invoke(this, this.BreakpointIndicators.Count); - BreakpointIndicators.Clear(); + this.BreakpointIndicators.Clear(); UpdateBreakpointsInfo(); - IdeOverlaysCanvas.Invalidate(); - CodeEditBox.InvalidateOverlays(); + this.IdeOverlaysCanvas.Invalidate(); + this.CodeEditBox.InvalidateOverlays(); } } diff --git a/src/Brainf_ckSharp.Uwp.Themes/Brainf_ckTheme.cs b/src/Brainf_ckSharp.Uwp.Themes/Brainf_ckTheme.cs index 7e7c72fd..5c411136 100644 --- a/src/Brainf_ckSharp.Uwp.Themes/Brainf_ckTheme.cs +++ b/src/Brainf_ckSharp.Uwp.Themes/Brainf_ckTheme.cs @@ -73,10 +73,10 @@ public Brainf_ckTheme( BracketsGuideColor = bracketsGuide; BracketsGuideStrokesLength = bracketsGuideStrokesLength; CommentsColor = comments; - CommentsBrush = new SolidColorBrush(comments); + this.CommentsBrush = new SolidColorBrush(comments); LineHighlightStyle = lineStyle; LineHighlightColor = lineColor; - HighlightColorMap = new Dictionary + this.HighlightColorMap = new Dictionary { [Characters.BackwardPtr] = arrows, [Characters.ForwardPtr] = arrows, @@ -90,7 +90,7 @@ public Brainf_ckTheme( [Characters.FunctionEnd] = function, [Characters.FunctionCall] = call }; - HighlightBrushMap = HighlightColorMap.ToDictionary(p => p.Key, p => new SolidColorBrush(p.Value)); + this.HighlightBrushMap = this.HighlightColorMap.ToDictionary(p => p.Key, p => new SolidColorBrush(p.Value)); } /// @@ -164,7 +164,7 @@ public static bool HaveSameColor(char first, char second) /// The character to parse /// The value for the input character [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Color GetColor(char c) => HighlightColorMap.TryGetValue(c, out Color color) ? color : CommentsColor; + public Color GetColor(char c) => this.HighlightColorMap.TryGetValue(c, out Color color) ? color : CommentsColor; /// /// Gets the corresponding from a given character in a Brainf*ck/PBrain source code @@ -172,5 +172,5 @@ public static bool HaveSameColor(char first, char second) /// The character to parse /// The value for the input character [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Brush GetBrush(char c) => HighlightBrushMap.TryGetValue(c, out SolidColorBrush brush) ? brush : CommentsBrush; + public Brush GetBrush(char c) => this.HighlightBrushMap.TryGetValue(c, out SolidColorBrush brush) ? brush : this.CommentsBrush; } diff --git a/src/Brainf_ckSharp.Uwp/App.xaml.cs b/src/Brainf_ckSharp.Uwp/App.xaml.cs index ea8feb28..92b9e828 100644 --- a/src/Brainf_ckSharp.Uwp/App.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/App.xaml.cs @@ -51,14 +51,14 @@ public sealed partial class App : Application /// /// Gets whether or not there is a file request pending /// - public bool IsFileRequestPending => _RequestedFile is not null; + public bool IsFileRequestPending => this._RequestedFile is not null; public SubPageHost? _SubPageHost; /// /// Gets the instance used to display popups in the app /// - public SubPageHost SubPageHost => _SubPageHost ??= Window.Current.Content.FindDescendant()!; + public SubPageHost SubPageHost => this._SubPageHost ??= Window.Current.Content.FindDescendant()!; /// /// Extracts the current file request, if present @@ -67,9 +67,9 @@ public sealed partial class App : Application /// Whether or not a requested file was present public bool TryExtractRequestedFile(out IFile? file) { - file = _RequestedFile; + file = this._RequestedFile; - _RequestedFile = null; + this._RequestedFile = null; return file is not null; } @@ -89,9 +89,9 @@ protected override void OnFileActivated(FileActivatedEventArgs args) { if (args.Files.FirstOrDefault() is StorageFile file) { - _RequestedFile = new File(file); + this._RequestedFile = new File(file); } - else _RequestedFile = null; + else this._RequestedFile = null; OnActivated(false); @@ -124,7 +124,7 @@ protected override async void OnActivated(IActivatedEventArgs args) StorageFile file = await StorageFile.GetFileFromPathAsync(unescapedPath); - _RequestedFile = new File(file); + this._RequestedFile = new File(file); } // Then only if this is not a new app instance, focus the IDE diff --git a/src/Brainf_ckSharp.Uwp/Behaviors/LockedPivotBehavior.cs b/src/Brainf_ckSharp.Uwp/Behaviors/LockedPivotBehavior.cs index 07f67afe..912f42b2 100644 --- a/src/Brainf_ckSharp.Uwp/Behaviors/LockedPivotBehavior.cs +++ b/src/Brainf_ckSharp.Uwp/Behaviors/LockedPivotBehavior.cs @@ -34,13 +34,13 @@ protected override void OnDetaching() AssociatedObject.Loaded -= AssociatedObject_Loaded; - if (_scrollViewer is not null) + if (this._scrollViewer is not null) { - _scrollViewer!.PointerEntered -= Scroller_PointerIn; - _scrollViewer.PointerMoved -= Scroller_PointerIn; - _scrollViewer.PointerExited -= Scroller_PointerOut; - _scrollViewer.PointerReleased -= Scroller_PointerOut; - _scrollViewer.PointerCaptureLost -= Scroller_PointerOut; + this._scrollViewer!.PointerEntered -= Scroller_PointerIn; + this._scrollViewer.PointerMoved -= Scroller_PointerIn; + this._scrollViewer.PointerExited -= Scroller_PointerOut; + this._scrollViewer.PointerReleased -= Scroller_PointerOut; + this._scrollViewer.PointerCaptureLost -= Scroller_PointerOut; } } @@ -54,14 +54,14 @@ private void AssociatedObject_Loaded(object sender, RoutedEventArgs e) return; } - _scrollViewer = scroller; + this._scrollViewer = scroller; // Add the handlers to disable the swipe gestures - _scrollViewer.PointerEntered += Scroller_PointerIn; - _scrollViewer.PointerMoved += Scroller_PointerIn; - _scrollViewer.PointerExited += Scroller_PointerOut; - _scrollViewer.PointerReleased += Scroller_PointerOut; - _scrollViewer.PointerCaptureLost += Scroller_PointerOut; + this._scrollViewer.PointerEntered += Scroller_PointerIn; + this._scrollViewer.PointerMoved += Scroller_PointerIn; + this._scrollViewer.PointerExited += Scroller_PointerOut; + this._scrollViewer.PointerReleased += Scroller_PointerOut; + this._scrollViewer.PointerCaptureLost += Scroller_PointerOut; } // Disables the swipe gesture for the keyboard pivot (swiping that pivot causes the app to crash) diff --git a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs index 291c5a3e..dcc906b3 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs @@ -29,7 +29,7 @@ public DeveloperTemplate() public User? ViewModel => DataContext as User; // Hides the progress ring - private void ImageExBase_OnImageExOpened(object sender, ImageExOpenedEventArgs e) => LoadingRing.Visibility = Visibility.Collapsed; + private void ImageExBase_OnImageExOpened(object sender, ImageExOpenedEventArgs e) => this.LoadingRing.Visibility = Visibility.Collapsed; // Opens the profile page of the current contributor private void Contributor_Clicked(object sender, RoutedEventArgs e) diff --git a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/JumpList/SemanticZoomZoomedOutViewHeaderTemplate.cs b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/JumpList/SemanticZoomZoomedOutViewHeaderTemplate.cs index fe0dbd74..5267fde1 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/JumpList/SemanticZoomZoomedOutViewHeaderTemplate.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/JumpList/SemanticZoomZoomedOutViewHeaderTemplate.cs @@ -23,14 +23,14 @@ protected override void OnApplyTemplate() { base.OnApplyTemplate(); - _DescriptionBlock = GetTemplateChild("DescriptionBlock") as TextBlock + this._DescriptionBlock = GetTemplateChild("DescriptionBlock") as TextBlock ?? ThrowHelper.ThrowInvalidOperationException("Failed to find description block"); // Load the span explicitly, if present if (DescriptionSpan is { } span) { - _DescriptionBlock.Inlines.Clear(); - _DescriptionBlock.Inlines.Add(span); + this._DescriptionBlock.Inlines.Clear(); + this._DescriptionBlock.Inlines.Add(span); } } diff --git a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs index d5a94c78..fa2179cb 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs @@ -28,10 +28,10 @@ protected override void OnApplyTemplate() { base.OnApplyTemplate(); - _RootButton = (Button?)GetTemplateChild(RootButtonName) + this._RootButton = (Button?)GetTemplateChild(RootButtonName) ?? ThrowHelper.ThrowInvalidOperationException private void Border_SizeChanged(object sender, SizeChangedEventArgs e) { - if (Math.Abs(_previousKeyboardHeight - e.NewSize.Height) > 0.01) + if (Math.Abs(this._previousKeyboardHeight - e.NewSize.Height) > 0.01) { - _previousKeyboardHeight = e.NewSize.Height; + this._previousKeyboardHeight = e.NewSize.Height; - ConsolePivotItem.FooterSpacing = e.NewSize.Height; - IdePivotItem.FooterSpacing = e.NewSize.Height; + this.ConsolePivotItem.FooterSpacing = e.NewSize.Height; + this.IdePivotItem.FooterSpacing = e.NewSize.Height; } } } diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs index f1c00493..41d08201 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs @@ -53,10 +53,10 @@ public SubPageHost() // Other sub page settings CoreApplicationViewTitleBar titleBar = CoreApplication.GetCurrentView().TitleBar; - _IsTitleBarVisible = titleBar.IsVisible; + this._IsTitleBarVisible = titleBar.IsVisible; titleBar.IsVisibleChanged += (s, e) => { - _IsTitleBarVisible = s.IsVisible; + this._IsTitleBarVisible = s.IsVisible; UpdateLayout(new Size(ActualWidth, ActualHeight)); }; } @@ -66,12 +66,12 @@ public SubPageHost() /// private object? SubPage { - get => HostControl.Content; + get => this.HostControl.Content; set { - if (value == null && HostControl.Content != null) SizeChanged -= SubFrameHost_SizeChanged; - else if (value != null && HostControl.Content == null) SizeChanged += SubFrameHost_SizeChanged; - HostControl.Content = value; + if (value == null && this.HostControl.Content != null) SizeChanged -= SubFrameHost_SizeChanged; + else if (value != null && this.HostControl.Content == null) SizeChanged += SubFrameHost_SizeChanged; + this.HostControl.Content = value; UpdateLayout(new Size(ActualWidth, ActualHeight)); SizeChanged += SubFrameHost_SizeChanged; } @@ -83,26 +83,26 @@ private object? SubPage /// The page to display public async void DisplaySubFramePage(UserControl subPage) { - using (await SubFrameLock.LockAsync()) + using (await this.SubFrameLock.LockAsync()) { // Fade out the current content, if present if (SubPage is UserControl page) { page.IsHitTestVisible = false; - SubFrameContentHost.Visibility = Visibility.Collapsed; + this.SubFrameContentHost.Visibility = Visibility.Collapsed; await Task.Delay(400); // Time for the animations to complete SubPage = subPage; - SubFrameContentHost.Visibility = Visibility.Visible; + this.SubFrameContentHost.Visibility = Visibility.Visible; } else { // Fade in the new sub page - LoadingRing.Visibility = Visibility.Collapsed; // Hide the progress ring, if present + this.LoadingRing.Visibility = Visibility.Collapsed; // Hide the progress ring, if present SubPage = subPage; - RootGrid.Visibility = SubFrameContentHost.Visibility = Visibility.Visible; + this.RootGrid.Visibility = this.SubFrameContentHost.Visibility = Visibility.Visible; } - HostControl.Focus(FocusState.Keyboard); + this.HostControl.Focus(FocusState.Keyboard); subPage.IsHitTestVisible = true; } } @@ -112,12 +112,12 @@ public async void DisplaySubFramePage(UserControl subPage) /// public async void CloseSubFramePage() { - using (await SubFrameLock.LockAsync()) + using (await this.SubFrameLock.LockAsync()) { if (SubPage is not UserControl page) return; page.IsHitTestVisible = false; - RootGrid.Visibility = SubFrameContentHost.Visibility = Visibility.Collapsed; + this.RootGrid.Visibility = this.SubFrameContentHost.Visibility = Visibility.Collapsed; await Task.Delay(600); // Time for the animations to complete SubPage = null; } @@ -144,7 +144,7 @@ private void UpdateLayout(Size size) void UpdateLayout(double width, double height) { // Setup - RootGrid.BorderThickness = new Thickness(); + this.RootGrid.BorderThickness = new Thickness(); Thickness contentBorderThickness = new(1); // Adjust the content width @@ -159,34 +159,34 @@ void UpdateLayout(double width, double height) // Adjust the content height if (double.IsNaN(height)) { - ContentGrid.MaxHeight = double.PositiveInfinity; + this.ContentGrid.MaxHeight = double.PositiveInfinity; contentBorderThickness.Top = contentBorderThickness.Bottom = 0; // Visual state update if (targetWidth > size.Width - 48 * 2) { - ContentGrid.MaxWidth = targetWidth; - VisualStateManager.GoToState(this, nameof(TopBackButton), false); - CloseButton.Visibility = Visibility.Collapsed; + this.ContentGrid.MaxWidth = targetWidth; + VisualStateManager.GoToState(this, nameof(this.TopBackButton), false); + this.CloseButton.Visibility = Visibility.Collapsed; } else { - ContentGrid.MaxWidth = targetWidth + 48; - VisualStateManager.GoToState(this, nameof(LeftBackButton), false); - CloseButton.Visibility = Visibility.Visible; + this.ContentGrid.MaxWidth = targetWidth + 48; + VisualStateManager.GoToState(this, nameof(this.LeftBackButton), false); + this.CloseButton.Visibility = Visibility.Visible; } } else { - ContentGrid.MaxHeight = height + 48; - ContentGrid.MaxWidth = targetWidth; - VisualStateManager.GoToState(this, nameof(TopBackButton), false); - CloseButton.Visibility = Visibility.Visible; + this.ContentGrid.MaxHeight = height + 48; + this.ContentGrid.MaxWidth = targetWidth; + VisualStateManager.GoToState(this, nameof(this.TopBackButton), false); + this.CloseButton.Visibility = Visibility.Visible; } // Final setup - ContentBorder.BorderThickness = contentBorderThickness; - ContentBorder.CornerRadius = new CornerRadius(contentBorderThickness == new Thickness(1) ? 1 : 0); + this.ContentBorder.BorderThickness = contentBorderThickness; + this.ContentBorder.CornerRadius = new CornerRadius(contentBorderThickness == new Thickness(1) ? 1 : 0); } // Updates the layout according to the current type of content @@ -225,7 +225,7 @@ void UpdateLayout(double width, double height) // Additional UI tweaks if (SubPage is IAdaptiveSubPage adaptive) { - adaptive.IsFullHeight = double.IsPositiveInfinity(ContentGrid.MaxHeight) && _IsTitleBarVisible; + adaptive.IsFullHeight = double.IsPositiveInfinity(this.ContentGrid.MaxHeight) && this._IsTitleBarVisible; } } } diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/CodeSampleTemplate.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/CodeSampleTemplate.xaml.cs index 89639e2c..ff4dc281 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/CodeSampleTemplate.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/CodeSampleTemplate.xaml.cs @@ -21,8 +21,8 @@ public CodeSampleTemplate() /// public string Title { - get => TitleBlock.Text; - set => TitleBlock.Text = value; + get => this.TitleBlock.Text; + set => this.TitleBlock.Text = value; } /// diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/OperatorInfoTemplate.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/OperatorInfoTemplate.xaml.cs index 11f7d641..ae535825 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/OperatorInfoTemplate.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Shell/UserGuide/Templates/OperatorInfoTemplate.xaml.cs @@ -21,8 +21,8 @@ public OperatorInfoTemplate() /// public string ItemName { - get => ItemNameBlock.Text; - set => ItemNameBlock.Text = value; + get => this.ItemNameBlock.Text; + set => this.ItemNameBlock.Text = value; } /// @@ -30,8 +30,8 @@ public string ItemName /// public Brush ItemNameForegroundBrush { - get => ItemNameBlock.Foreground; - set => ItemNameBlock.Foreground = value; + get => this.ItemNameBlock.Foreground; + set => this.ItemNameBlock.Foreground = value; } /// @@ -39,7 +39,7 @@ public Brush ItemNameForegroundBrush /// public string Description { - get => DescriptionBlock.Text; - set => DescriptionBlock.Text = value; + get => this.DescriptionBlock.Text; + set => this.DescriptionBlock.Text = value; } } diff --git a/src/Brainf_ckSharp.Uwp/Helpers/TimelineService.cs b/src/Brainf_ckSharp.Uwp/Helpers/TimelineService.cs index 9ba6665c..91a77dd3 100644 --- a/src/Brainf_ckSharp.Uwp/Helpers/TimelineService.cs +++ b/src/Brainf_ckSharp.Uwp/Helpers/TimelineService.cs @@ -59,7 +59,7 @@ public sealed class TimelineService : IFilesHistoryService /// public async Task LogOrUpdateActivityAsync(IFile file) { - using (await TimelineMutex.LockAsync()) + using (await this.TimelineMutex.LockAsync()) { // Load the template, if needed if (_Template is null) @@ -95,25 +95,25 @@ public async Task LogOrUpdateActivityAsync(IFile file) await activity.SaveAsync(); // Update the activity currently in use - _Session?.Dispose(); - _Session = activity.CreateSession(); + this._Session?.Dispose(); + this._Session = activity.CreateSession(); } } /// public async Task DismissCurrentActivityAsync() { - using (await TimelineMutex.LockAsync()) + using (await this.TimelineMutex.LockAsync()) { - _Session?.Dispose(); - _Session = null; + this._Session?.Dispose(); + this._Session = null; } } /// public async Task RemoveActivityAsync(IFile file) { - using (await TimelineMutex.LockAsync()) + using (await this.TimelineMutex.LockAsync()) { // Get a unique id for the file string id = ((uint)HashCode.Combine(file.Path.AsSpan())).ToString(); diff --git a/src/Brainf_ckSharp.Uwp/Views/ConsoleView.xaml.cs b/src/Brainf_ckSharp.Uwp/Views/ConsoleView.xaml.cs index c9ac6c8a..266a6aaa 100644 --- a/src/Brainf_ckSharp.Uwp/Views/ConsoleView.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Views/ConsoleView.xaml.cs @@ -33,8 +33,8 @@ public ConsoleView() /// public double FooterSpacing { - get => FooterBorder.Height - 12; - set => FooterBorder.Height = value + 12; + get => this.FooterBorder.Height - 12; + set => this.FooterBorder.Height = value + 12; } /// diff --git a/src/Brainf_ckSharp.Uwp/Views/IdeView.xaml.cs b/src/Brainf_ckSharp.Uwp/Views/IdeView.xaml.cs index e8484188..23d05606 100644 --- a/src/Brainf_ckSharp.Uwp/Views/IdeView.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Views/IdeView.xaml.cs @@ -41,8 +41,8 @@ public IdeView() ViewModel.CodeSaved += ViewModel_CodeSaved; ViewModel.StateRestored += ViewModel_OnStateRestored; - CodeEditor.RenderWhitespaceCharacters = App.Current.Services.GetRequiredService().GetValue(SettingsKeys.RenderWhitespaces); - CodeEditor.SyntaxHighlightTheme = App.Current.Services.GetRequiredService().GetValue(SettingsKeys.IdeTheme).AsBrainf_ckTheme(); + this.CodeEditor.RenderWhitespaceCharacters = App.Current.Services.GetRequiredService().GetValue(SettingsKeys.RenderWhitespaces); + this.CodeEditor.SyntaxHighlightTheme = App.Current.Services.GetRequiredService().GetValue(SettingsKeys.IdeTheme).AsBrainf_ckTheme(); App.Current.Services.GetRequiredService().Register>(this, (r, m) => r.CodeEditor.Move(m.Value)); App.Current.Services.GetRequiredService().Register(this, (r, m) => r.CodeEditor.SyntaxHighlightTheme = m.Value.AsBrainf_ckTheme()); @@ -59,8 +59,8 @@ public IdeView() /// public double FooterSpacing { - get => CodeEditor.FooterSpacing; - set => CodeEditor.FooterSpacing = value; + get => this.CodeEditor.FooterSpacing; + set => this.CodeEditor.FooterSpacing = value; } /// @@ -84,12 +84,12 @@ private void IdeViewModel_OnScriptRunRequested(object sender, EventArgs e) { if (!ViewModel.ValidationResult.IsSuccess) { - CodeEditor.TryShowSyntaxErrorToolTip(); + this.CodeEditor.TryShowSyntaxErrorToolTip(); return; } - App.Current.SubPageHost.DisplaySubFramePage(new IdeResultSubPage(CodeEditor.Text)); + App.Current.SubPageHost.DisplaySubFramePage(new IdeResultSubPage(this.CodeEditor.Text)); } /// @@ -101,13 +101,13 @@ private void IdeViewModel_OnScriptDebugRequested(object sender, EventArgs e) { if (!ViewModel.ValidationResult.IsSuccess) { - CodeEditor.TryShowSyntaxErrorToolTip(); + this.CodeEditor.TryShowSyntaxErrorToolTip(); return; } - string source = CodeEditor.Text; - IMemoryOwner breakpoints = CodeEditor.GetBreakpoints(); + string source = this.CodeEditor.Text; + IMemoryOwner breakpoints = this.CodeEditor.GetBreakpoints(); App.Current.SubPageHost.DisplaySubFramePage(new IdeResultSubPage(source, breakpoints)); } @@ -119,7 +119,7 @@ private void IdeViewModel_OnScriptDebugRequested(object sender, EventArgs e) /// The operator character to add to the text private void ViewModel_CharacterAdded(object sender, char e) { - CodeEditor.TypeCharacter(e); + this.CodeEditor.TypeCharacter(e); } /// @@ -129,7 +129,7 @@ private void ViewModel_CharacterAdded(object sender, char e) /// The empty instance for this event private void ViewModel_CharacterDeleted(object sender, EventArgs e) { - CodeEditor.DeleteCharacter(); + this.CodeEditor.DeleteCharacter(); } /// @@ -139,7 +139,7 @@ private void ViewModel_CharacterDeleted(object sender, EventArgs e) /// The with the code to load private void ViewModel_CodeLoaded(object sender, string e) { - CodeEditor.LoadText(e); + this.CodeEditor.LoadText(e); App.Current.SubPageHost.CloseSubFramePage(); } @@ -151,7 +151,7 @@ private void ViewModel_CodeLoaded(object sender, string e) /// The empty instance for the event private void ViewModel_CodeSaved(object sender, EventArgs e) { - CodeEditor.MarkTextAsSaved(); + this.CodeEditor.MarkTextAsSaved(); } /// @@ -161,8 +161,8 @@ private void ViewModel_CodeSaved(object sender, EventArgs e) /// The empty instance for the event private void ViewModel_OnStateRestored(object sender, IdeState e) { - CodeEditor.LoadText(e.Text); - CodeEditor.Move(e.Row, e.Column); + this.CodeEditor.LoadText(e.Text); + this.CodeEditor.Move(e.Row, e.Column); } /// @@ -204,7 +204,7 @@ from fieldInfo in typeof(CodeSnippets).GetFields(BindingFlags.Public | BindingFl App.Current.Services.GetRequiredService().Log(EventNames.InsertCodeSnippet, (nameof(CodeSnippets), name)); - CodeEditor.InsertText(snippet); + this.CodeEditor.InsertText(snippet); } } diff --git a/src/Brainf_ckSharp/Buffers/StdinBuffer.cs b/src/Brainf_ckSharp/Buffers/StdinBuffer.cs index eba2ca48..e838f5e3 100644 --- a/src/Brainf_ckSharp/Buffers/StdinBuffer.cs +++ b/src/Brainf_ckSharp/Buffers/StdinBuffer.cs @@ -28,8 +28,8 @@ internal struct StdinBuffer /// The input data to use to read characters from public StdinBuffer(ReadOnlyMemory data) { - Data = data; - _Position = 0; + this.Data = data; + this._Position = 0; } /// @@ -38,7 +38,7 @@ public StdinBuffer(ReadOnlyMemory data) /// A instance to read characters public Reader CreateReader() { - return new(Data.Span, _Position); + return new(this.Data.Span, this._Position); } /// @@ -47,7 +47,7 @@ public Reader CreateReader() /// The instance that was previously used public void Synchronize(ref Reader reader) { - _Position = reader.Position; + this._Position = reader.Position; } /// @@ -68,8 +68,8 @@ public ref struct Reader /// The initial position to read from public Reader(ReadOnlySpan data, int position = 0) { - Data = data; - Position = position; + this.Data = data; + this.Position = position; } /// @@ -80,16 +80,16 @@ public Reader(ReadOnlySpan data, int position = 0) [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryRead(out char c) { - Assert(Position >= 0); - Assert(Position <= Data.Length); + Assert(this.Position >= 0); + Assert(this.Position <= this.Data.Length); - int position = Position; + int position = this.Position; - if ((uint)position < (uint)Data.Length) + if ((uint)position < (uint)this.Data.Length) { - c = Data.DangerousGetReferenceAt(position); + c = this.Data.DangerousGetReferenceAt(position); - Position = position + 1; + this.Position = position + 1; return true; } @@ -102,7 +102,7 @@ public bool TryRead(out char c) /// public override string ToString() { - return StringPool.Shared.GetOrAdd(Data); + return StringPool.Shared.GetOrAdd(this.Data); } } @@ -113,12 +113,12 @@ public override readonly string ToString() // we can just return that same instance with no additional allocations (this is the // same behavior of ReadOnlyMemory.ToString()). Otherwise, we use StringPool to // avoid repeated allocations if the source buffers represent a repeated text. - if (MemoryMarshal.TryGetString(Data, out string text, out int start, out int length) && + if (MemoryMarshal.TryGetString(this.Data, out string text, out int start, out int length) && start == 0 && length == text.Length) { return text; } - return StringPool.Shared.GetOrAdd(Data.Span); + return StringPool.Shared.GetOrAdd(this.Data.Span); } } diff --git a/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs b/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs index 8ad9a78d..d9f163cd 100644 --- a/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs +++ b/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs @@ -29,8 +29,8 @@ internal struct StdoutBuffer : IDisposable [MethodImpl(MethodImplOptions.AggressiveInlining)] private StdoutBuffer(char[] buffer) { - Buffer = buffer; - _Position = 0; + this.Buffer = buffer; + this._Position = 0; } /// @@ -49,7 +49,7 @@ public static StdoutBuffer Allocate() /// A instance to write characters public Writer CreateWriter() { - return new(Buffer, _Position); + return new(this.Buffer, this._Position); } /// @@ -58,7 +58,7 @@ public Writer CreateWriter() /// The instance that was previously used public void Synchronize(ref Writer writer) { - _Position = writer.Position; + this._Position = writer.Position; } /// @@ -79,8 +79,8 @@ public ref struct Writer /// The initial position to write from public Writer(Span buffer, int position = 0) { - Buffer = buffer; - Position = position; + this.Buffer = buffer; + this.Position = position; } /// @@ -91,16 +91,16 @@ public Writer(Span buffer, int position = 0) [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool TryWrite(char c) { - Assert(Position >= 0); - Assert(Position <= Specs.StdoutBufferSizeLimit); + Assert(this.Position >= 0); + Assert(this.Position <= Specs.StdoutBufferSizeLimit); - int position = Position; + int position = this.Position; - if ((uint)position < (uint)Buffer.Length) + if ((uint)position < (uint)this.Buffer.Length) { - Buffer.DangerousGetReferenceAt(position) = c; + this.Buffer.DangerousGetReferenceAt(position) = c; - Position = position + 1; + this.Position = position + 1; return true; } @@ -111,19 +111,19 @@ public bool TryWrite(char c) /// public override readonly string ToString() { - return StringPool.Shared.GetOrAdd(Buffer.Slice(0, Position)); + return StringPool.Shared.GetOrAdd(this.Buffer.Slice(0, this.Position)); } } /// public override readonly string ToString() { - return StringPool.Shared.GetOrAdd(new ReadOnlySpan(Buffer, 0, _Position)); + return StringPool.Shared.GetOrAdd(new ReadOnlySpan(this.Buffer, 0, this._Position)); } /// public readonly void Dispose() { - ArrayPool.Shared.Return(Buffer); + ArrayPool.Shared.Return(this.Buffer); } } diff --git a/src/Brainf_ckSharp/Configurations/Configuration.Debug.cs b/src/Brainf_ckSharp/Configurations/Configuration.Debug.cs index fefe0b48..2773672b 100644 --- a/src/Brainf_ckSharp/Configurations/Configuration.Debug.cs +++ b/src/Brainf_ckSharp/Configurations/Configuration.Debug.cs @@ -31,30 +31,30 @@ public readonly ref partial struct DebugConfiguration [MethodImpl(MethodImplOptions.NoInlining)] public Option TryRun() { - Guard.IsNotNull(Source); + Guard.IsNotNull(this.Source); - if (InitialState is TuringMachineState initialState) + if (this.InitialState is TuringMachineState initialState) { - Guard.IsNull(MemorySize); - Guard.IsNull(OverflowMode); + Guard.IsNull(this.MemorySize); + Guard.IsNull(this.OverflowMode); initialState = (TuringMachineState)initialState.Clone(); } else { - int size = MemorySize ?? Specs.DefaultMemorySize; + int size = this.MemorySize ?? Specs.DefaultMemorySize; - Guard.IsBetweenOrEqualTo(size, Specs.MinimumMemorySize, Specs.MaximumMemorySize, nameof(MemorySize)); + Guard.IsBetweenOrEqualTo(size, Specs.MinimumMemorySize, Specs.MaximumMemorySize, nameof(this.MemorySize)); - initialState = new TuringMachineState(size, OverflowMode ?? Specs.DefaultOverflowMode); + initialState = new TuringMachineState(size, this.OverflowMode ?? Specs.DefaultOverflowMode); } return Brainf_ckInterpreter.Debug.TryCreateSession( - Source.Value.Span, - Breakpoints.Span, - Stdin.GetValueOrDefault(), + this.Source.Value.Span, + this.Breakpoints.Span, + this.Stdin.GetValueOrDefault(), initialState, - ExecutionToken, - DebugToken); + this.ExecutionToken, + this.DebugToken); } } diff --git a/src/Brainf_ckSharp/Configurations/Configuration.Release.cs b/src/Brainf_ckSharp/Configurations/Configuration.Release.cs index 1e6f5b8c..e80e7970 100644 --- a/src/Brainf_ckSharp/Configurations/Configuration.Release.cs +++ b/src/Brainf_ckSharp/Configurations/Configuration.Release.cs @@ -21,33 +21,33 @@ public readonly ref partial struct ReleaseConfiguration [MethodImpl(MethodImplOptions.NoInlining)] public Option TryRun() { - Guard.IsNotNull(Source); + Guard.IsNotNull(this.Source); - using MemoryOwner? operations = Brainf_ckParser.TryParse(Source.Value.Span, out SyntaxValidationResult validationResult); + using MemoryOwner? operations = Brainf_ckParser.TryParse(this.Source.Value.Span, out SyntaxValidationResult validationResult); if (!validationResult.IsSuccess) return Option.From(validationResult); - if (InitialState is TuringMachineState initialState) + if (this.InitialState is TuringMachineState initialState) { - Guard.IsNull(MemorySize); - Guard.IsNull(OverflowMode); + Guard.IsNull(this.MemorySize); + Guard.IsNull(this.OverflowMode); initialState = (TuringMachineState)initialState.Clone(); } else { - int size = MemorySize ?? Specs.DefaultMemorySize; + int size = this.MemorySize ?? Specs.DefaultMemorySize; - Guard.IsBetweenOrEqualTo(size, Specs.MinimumMemorySize, Specs.MaximumMemorySize, nameof(MemorySize)); + Guard.IsBetweenOrEqualTo(size, Specs.MinimumMemorySize, Specs.MaximumMemorySize, nameof(this.MemorySize)); - initialState = new TuringMachineState(size, OverflowMode ?? Specs.DefaultOverflowMode); + initialState = new TuringMachineState(size, this.OverflowMode ?? Specs.DefaultOverflowMode); } InterpreterResult result = Brainf_ckInterpreter.Release.Run( operations!.Span, - Stdin.GetValueOrDefault().Span, + this.Stdin.GetValueOrDefault().Span, initialState, - ExecutionToken); + this.ExecutionToken); return Option.From(validationResult, result); } diff --git a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs index bb1d1c05..d4805603 100644 --- a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs +++ b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs @@ -34,27 +34,27 @@ public ref struct IReadOnlyMachineStateEnumerator [MethodImpl(MethodImplOptions.AggressiveInlining)] internal IReadOnlyMachineStateEnumerator(TuringMachineState machineState) { - MachineState = machineState; - Size = machineState.Size; - _Index = -1; + this.MachineState = machineState; + this.Size = machineState.Size; + this._Index = -1; } /// public Brainf_ckMemoryCell Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => MachineState[_Index]; + get => this.MachineState[this._Index]; } /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { - int index = _Index + 1; + int index = this._Index + 1; - if (index < Size) + if (index < this.Size) { - _Index = index; + this._Index = index; return true; } diff --git a/src/Brainf_ckSharp/Memory/TuringMachineState.ExecutionSession.cs b/src/Brainf_ckSharp/Memory/TuringMachineState.ExecutionSession.cs index 7ecab9dd..ff403330 100644 --- a/src/Brainf_ckSharp/Memory/TuringMachineState.ExecutionSession.cs +++ b/src/Brainf_ckSharp/Memory/TuringMachineState.ExecutionSession.cs @@ -65,18 +65,18 @@ public ExecutionSession(TuringMachineState state) { Assert(state._Buffer != null); - Handle = GCHandle.Alloc(state._Buffer); - MachineState = state; - ExecutionContext = state.GetExecutionContext(); + this.Handle = GCHandle.Alloc(state._Buffer); + this.MachineState = state; + this.ExecutionContext = state.GetExecutionContext(); } /// public void Dispose() { // Cast to a mutable reference to avoid the defensive copy - Unsafe.AsRef(Handle).Free(); + Unsafe.AsRef(this.Handle).Free(); - MachineState._Position = ExecutionContext.Position; + this.MachineState._Position = this.ExecutionContext.Position; } } } diff --git a/src/Brainf_ckSharp/Memory/TuringMachineState.cs b/src/Brainf_ckSharp/Memory/TuringMachineState.cs index a22f39c8..fdcab3f9 100644 --- a/src/Brainf_ckSharp/Memory/TuringMachineState.cs +++ b/src/Brainf_ckSharp/Memory/TuringMachineState.cs @@ -57,13 +57,13 @@ public TuringMachineState(int size, OverflowMode mode) /// Indicates whether or not to clear the allocated memory area private TuringMachineState(int size, OverflowMode mode, bool clear) { - _Buffer = ArrayPool.Shared.Rent(size); - Size = size; - Mode = mode; + this._Buffer = ArrayPool.Shared.Rent(size); + this.Size = size; + this.Mode = mode; if (clear) { - _Buffer.AsSpan(0, size).Clear(); + this._Buffer.AsSpan(0, size).Clear(); } } @@ -73,10 +73,10 @@ private TuringMachineState(int size, OverflowMode mode, bool clear) ~TuringMachineState() => Dispose(); /// - public int Position => _Position; + public int Position => this._Position; /// - public int Count => Size; + public int Count => this.Size; /// public Brainf_ckMemoryCell Current @@ -84,13 +84,13 @@ public Brainf_ckMemoryCell Current [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - ushort[]? array = _Buffer; + ushort[]? array = this._Buffer; if (array is null) ThrowObjectDisposedException(); - ushort value = array!.DangerousGetReferenceAt(_Position); + ushort value = array!.DangerousGetReferenceAt(this._Position); - return new(_Position, value, true); + return new(this._Position, value, true); } } @@ -100,18 +100,18 @@ public Brainf_ckMemoryCell this[int index] [MethodImpl(MethodImplOptions.AggressiveInlining)] get { - ushort[]? array = _Buffer; + ushort[]? array = this._Buffer; if (array is null) ThrowObjectDisposedException(); // Manually check the current size, as the buffer // is rented from the pool and its length might // actually be greater than the memory state. - Guard.IsInRange(index, 0, Size); + Guard.IsInRange(index, 0, this.Size); ushort value = array!.DangerousGetReferenceAt(index); - return new(index, value, _Position == index); + return new(index, value, this._Position == index); } } @@ -128,30 +128,30 @@ public bool Equals(IReadOnlyMachineState? other) if (ReferenceEquals(this, other)) return true; - if (_Buffer is null) ThrowObjectDisposedException(); + if (this._Buffer is null) ThrowObjectDisposedException(); if (other is not TuringMachineState state) return false; if (state._Buffer is null) ThrowObjectDisposedException(); return - Size == state.Size && - Mode == state.Mode && - _Position == state._Position && - _Buffer.AsSpan(0, Size).SequenceEqual(state._Buffer.AsSpan(0, Size)); + this.Size == state.Size && + this.Mode == state.Mode && + this._Position == state._Position && + this._Buffer.AsSpan(0, this.Size).SequenceEqual(state._Buffer.AsSpan(0, this.Size)); } /// public override int GetHashCode() { - if (_Buffer is null) ThrowObjectDisposedException(); + if (this._Buffer is null) ThrowObjectDisposedException(); HashCode hashCode = default; - hashCode.Add(Size); - hashCode.Add(Mode); - hashCode.Add(_Position); - hashCode.Add(_Buffer.AsSpan(0, Size)); + hashCode.Add(this.Size); + hashCode.Add(this.Mode); + hashCode.Add(this._Position); + hashCode.Add(this._Buffer.AsSpan(0, this.Size)); return hashCode.ToHashCode(); } @@ -165,7 +165,7 @@ IEnumerator IEnumerable.GetEnumerator() /// IEnumerator IEnumerable.GetEnumerator() { - for (int i = 0; i < Size; i++) + for (int i = 0; i < this.Size; i++) { yield return this[i]; } @@ -180,11 +180,11 @@ public IReadOnlyMachineStateEnumerator GetEnumerator() /// public object Clone() { - if (_Buffer is null) ThrowObjectDisposedException(); + if (this._Buffer is null) ThrowObjectDisposedException(); - TuringMachineState clone = new(Size, Mode, false) { _Position = _Position }; + TuringMachineState clone = new(this.Size, this.Mode, false) { _Position = this._Position }; - _Buffer.AsSpan(0, Size).CopyTo(clone._Buffer.AsSpan(0, Size)); + this._Buffer.AsSpan(0, this.Size).CopyTo(clone._Buffer.AsSpan(0, this.Size)); return clone; } @@ -192,11 +192,11 @@ public object Clone() /// public void Dispose() { - ushort[]? array = _Buffer; + ushort[]? array = this._Buffer; if (array is null) return; - _Buffer = null; + this._Buffer = null; ArrayPool.Shared.Return(array); } diff --git a/src/Brainf_ckSharp/Models/Brainf_ckMemoryCell.cs b/src/Brainf_ckSharp/Models/Brainf_ckMemoryCell.cs index 56f892fa..ad091f97 100644 --- a/src/Brainf_ckSharp/Models/Brainf_ckMemoryCell.cs +++ b/src/Brainf_ckSharp/Models/Brainf_ckMemoryCell.cs @@ -32,7 +32,7 @@ internal Brainf_ckMemoryCell(int index, ushort value, bool isSelected) { Assert((uint)index <= short.MaxValue); - State = (ushort)BitHelper.SetFlag((uint)index, 15, isSelected); + this.State = (ushort)BitHelper.SetFlag((uint)index, 15, isSelected); Value = value; } @@ -42,7 +42,7 @@ internal Brainf_ckMemoryCell(int index, ushort value, bool isSelected) public int Index { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => (int)BitHelper.SetFlag(State, 15, false); + get => (int)BitHelper.SetFlag(this.State, 15, false); } /// @@ -65,7 +65,7 @@ public char Character public bool IsSelected { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => BitHelper.HasFlag(State, 15); + get => BitHelper.HasFlag(this.State, 15); } /// @@ -88,7 +88,7 @@ public bool IsSelected public bool Equals(Brainf_ckMemoryCell other) { return - State == other.State && + this.State == other.State && Value == other.Value; } @@ -103,6 +103,6 @@ obj is Brainf_ckMemoryCell cell && /// public override int GetHashCode() { - return HashCode.Combine(State, Value); + return HashCode.Combine(this.State, Value); } } \ No newline at end of file diff --git a/src/Brainf_ckSharp/Models/Internal/Range.cs b/src/Brainf_ckSharp/Models/Internal/Range.cs index 554e1af6..1b629e68 100644 --- a/src/Brainf_ckSharp/Models/Internal/Range.cs +++ b/src/Brainf_ckSharp/Models/Internal/Range.cs @@ -30,8 +30,8 @@ public Range(int start, int end) Assert(end >= 0); Assert(start <= end); - Start = start; - End = end; + this.Start = start; + this.End = end; } /// @@ -40,6 +40,6 @@ public Range(int start, int end) public int Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => End - Start; + get => this.End - this.Start; } } diff --git a/src/Brainf_ckSharp/Models/Internal/StackFrame.cs b/src/Brainf_ckSharp/Models/Internal/StackFrame.cs index 537d4832..bb82b5c9 100644 --- a/src/Brainf_ckSharp/Models/Internal/StackFrame.cs +++ b/src/Brainf_ckSharp/Models/Internal/StackFrame.cs @@ -36,8 +36,8 @@ public StackFrame(Range range, int offset) Assert(offset >= range.Start); Assert(offset <= range.End); - Range = range; - Offset = offset; + this.Range = range; + this.Offset = offset; } /// @@ -46,5 +46,5 @@ public StackFrame(Range range, int offset) /// The current offset during execution /// A instance like the current one, but with a different offset [MethodImpl(MethodImplOptions.AggressiveInlining)] - public StackFrame WithOffset(int offset) => new(Range, offset); + public StackFrame WithOffset(int offset) => new(this.Range, offset); } diff --git a/src/Brainf_ckSharp/Models/Internal/Timestamp.cs b/src/Brainf_ckSharp/Models/Internal/Timestamp.cs index ee2c47cc..ce750828 100644 --- a/src/Brainf_ckSharp/Models/Internal/Timestamp.cs +++ b/src/Brainf_ckSharp/Models/Internal/Timestamp.cs @@ -30,7 +30,7 @@ internal readonly struct Timestamp [MethodImpl(MethodImplOptions.AggressiveInlining)] private Timestamp(long value) { - Value = value; + this.Value = value; } /// @@ -52,7 +52,7 @@ public long Ticks { long current = Stopwatch.GetTimestamp(), - delta = Math.Abs(current - Value), + delta = Math.Abs(current - this.Value), ticks = unchecked((long)(delta * TickFrequency)); return ticks; diff --git a/src/Brainf_ckSharp/Models/InterpreterSession.cs b/src/Brainf_ckSharp/Models/InterpreterSession.cs index e3144994..d454bc3a 100644 --- a/src/Brainf_ckSharp/Models/InterpreterSession.cs +++ b/src/Brainf_ckSharp/Models/InterpreterSession.cs @@ -131,19 +131,19 @@ internal InterpreterSession( CancellationToken executionToken, CancellationToken debugToken) { - Opcodes = opcodes; - Breakpoints = breakpoints; - JumpTable = jumpTable; - Functions = functions; - Definitions = definitions; - StackFrames = stackFrames; - MachineState = machineState; - StdinBuffer = new StdinBuffer(stdin); - StdoutBuffer = StdoutBuffer.Allocate(); - ExecutionToken = executionToken; - DebugToken = debugToken; - Stopwatch = new Stopwatch(); - SourceCode = Brainf_ckParser.ExtractSource(opcodes.Span); + this.Opcodes = opcodes; + this.Breakpoints = breakpoints; + this.JumpTable = jumpTable; + this.Functions = functions; + this.Definitions = definitions; + this.StackFrames = stackFrames; + this.MachineState = machineState; + this.StdinBuffer = new StdinBuffer(stdin); + this.StdoutBuffer = StdoutBuffer.Allocate(); + this.ExecutionToken = executionToken; + this.DebugToken = debugToken; + this.Stopwatch = new Stopwatch(); + this.SourceCode = Brainf_ckParser.ExtractSource(opcodes.Span); } private InterpreterResult? _Current; @@ -152,7 +152,7 @@ internal InterpreterSession( public InterpreterResult Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _Current ?? ThrowHelper.ThrowInvalidOperationException("The session has not been initialized yet"); + get => this._Current ?? ThrowHelper.ThrowInvalidOperationException("The session has not been initialized yet"); } /// @@ -162,21 +162,21 @@ public InterpreterResult Current public bool MoveNext() { // Check whether the current session can go ahead by one step - if (_Current != null && - (_Current.ExitCode.HasFlag(ExitCode.Failure) || - !_Current.ExitCode.HasFlag(ExitCode.BreakpointReached))) + if (this._Current != null && + (this._Current.ExitCode.HasFlag(ExitCode.Failure) || + !this._Current.ExitCode.HasFlag(ExitCode.BreakpointReached))) { return false; } // Execute the mode specific implementation - switch (MachineState.Mode) + switch (this.MachineState.Mode) { case OverflowMode.ByteWithOverflow: MoveNext(); break; case OverflowMode.ByteWithNoOverflow: MoveNext(); break; case OverflowMode.UshortWithOverflow: MoveNext(); break; case OverflowMode.UshortWithNoOverflow: MoveNext(); break; - default: ThrowHelper.ThrowArgumentOutOfRangeException(nameof(MachineState.Mode), $"Invalid execution mode: {MachineState.Mode}"); break; + default: ThrowHelper.ThrowArgumentOutOfRangeException(nameof(this.MachineState.Mode), $"Invalid execution mode: {this.MachineState.Mode}"); break; }; return true; @@ -191,62 +191,62 @@ private void MoveNext() { ExitCode exitCode; - using (TuringMachineState.ExecutionSession session = MachineState.CreateExecutionSession()) + using (TuringMachineState.ExecutionSession session = this.MachineState.CreateExecutionSession()) { - Stopwatch.Start(); + this.Stopwatch.Start(); // Setup the stdin and stdout readers and writers - StdinBuffer.Reader stdinReader = StdinBuffer.CreateReader(); - StdoutBuffer.Writer stdoutWriter = StdoutBuffer.CreateWriter(); + StdinBuffer.Reader stdinReader = this.StdinBuffer.CreateReader(); + StdoutBuffer.Writer stdoutWriter = this.StdoutBuffer.CreateWriter(); // Execute the new interpreter debug step exitCode = Brainf_ckInterpreter.Debug.Run( ref Unsafe.AsRef(session.ExecutionContext), - ref Opcodes.DangerousGetReference(), - ref Breakpoints.DangerousGetReference(), - ref JumpTable.DangerousGetReference(), - ref Functions.DangerousGetReference(), - ref Definitions.DangerousGetReference(), - ref StackFrames.DangerousGetReference(), - ref _Depth, - ref _TotalOperations, - ref _TotalFunctions, + ref this.Opcodes.DangerousGetReference(), + ref this.Breakpoints.DangerousGetReference(), + ref this.JumpTable.DangerousGetReference(), + ref this.Functions.DangerousGetReference(), + ref this.Definitions.DangerousGetReference(), + ref this.StackFrames.DangerousGetReference(), + ref this._Depth, + ref this._TotalOperations, + ref this._TotalFunctions, ref stdinReader, ref stdoutWriter, - ExecutionToken, - DebugToken); + this.ExecutionToken, + this.DebugToken); // Synchronize the buffers - StdinBuffer.Synchronize(ref stdinReader); - StdoutBuffer.Synchronize(ref stdoutWriter); + this.StdinBuffer.Synchronize(ref stdinReader); + this.StdoutBuffer.Synchronize(ref stdoutWriter); - Stopwatch.Stop(); + this.Stopwatch.Stop(); } // Prepare the debug info HaltedExecutionInfo? debugInfo = Brainf_ckInterpreter.LoadDebugInfo( - Opcodes.Span, - StackFrames.Span, - _Depth); + this.Opcodes.Span, + this.StackFrames.Span, + this._Depth); // Build the collection of defined functions FunctionDefinition[] functionDefinitions = Brainf_ckInterpreter.LoadFunctionDefinitions( - Opcodes.Span, - Functions.Span, - Definitions.Span, - _TotalFunctions); + this.Opcodes.Span, + this.Functions.Span, + this.Definitions.Span, + this._TotalFunctions); // Update the current interpreter result - _Current = new InterpreterResult( - SourceCode, + this._Current = new InterpreterResult( + this.SourceCode, exitCode, debugInfo, - (TuringMachineState)MachineState.Clone(), + (TuringMachineState)this.MachineState.Clone(), functionDefinitions, - StdinBuffer.ToString(), - StdoutBuffer.ToString(), - Stopwatch.Elapsed, - _TotalOperations); + this.StdinBuffer.ToString(), + this.StdoutBuffer.ToString(), + this.Stopwatch.Elapsed, + this._TotalOperations); } /// @@ -257,18 +257,18 @@ ref StackFrames.DangerousGetReference(), /// public void Dispose() { - if (_Disposed) return; - - _Disposed = true; - - Opcodes.Dispose(); - Breakpoints.Dispose(); - JumpTable.Dispose(); - Functions.Dispose(); - Definitions.Dispose(); - StackFrames.Dispose(); - StackFrames.Dispose(); - StdoutBuffer.Dispose(); - Stopwatch.Stop(); + if (this._Disposed) return; + + this._Disposed = true; + + this.Opcodes.Dispose(); + this.Breakpoints.Dispose(); + this.JumpTable.Dispose(); + this.Functions.Dispose(); + this.Definitions.Dispose(); + this.StackFrames.Dispose(); + this.StackFrames.Dispose(); + this.StdoutBuffer.Dispose(); + this.Stopwatch.Stop(); } } diff --git a/src/GitHub/HttpHandlers/UnauthenticatedHttpClientHandler.cs b/src/GitHub/HttpHandlers/UnauthenticatedHttpClientHandler.cs index ca130473..14b48e7a 100644 --- a/src/GitHub/HttpHandlers/UnauthenticatedHttpClientHandler.cs +++ b/src/GitHub/HttpHandlers/UnauthenticatedHttpClientHandler.cs @@ -18,13 +18,13 @@ internal sealed class UnauthenticatedHttpClientHandler : HttpClientHandler /// Creates a new instance with the specified parameters /// /// The user agent to use to send the requests - public UnauthenticatedHttpClientHandler(string userAgent) => UserAgent = userAgent; + public UnauthenticatedHttpClientHandler(string userAgent) => this.UserAgent = userAgent; /// protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { // Headers setup - request.Headers.Add("User-Agent", UserAgent); + request.Headers.Add("User-Agent", this.UserAgent); // Send the request and handle errors return base.SendAsync(request, cancellationToken); From 87bd16f211447ae93929d4713ad60a9ef78d6f2d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:02:01 -0700 Subject: [PATCH 04/31] Fix CS1591 (missing XML docs) --- profiling/Directory.Build.props | 9 +++++++++ src/Brainf_ckSharp.Shared/Constants/EventNames.cs | 4 +++- .../ViewModels/Controls/StatusBarViewModel.cs | 5 ++++- .../ViewModels/Controls/StdinHeaderViewModel.cs | 5 ++++- .../Controls/SubPages/CodeLibrarySubPageViewModel.cs | 5 ++++- .../Controls/SubPages/IdeResultSubPageViewModel.cs | 5 ++++- .../Settings/Sections/IdeSettingsSectionViewModel.cs | 5 ++++- .../Sections/InterpreterSettingsSectionViewModel.cs | 3 +++ .../Settings/Sections/UISettingsSectionViewModel.cs | 5 ++++- .../SubPages/Settings/SettingsSubPageViewModel.cs | 5 ++++- .../SubPages/UnicodeCharactersMapSubPageViewModel.cs | 5 ++++- .../ViewModels/Controls/VirtualKeyboardViewModel.cs | 5 ++++- src/Brainf_ckSharp/Models/InterpreterSession.cs | 5 ++++- unit/Directory.Build.props | 9 +++++++++ 14 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 profiling/Directory.Build.props create mode 100644 unit/Directory.Build.props diff --git a/profiling/Directory.Build.props b/profiling/Directory.Build.props new file mode 100644 index 00000000..c3c5a51b --- /dev/null +++ b/profiling/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + + + $(NoWarn);CS1591 + + \ No newline at end of file diff --git a/src/Brainf_ckSharp.Shared/Constants/EventNames.cs b/src/Brainf_ckSharp.Shared/Constants/EventNames.cs index 37521e82..83639e5e 100644 --- a/src/Brainf_ckSharp.Shared/Constants/EventNames.cs +++ b/src/Brainf_ckSharp.Shared/Constants/EventNames.cs @@ -1,4 +1,6 @@ -namespace Brainf_ckSharp.Shared.Constants; +#pragma warning disable CS1591 + +namespace Brainf_ckSharp.Shared.Constants; /// /// A with the collection of tracked events for analytics diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs index 8492f972..2c781bfe 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using Brainf_ckSharp.Enums; using Brainf_ckSharp.Memory.Interfaces; @@ -15,6 +15,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls; +/// +/// A viewmodel for the status bar in the application. +/// public sealed class StatusBarViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs index 04a5a395..32f24970 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StdinHeaderViewModel.cs @@ -1,4 +1,4 @@ -using Brainf_ckSharp.Services; +using Brainf_ckSharp.Services; using Brainf_ckSharp.Shared.Constants; using Brainf_ckSharp.Shared.Messages.InputPanel; using CommunityToolkit.Mvvm.ComponentModel; @@ -6,6 +6,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls; +/// +/// A viewmodel for the stdin header shown in the app. +/// public sealed class StdinHeaderViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs index e4b6e6c6..8607b04c 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.Json; @@ -19,6 +19,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages; +/// +/// A viewmodel for the code library page. +/// public sealed partial class CodeLibrarySubPageViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs index 92d60580..e0ca693c 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Buffers; using System.Threading; using System.Threading.Tasks; @@ -20,6 +20,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages; +/// +/// A viewmodel for the IDE results page displayed when running a script. +/// public sealed partial class IdeResultSubPageViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs index 8408a0eb..92770ff4 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/IdeSettingsSectionViewModel.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using Brainf_ckSharp.Services; using Brainf_ckSharp.Services.Enums; @@ -12,6 +12,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings.Sections; +/// +/// A viewmodel for the IDE settings section. +/// public sealed partial class IdeSettingsSectionViewModel : SettingsSectionViewModelBase { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs index 285fc283..2d89eefc 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/InterpreterSettingsSectionViewModel.cs @@ -8,6 +8,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings.Sections; +/// +/// A viewmodel for the interpreter settings section. +/// public sealed class InterpreterSettingsSectionViewModel : SettingsSectionViewModelBase { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs index 80bc2f52..8b736167 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/Sections/UISettingsSectionViewModel.cs @@ -1,4 +1,4 @@ -using Brainf_ckSharp.Services; +using Brainf_ckSharp.Services; using Brainf_ckSharp.Shared.Constants; using Brainf_ckSharp.Shared.Messages.Settings; using Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings.Sections.Abstract; @@ -6,6 +6,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings.Sections; +/// +/// A viewmodel for the UI settings section. +/// public sealed class UISettingsSectionViewModel : SettingsSectionViewModelBase { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/SettingsSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/SettingsSubPageViewModel.cs index 195c1253..6455a6e9 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/SettingsSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/Settings/SettingsSubPageViewModel.cs @@ -1,4 +1,4 @@ -using Brainf_ckSharp.Services; +using Brainf_ckSharp.Services; using Brainf_ckSharp.Shared.Constants; using Brainf_ckSharp.Shared.Enums; using Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings.Sections; @@ -9,6 +9,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages.Settings; +/// +/// A viewmodel for the settings page. +/// public sealed class SettingsSubPageViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/UnicodeCharactersMapSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/UnicodeCharactersMapSubPageViewModel.cs index 1a9db02a..9e23311b 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/UnicodeCharactersMapSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/UnicodeCharactersMapSubPageViewModel.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Brainf_ckSharp.Shared.Models; @@ -9,6 +9,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages; +/// +/// A viewmodel for the characters control. +/// public sealed partial class UnicodeCharactersMapSubPageViewModel : ObservableObject { /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs index 0d33ef00..eceb62b6 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/VirtualKeyboardViewModel.cs @@ -1,4 +1,4 @@ -using Brainf_ckSharp.Services; +using Brainf_ckSharp.Services; using Brainf_ckSharp.Shared.Constants; using Brainf_ckSharp.Shared.Messages.InputPanel; using Brainf_ckSharp.Shared.Messages.Settings; @@ -8,6 +8,9 @@ namespace Brainf_ckSharp.Shared.ViewModels.Controls; +/// +/// A viewmodel for the virtual keyboard control. +/// public sealed partial class VirtualKeyboardViewModel : ObservableRecipient { /// diff --git a/src/Brainf_ckSharp/Models/InterpreterSession.cs b/src/Brainf_ckSharp/Models/InterpreterSession.cs index d454bc3a..6f5294d1 100644 --- a/src/Brainf_ckSharp/Models/InterpreterSession.cs +++ b/src/Brainf_ckSharp/Models/InterpreterSession.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections; using System.Collections.Generic; using System.Runtime.CompilerServices; @@ -252,6 +252,9 @@ ref this.StackFrames.DangerousGetReference(), /// public void Reset() => throw new NotSupportedException("An interpreter session can't be reset"); + /// + /// Disposes resources when the instance is finalized. + /// ~InterpreterSession() => Dispose(); /// diff --git a/unit/Directory.Build.props b/unit/Directory.Build.props new file mode 100644 index 00000000..24995471 --- /dev/null +++ b/unit/Directory.Build.props @@ -0,0 +1,9 @@ + + + + + + + $(NoWarn);CS1591 + + \ No newline at end of file From bc4e953a623e815a4ac4aec572fe2ecf7de11400 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:02:11 -0700 Subject: [PATCH 05/31] Update line ending in .editorconfig --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index bcfa1529..3fb61be2 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,7 +15,7 @@ indent_size = 4 indent_style = space # New line preferences -end_of_line = lf +end_of_line = crlf insert_final_newline = false trim_trailing_whitespace = true From 3539e037d54cfecbfeab12aac9bfb7b1927e602a Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:08:00 -0700 Subject: [PATCH 06/31] Fix IDE0230 (use UTF-8 string literal) --- src/Brainf_ckSharp/Brainf_ckParser.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Brainf_ckSharp/Brainf_ckParser.cs b/src/Brainf_ckSharp/Brainf_ckParser.cs index c2ab0ecf..6c94a898 100644 --- a/src/Brainf_ckSharp/Brainf_ckParser.cs +++ b/src/Brainf_ckSharp/Brainf_ckParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; using Brainf_ckSharp.Constants; using Brainf_ckSharp.Enums; @@ -45,20 +45,7 @@ public static partial class Brainf_ckParser /// /// A lookup table to quickly check characters /// - private static ReadOnlySpan OperatorsInverseLookupTable => new[] - { - (byte)Characters.LoopStart, - (byte)Characters.LoopEnd, - (byte)Characters.FunctionStart, - (byte)Characters.FunctionEnd, - (byte)Characters.Plus, - (byte)Characters.Minus, - (byte)Characters.ForwardPtr, - (byte)Characters.BackwardPtr, - (byte)Characters.PrintChar, - (byte)Characters.ReadChar, - (byte)Characters.FunctionCall - }; + private static ReadOnlySpan OperatorsInverseLookupTable => "[]()+-><.,:"u8; /// /// Checks whether or not an input character is a Brainf*ck/PBrain operator From e9921307541e5a2c6300db7d59a3632bc24ec20f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:09:31 -0700 Subject: [PATCH 07/31] Fix IDE0022 (use block body for methods) --- src/Brainf_ckSharp.Cli/Helpers/Logger.cs | 5 +- src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs | 5 +- .../Models/Ide/SourceCode.cs | 5 +- .../SubPages/CodeLibrarySubPageViewModel.cs | 5 +- .../ViewModels/ShellViewModel.cs | 20 +++- .../DataTemplates/DeveloperTemplate.xaml.cs | 5 +- .../Controls/Host/Header/HeaderButton.cs | 5 +- .../Controls/Host/Header/HeaderPanel.xaml.cs | 10 +- .../InputPanel/Header/MinimalHeaderButton.cs | 5 +- .../InputPanel/Header/StdinHeader.xaml.cs | 15 ++- .../SubPages/Host/SubPageHost.xaml.cs | 5 +- .../Converters/PivotSelectionConverter.cs | 10 +- .../Converters/UI/BoolToNotBoolConverter.cs | 5 +- .../IListExtensions.cs | 5 +- .../Resources/XamlResources.cs | 5 +- src/Brainf_ckSharp/Brainf_ckInterpreter.cs | 12 +- src/Brainf_ckSharp/Brainf_ckParser.cs | 5 +- .../Memory/Tools/MachineStateProvider.cs | 5 +- .../Models/FunctionDefinition.cs | 5 +- .../Models/Internal/StackFrame.cs | 5 +- .../Models/InterpreterSession.cs | 5 +- .../Models/SyntaxValidationResult.cs | 5 +- unit/Brainf_ckSharp.Unit/SyntaxTest.cs | 110 ++++++++++++++---- 23 files changed, 209 insertions(+), 53 deletions(-) diff --git a/src/Brainf_ckSharp.Cli/Helpers/Logger.cs b/src/Brainf_ckSharp.Cli/Helpers/Logger.cs index 417f5c08..729cbdba 100644 --- a/src/Brainf_ckSharp.Cli/Helpers/Logger.cs +++ b/src/Brainf_ckSharp.Cli/Helpers/Logger.cs @@ -11,7 +11,10 @@ internal static class Logger /// /// Inserts a new line to the console output /// - public static void NewLine() => Console.Write(Environment.NewLine); + public static void NewLine() + { + Console.Write(Environment.NewLine); + } /// /// Writes an opening tag diff --git a/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs b/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs index 009fd459..eb8414a2 100644 --- a/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs +++ b/src/Brainf_ckSharp.Git/Buffers/Pool{T}.cs @@ -92,5 +92,8 @@ private void ExpandBuffer() /// /// This can cause previously rented objects to be reused [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Reset() => this._Offset = 0; + public void Reset() + { + this._Offset = 0; + } } diff --git a/src/Brainf_ckSharp.Shared/Models/Ide/SourceCode.cs b/src/Brainf_ckSharp.Shared/Models/Ide/SourceCode.cs index e43a8e57..c4b497fe 100644 --- a/src/Brainf_ckSharp.Shared/Models/Ide/SourceCode.cs +++ b/src/Brainf_ckSharp.Shared/Models/Ide/SourceCode.cs @@ -50,7 +50,10 @@ private SourceCode(string content, IFile? file, CodeMetadata metadata) /// Creates a new instance with no linked file /// /// A new, empty instance - public static SourceCode CreateEmpty() => new(EmptyContent, null, new CodeMetadata()); + public static SourceCode CreateEmpty() + { + return new(EmptyContent, null, new CodeMetadata()); + } /// /// Creates a new instance from the specified reference file diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs index 8607b04c..4e724016 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs @@ -176,7 +176,10 @@ private void ProcessItem(object? item) /// /// Requests to pick and open a source code file /// - private void RequestOpenFile(bool favorite) => Messenger.Send(new PickOpenFileRequestMessage(favorite)); + private void RequestOpenFile(bool favorite) + { + Messenger.Send(new PickOpenFileRequestMessage(favorite)); + } /// /// Sends a request to load a specified code entry diff --git a/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs index 16725f82..05b5fa7b 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/ShellViewModel.cs @@ -112,12 +112,18 @@ public void RunConsoleScript() /// /// Deletes the last operator in the current console script /// - public void DeleteConsoleOperator() => Messenger.Send(); + public void DeleteConsoleOperator() + { + Messenger.Send(); + } /// /// Clears the current console command /// - public void ClearConsoleCommand() => Messenger.Send(); + public void ClearConsoleCommand() + { + Messenger.Send(); + } /// /// Clears the current console screen @@ -182,12 +188,18 @@ public void NewIdeFile() /// /// Inserts a new line into the IDE /// - public void InsertNewLine() => Messenger.Send(); + public void InsertNewLine() + { + Messenger.Send(); + } /// /// Deletes the last character in the IDE /// - public void DeleteIdeCharacter() => Messenger.Send(); + public void DeleteIdeCharacter() + { + Messenger.Send(); + } /// /// Opens a new file in the IDE diff --git a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs index dcc906b3..e64c4537 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/DataTemplates/DeveloperTemplate.xaml.cs @@ -29,7 +29,10 @@ public DeveloperTemplate() public User? ViewModel => DataContext as User; // Hides the progress ring - private void ImageExBase_OnImageExOpened(object sender, ImageExOpenedEventArgs e) => this.LoadingRing.Visibility = Visibility.Collapsed; + private void ImageExBase_OnImageExOpened(object sender, ImageExOpenedEventArgs e) + { + this.LoadingRing.Visibility = Visibility.Collapsed; + } // Opens the profile page of the current contributor private void Contributor_Clicked(object sender, RoutedEventArgs e) diff --git a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs index fa2179cb..c3d04718 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderButton.cs @@ -119,5 +119,8 @@ private void UpdateVisualState() } // Updates the UI when the control is selected - private void RootButton_Click(object sender, RoutedEventArgs e) => IsSelected = true; + private void RootButton_Click(object sender, RoutedEventArgs e) + { + IsSelected = true; + } } diff --git a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderPanel.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderPanel.xaml.cs index 8a55f979..84193080 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderPanel.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/Host/Header/HeaderPanel.xaml.cs @@ -43,10 +43,16 @@ private static void OnSelectedIndexPropertyChanged(DependencyObject d, Dependenc } // Sets the selected index to 0 when the console button is clicked - private void ConsoleHeaderSelected(object sender, EventArgs e) => SelectedIndex = 0; + private void ConsoleHeaderSelected(object sender, EventArgs e) + { + SelectedIndex = 0; + } // Sets the selected index to 1 when the IDE button is clicked - private void IdeHeaderSelected(object sender, EventArgs e) => SelectedIndex = 1; + private void IdeHeaderSelected(object sender, EventArgs e) + { + SelectedIndex = 1; + } /// /// Sets the loaded control as the draggable region for the title bar diff --git a/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/MinimalHeaderButton.cs b/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/MinimalHeaderButton.cs index 0b048714..528423f1 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/MinimalHeaderButton.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/MinimalHeaderButton.cs @@ -129,5 +129,8 @@ private void OnIsEnabledChanged(DependencyObject sender, DependencyProperty dp) } // Updates the UI when the control is selected - private void RootButton_Click(object sender, RoutedEventArgs e) => IsSelected = true; + private void RootButton_Click(object sender, RoutedEventArgs e) + { + IsSelected = true; + } } diff --git a/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/StdinHeader.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/StdinHeader.xaml.cs index 4395dc1c..e2060eb0 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/StdinHeader.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/Host/InputPanel/Header/StdinHeader.xaml.cs @@ -71,13 +71,22 @@ private static void OnStdinSelectedIndexPropertyChanged(DependencyObject d, Depe } // Sets the selected index to 0 when the keyboard button is clicked - private void VirtualKeyboardHeaderSelected(object sender, EventArgs e) => StdinSelectedIndex = 0; + private void VirtualKeyboardHeaderSelected(object sender, EventArgs e) + { + StdinSelectedIndex = 0; + } // Sets the selected index to 1 when the memory viewer button is clicked - private void MemoryViewerHeaderSelected(object sender, EventArgs e) => StdinSelectedIndex = 1; + private void MemoryViewerHeaderSelected(object sender, EventArgs e) + { + StdinSelectedIndex = 1; + } // Sets the selected index to 0 when the memory viewer button is deselected - private void MemoryViewerHeaderDeselected(object sender, EventArgs e) => StdinSelectedIndex = 0; + private void MemoryViewerHeaderDeselected(object sender, EventArgs e) + { + StdinSelectedIndex = 0; + } // Prevents the event from bubbling up the UI stack private void StdinBox_OnCharacterReceived(UIElement sender, CharacterReceivedRoutedEventArgs args) diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs index 41d08201..28bdb415 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs @@ -132,7 +132,10 @@ private void SubFrameControl_BackRequested(object sender, BackRequestedEventArgs } // Executes a UI refresh when the root size changes - private void SubFrameHost_SizeChanged(object sender, SizeChangedEventArgs e) => UpdateLayout(e.NewSize); + private void SubFrameHost_SizeChanged(object sender, SizeChangedEventArgs e) + { + UpdateLayout(e.NewSize); + } /// /// Adjusts the UI when the window is resized diff --git a/src/Brainf_ckSharp.Uwp/Converters/PivotSelectionConverter.cs b/src/Brainf_ckSharp.Uwp/Converters/PivotSelectionConverter.cs index 17fcd1f9..b54270c1 100644 --- a/src/Brainf_ckSharp.Uwp/Converters/PivotSelectionConverter.cs +++ b/src/Brainf_ckSharp.Uwp/Converters/PivotSelectionConverter.cs @@ -18,7 +18,10 @@ public sealed class PivotSelectionConverter : IValueConverter /// The input value /// The value representing [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int ConvertToIndex(ViewType viewType) => (int)viewType; + public static int ConvertToIndex(ViewType viewType) + { + return (int)viewType; + } /// /// Returns a value if the two arguments match @@ -39,7 +42,10 @@ public static Visibility ConvertToVisibility(ViewType viewType, ViewType target) /// The target value to match /// if the input values match, otherwise [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool ConvertIndexToBool(int index, int target) => index == target; + public static bool ConvertIndexToBool(int index, int target) + { + return index == target; + } /// public object Convert(object value, Type targetType, object parameter, string language) diff --git a/src/Brainf_ckSharp.Uwp/Converters/UI/BoolToNotBoolConverter.cs b/src/Brainf_ckSharp.Uwp/Converters/UI/BoolToNotBoolConverter.cs index 667ffbbb..78b1cd93 100644 --- a/src/Brainf_ckSharp.Uwp/Converters/UI/BoolToNotBoolConverter.cs +++ b/src/Brainf_ckSharp.Uwp/Converters/UI/BoolToNotBoolConverter.cs @@ -15,5 +15,8 @@ public static class BoolToNotBoolConverter /// The input value /// The negation of [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool Convert(bool value) => !value; + public static bool Convert(bool value) + { + return !value; + } } diff --git a/src/Brainf_ckSharp.Uwp/Extensions/System.Collections.Generic/IListExtensions.cs b/src/Brainf_ckSharp.Uwp/Extensions/System.Collections.Generic/IListExtensions.cs index e8bcb7dd..9495105e 100644 --- a/src/Brainf_ckSharp.Uwp/Extensions/System.Collections.Generic/IListExtensions.cs +++ b/src/Brainf_ckSharp.Uwp/Extensions/System.Collections.Generic/IListExtensions.cs @@ -14,5 +14,8 @@ public static class IListExtensions /// The type of items in the input list /// The input list of items [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void RemoveLast(this IList items) => items.RemoveAt(items.Count - 1); + public static void RemoveLast(this IList items) + { + items.RemoveAt(items.Count - 1); + } } diff --git a/src/Brainf_ckSharp.Uwp/Resources/XamlResources.cs b/src/Brainf_ckSharp.Uwp/Resources/XamlResources.cs index cc5e1a88..64c39b87 100644 --- a/src/Brainf_ckSharp.Uwp/Resources/XamlResources.cs +++ b/src/Brainf_ckSharp.Uwp/Resources/XamlResources.cs @@ -32,7 +32,10 @@ public static T Get(string key) /// The type of resource to set /// The key of the resource to create or update /// The resource value to set - public static void Set(string key, T value) => Application.Current.Resources[key] = value; + public static void Set(string key, T value) + { + Application.Current.Resources[key] = value; + } /// /// A with some hardcoded brushes diff --git a/src/Brainf_ckSharp/Brainf_ckInterpreter.cs b/src/Brainf_ckSharp/Brainf_ckInterpreter.cs index c961782f..130b3924 100644 --- a/src/Brainf_ckSharp/Brainf_ckInterpreter.cs +++ b/src/Brainf_ckSharp/Brainf_ckInterpreter.cs @@ -1,4 +1,4 @@ -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; using Brainf_ckSharp.Configurations; namespace Brainf_ckSharp; @@ -13,12 +13,18 @@ public static partial class Brainf_ckInterpreter /// /// A instance to prepare a script execution [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static DebugConfiguration CreateDebugConfiguration() => default; + public static DebugConfiguration CreateDebugConfiguration() + { + return default; + } /// /// Creates a new instance to prepare a script execution in RELEASE mode /// /// A instance to prepare a script execution [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ReleaseConfiguration CreateReleaseConfiguration() => default; + public static ReleaseConfiguration CreateReleaseConfiguration() + { + return default; + } } diff --git a/src/Brainf_ckSharp/Brainf_ckParser.cs b/src/Brainf_ckSharp/Brainf_ckParser.cs index 6c94a898..69692535 100644 --- a/src/Brainf_ckSharp/Brainf_ckParser.cs +++ b/src/Brainf_ckSharp/Brainf_ckParser.cs @@ -78,7 +78,10 @@ internal static bool TryParseOperator(char c, out byte op) /// The input script to validate /// A instance with the results of the parsing operation [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static SyntaxValidationResult ValidateSyntax(string source) => ValidateSyntax(source.AsSpan()); + public static SyntaxValidationResult ValidateSyntax(string source) + { + return ValidateSyntax(source.AsSpan()); + } /// /// Checks whether or not the syntax of the input script is valid diff --git a/src/Brainf_ckSharp/Memory/Tools/MachineStateProvider.cs b/src/Brainf_ckSharp/Memory/Tools/MachineStateProvider.cs index 3fd60369..6c54c4ba 100644 --- a/src/Brainf_ckSharp/Memory/Tools/MachineStateProvider.cs +++ b/src/Brainf_ckSharp/Memory/Tools/MachineStateProvider.cs @@ -20,7 +20,10 @@ public static class MachineStateProvider /// /// The size of the state machine to create /// A new instance with the specified parameters - public static IReadOnlyMachineState Create(int size) => Create(size, Specs.DefaultOverflowMode); + public static IReadOnlyMachineState Create(int size) + { + return Create(size, Specs.DefaultOverflowMode); + } /// /// Creates a new instance with the specified parameters diff --git a/src/Brainf_ckSharp/Models/FunctionDefinition.cs b/src/Brainf_ckSharp/Models/FunctionDefinition.cs index c10a1863..08ae8e26 100644 --- a/src/Brainf_ckSharp/Models/FunctionDefinition.cs +++ b/src/Brainf_ckSharp/Models/FunctionDefinition.cs @@ -71,7 +71,10 @@ public bool Equals(FunctionDefinition? other) } /// - public override bool Equals(object? obj) => Equals(obj as FunctionDefinition); + public override bool Equals(object? obj) + { + return Equals(obj as FunctionDefinition); + } /// public override int GetHashCode() diff --git a/src/Brainf_ckSharp/Models/Internal/StackFrame.cs b/src/Brainf_ckSharp/Models/Internal/StackFrame.cs index bb82b5c9..a3dcee7d 100644 --- a/src/Brainf_ckSharp/Models/Internal/StackFrame.cs +++ b/src/Brainf_ckSharp/Models/Internal/StackFrame.cs @@ -46,5 +46,8 @@ public StackFrame(Range range, int offset) /// The current offset during execution /// A instance like the current one, but with a different offset [MethodImpl(MethodImplOptions.AggressiveInlining)] - public StackFrame WithOffset(int offset) => new(this.Range, offset); + public StackFrame WithOffset(int offset) + { + return new(this.Range, offset); + } } diff --git a/src/Brainf_ckSharp/Models/InterpreterSession.cs b/src/Brainf_ckSharp/Models/InterpreterSession.cs index 6f5294d1..c271dcd5 100644 --- a/src/Brainf_ckSharp/Models/InterpreterSession.cs +++ b/src/Brainf_ckSharp/Models/InterpreterSession.cs @@ -250,7 +250,10 @@ ref this.StackFrames.DangerousGetReference(), } /// - public void Reset() => throw new NotSupportedException("An interpreter session can't be reset"); + public void Reset() + { + throw new NotSupportedException("An interpreter session can't be reset"); + } /// /// Disposes resources when the instance is finalized. diff --git a/src/Brainf_ckSharp/Models/SyntaxValidationResult.cs b/src/Brainf_ckSharp/Models/SyntaxValidationResult.cs index 478ea5c9..63ecef6e 100644 --- a/src/Brainf_ckSharp/Models/SyntaxValidationResult.cs +++ b/src/Brainf_ckSharp/Models/SyntaxValidationResult.cs @@ -90,7 +90,10 @@ public bool Equals(SyntaxValidationResult other) } /// - public override bool Equals(object obj) => obj is SyntaxValidationResult result && Equals(result); + public override bool Equals(object obj) + { + return obj is SyntaxValidationResult result && Equals(result); + } /// public override int GetHashCode() diff --git a/unit/Brainf_ckSharp.Unit/SyntaxTest.cs b/unit/Brainf_ckSharp.Unit/SyntaxTest.cs index b8d5a593..492a96e5 100644 --- a/unit/Brainf_ckSharp.Unit/SyntaxTest.cs +++ b/unit/Brainf_ckSharp.Unit/SyntaxTest.cs @@ -22,13 +22,22 @@ private static void AssertIsOperator(string characters, bool result) } [TestMethod] - public void AreOperators() => AssertIsOperator("+-><[].,():", true); + public void AreOperators() + { + AssertIsOperator("+-><[].,():", true); + } [TestMethod] - public void AreNotOperators_Ascii() => AssertIsOperator("abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*{}_=ABCDEFGHIJKLMNOPQRSTUVWXYZ", false); + public void AreNotOperators_Ascii() + { + AssertIsOperator("abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*{}_=ABCDEFGHIJKLMNOPQRSTUVWXYZ", false); + } [TestMethod] - public void AreNotOperators_Unicode() => AssertIsOperator("©®℗™‰&⁜※௹₣₺﷼¼⅔⨊⨌⨏⨐ΔΕνΜΩχοἉ〒▽〒→_→ಠ_ಠ◑﹏◐😊😄🚀🍻🎉🤷‍♂️🐱‍🏍🐱‍🚀✅", false); + public void AreNotOperators_Unicode() + { + AssertIsOperator("©®℗™‰&⁜※௹₣₺﷼¼⅔⨊⨌⨏⨐ΔΕνΜΩχοἉ〒▽〒→_→ಠ_ಠ◑﹏◐😊😄🚀🍻🎉🤷‍♂️🐱‍🏍🐱‍🚀✅", false); + } // Tests a valid script private static void AssertIsValid(string script) @@ -41,28 +50,52 @@ private static void AssertIsValid(string script) } [TestMethod] - public void OnlyPlus() => AssertIsValid("+++++"); + public void OnlyPlus() + { + AssertIsValid("+++++"); + } [TestMethod] - public void PlusAndEmptyLoop() => AssertIsValid("+++++[]"); + public void PlusAndEmptyLoop() + { + AssertIsValid("+++++[]"); + } [TestMethod] - public void PlusAndSmallFunction() => AssertIsValid("++(+)"); + public void PlusAndSmallFunction() + { + AssertIsValid("++(+)"); + } [TestMethod] - public void NestedLoops() => AssertIsValid("[++.]++[-][++[++]]"); + public void NestedLoops() + { + AssertIsValid("[++.]++[-][++[++]]"); + } [TestMethod] - public void LoopsAndFunctions() => AssertIsValid("++(+)[][++[-]]++.>(+)"); + public void LoopsAndFunctions() + { + AssertIsValid("++(+)[][++[-]]++.>(+)"); + } [TestMethod] - public void MultipleFunctions() => AssertIsValid("++>>>(+)[]+++(+)(-)(>>>)"); + public void MultipleFunctions() + { + AssertIsValid("++>>>(+)[]+++(+)(-)(>>>)"); + } [TestMethod] - public void HelloWorld() => AssertIsValid("[]+++++[>+++++[>+++>++++[>+>+<<-]>>>+++++>+<<<<<<-]<-]>>---.>>+.>++++++++..+++.>>+++++++.<------.<.+++.------.<-.>>>+."); + public void HelloWorld() + { + AssertIsValid("[]+++++[>+++++[>+++>++++[>+>+<<-]>>>+++++>+<<<<<<-]<-]>>---.>>+.>++++++++..+++.>>+++++++.<------.<.+++.------.<-.>>>+."); + } [TestMethod] - public void Fibonacci() => AssertIsValid("[.,-.,,,.]++++++++[>++++>++++++<<-]>>.[>+>+<<-]>>[<<+>>-],>,<<[>->-<<-]>[<++++++++++>-]>[<<+>>-]<<-1>>>+>>>+(->[>+<-]>[>>++++++++++<<[>+>>+<<<-]>>>[<<<+>>>-]<<[->->+<[>>>]=>[<++++++++++>---------->>>>+<]<<<<<]>[-]>[<<+>>-]>>>>[<<<<<+>>>>>-]<<<<<<<[-]+>>]<<[+++++[>++++++++<-]>.[-]<<<])<<<<<(<[<<.>>->>>1[>+>+>>+<<<<-]>>[<<+>>-]<<<[>+<-]>>[<<+>>-]>>:+<<<<<:]):"); + public void Fibonacci() + { + AssertIsValid("[.,-.,,,.]++++++++[>++++>++++++<<-]>>.[>+>+<<-]>>[<<+>>-],>,<<[>->-<<-]>[<++++++++++>-]>[<<+>>-]<<-1>>>+>>>+(->[>+<-]>[>>++++++++++<<[>+>>+<<<-]>>>[<<<+>>>-]<<[->->+<[>>>]=>[<++++++++++>---------->>>>+<]<<<<<]>[-]>[<<+>>-]>>>>[<<<<<+>>>>>-]<<<<<<<[-]+>>]<<[+++++[>++++++++<-]>.[-]<<<])<<<<<(<[<<.>>->>>1[>+>+>>+<<<<-]>>[<<+>>-]<<<[>+<-]>>[<<+>>-]>>:+<<<<<:]):"); + } // Tests an invalid script private static void AssertIsInvalid(string script, int position, SyntaxError error) @@ -75,35 +108,68 @@ private static void AssertIsInvalid(string script, int position, SyntaxError err } [TestMethod] - public void MismatchedBrackets1() => AssertIsInvalid("++[+>]]", 6, SyntaxError.MismatchedSquareBracket); + public void MismatchedBrackets1() + { + AssertIsInvalid("++[+>]]", 6, SyntaxError.MismatchedSquareBracket); + } [TestMethod] - public void MismatchedBrackets2() => AssertIsInvalid("]", 0, SyntaxError.MismatchedSquareBracket); + public void MismatchedBrackets2() + { + AssertIsInvalid("]", 0, SyntaxError.MismatchedSquareBracket); + } [TestMethod] - public void IncompleteLoop() => AssertIsInvalid("++[+>", 2, SyntaxError.IncompleteLoop); + public void IncompleteLoop() + { + AssertIsInvalid("++[+>", 2, SyntaxError.IncompleteLoop); + } [TestMethod] - public void MismatchedParenthesis() => AssertIsInvalid("++(++>)+)", 8, SyntaxError.MismatchedParenthesis); + public void MismatchedParenthesis() + { + AssertIsInvalid("++(++>)+)", 8, SyntaxError.MismatchedParenthesis); + } [TestMethod] - public void NestedFunctionDeclaration() => AssertIsInvalid("++(++>(++>)+)", 6, SyntaxError.NestedFunctionDeclaration); + public void NestedFunctionDeclaration() + { + AssertIsInvalid("++(++>(++>)+)", 6, SyntaxError.NestedFunctionDeclaration); + } [TestMethod] - public void EmptyFunction1() => AssertIsInvalid("++()>", 3, SyntaxError.EmptyFunctionDeclaration); + public void EmptyFunction1() + { + AssertIsInvalid("++()>", 3, SyntaxError.EmptyFunctionDeclaration); + } [TestMethod] - public void EmptyFunction2() => AssertIsInvalid("++(hello!)", 9, SyntaxError.EmptyFunctionDeclaration); + public void EmptyFunction2() + { + AssertIsInvalid("++(hello!)", 9, SyntaxError.EmptyFunctionDeclaration); + } [TestMethod] - public void InvalidFunctionDeclaration() => AssertIsInvalid("+[>>+(++>)]++:", 5, SyntaxError.InvalidFunctionDeclaration); + public void InvalidFunctionDeclaration() + { + AssertIsInvalid("+[>>+(++>)]++:", 5, SyntaxError.InvalidFunctionDeclaration); + } [TestMethod] - public void IncompleteFunctionDeclaration() => AssertIsInvalid("++(+++>", 2, SyntaxError.IncompleteFunctionDeclaration); + public void IncompleteFunctionDeclaration() + { + AssertIsInvalid("++(+++>", 2, SyntaxError.IncompleteFunctionDeclaration); + } [TestMethod] - public void NoOperators1() => AssertIsInvalid("", -1, SyntaxError.MissingOperators); + public void NoOperators1() + { + AssertIsInvalid("", -1, SyntaxError.MissingOperators); + } [TestMethod] - public void NoOperators2() => AssertIsInvalid("Hello world!", -1, SyntaxError.MissingOperators); + public void NoOperators2() + { + AssertIsInvalid("Hello world!", -1, SyntaxError.MissingOperators); + } } From a614c00d15eee01c9a3c48ba7499b250eacf1a1e Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:21:58 -0700 Subject: [PATCH 08/31] Fix CA1001 (implement IDisposable where applicable) --- .../ViewModels/Controls/StatusBarViewModel.cs | 2 ++ .../Controls/SubPages/IdeResultSubPageViewModel.cs | 1 + src/GitHub/GitHubService.cs | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs index 2c781bfe..5b5aac04 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs @@ -13,6 +13,8 @@ using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging.Messages; +#pragma warning disable CA1001 + namespace Brainf_ckSharp.Shared.ViewModels.Controls; /// diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs index e0ca693c..e947e8f6 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/IdeResultSubPageViewModel.cs @@ -17,6 +17,7 @@ using Nito.AsyncEx; #nullable enable +#pragma warning disable CA1001 namespace Brainf_ckSharp.Shared.ViewModels.Controls.SubPages; diff --git a/src/GitHub/GitHubService.cs b/src/GitHub/GitHubService.cs index 87c1acd6..97e863c7 100644 --- a/src/GitHub/GitHubService.cs +++ b/src/GitHub/GitHubService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Net.Http; using System.Text.Json; @@ -11,7 +11,7 @@ namespace GitHub; /// /// The default implementation. /// -public sealed class GitHubService : IGitHubService +public sealed class GitHubService : IGitHubService, IDisposable { /// /// Gets the base URL for the service @@ -44,4 +44,10 @@ public async Task GetUserAsync(string username) return user ?? throw new JsonException("Failed to deserialize a GitHub user."); } + + /// + public void Dispose() + { + this.httpClient.Dispose(); + } } From 87575970ccaf53f63e9889db015a236ee1fb7e05 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:24:21 -0700 Subject: [PATCH 09/31] Fix IDE0048 (add parentheses for clarity) --- .../ViewModels/Controls/StatusBarViewModel.cs | 4 ++-- ...ainf_ckInlineFormatterHelper.StackTrace.cs | 4 ++-- .../Behaviors/AnimatedCommandBarBehavior.cs | 4 ++-- .../SubPages/Host/SubPageHost.xaml.cs | 6 ++--- .../Extensions/System/StringExtensions.cs | 2 +- .../Windows.Storage/IFileExtensions.cs | 2 +- .../Brainf_ckInterpreter.Loader.cs | 4 ++-- .../Brainf_ckInterpreter.Runner.Release.cs | 2 +- src/Brainf_ckSharp/Enums/ExitCode.cs | 24 +++++++++---------- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs index 5b5aac04..3a06a696 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs @@ -143,8 +143,8 @@ private void RunBackgroundCode() stdin.Equals(this._Stdin) && memorySize == this._MemorySize && overflowMode == this._OverflowMode && - (machineState is null && this._MachineState is null || - machineState?.Equals(this._MachineState!) == true)) + ((machineState is null && this._MachineState is null) || + machineState?.Equals(this._MachineState!) == true)) { return; } diff --git a/src/Brainf_ckSharp.Uwp/AttachedProperties/Brainf_ckInlineFormatterHelper.StackTrace.cs b/src/Brainf_ckSharp.Uwp/AttachedProperties/Brainf_ckInlineFormatterHelper.StackTrace.cs index 18fbe7f4..28a7203e 100644 --- a/src/Brainf_ckSharp.Uwp/AttachedProperties/Brainf_ckInlineFormatterHelper.StackTrace.cs +++ b/src/Brainf_ckSharp.Uwp/AttachedProperties/Brainf_ckInlineFormatterHelper.StackTrace.cs @@ -97,7 +97,7 @@ private static void OnStackTracePropertyChanged(DependencyObject d, DependencyPr List<(int Length, int Occurrences)> info = new(); while (i < frames.Count) { - for (int step = 1; step < 5 && i + step * 2 - 1 < frames.Count; step++) + for (int step = 1; step < 5 && i + (step * 2) - 1 < frames.Count; step++) { // Find a valid sub-pattern of a given length bool valid = true; @@ -111,7 +111,7 @@ private static void OnStackTracePropertyChanged(DependencyObject d, DependencyPr // Check of many times the pattern repeats int occurrences = 2; - for (int j = i + step * 2; j + step - 1 < frames.Count; j += step) + for (int j = i + (step * 2); j + step - 1 < frames.Count; j += step) { valid = true; for (int k = 0; k < step; k++) diff --git a/src/Brainf_ckSharp.Uwp/Behaviors/AnimatedCommandBarBehavior.cs b/src/Brainf_ckSharp.Uwp/Behaviors/AnimatedCommandBarBehavior.cs index b72f7390..b0533d13 100644 --- a/src/Brainf_ckSharp.Uwp/Behaviors/AnimatedCommandBarBehavior.cs +++ b/src/Brainf_ckSharp.Uwp/Behaviors/AnimatedCommandBarBehavior.cs @@ -141,7 +141,7 @@ from button in commandBar.PrimaryCommands.Cast() } // Wait for the initial animations to finish - await Task.Delay((pendingElements.Count - 1) * ButtonsFadeDelayBetweenAnimations + ContentAnimationDuration); + await Task.Delay(((pendingElements.Count - 1) * ButtonsFadeDelayBetweenAnimations) + ContentAnimationDuration); // Set the animated buttons to invisible foreach (var item in pendingElements) @@ -169,7 +169,7 @@ from button in commandBar.PrimaryCommands.Cast() } // Wait for the second animations to finish - await Task.Delay((targetElements.Count - 1) * ButtonsFadeDelayBetweenAnimations + ContentAnimationDuration); + await Task.Delay(((targetElements.Count - 1) * ButtonsFadeDelayBetweenAnimations) + ContentAnimationDuration); commandBar.IsHitTestVisible = true; } diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs index 28bdb415..fb253f5f 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs @@ -166,7 +166,7 @@ void UpdateLayout(double width, double height) contentBorderThickness.Top = contentBorderThickness.Bottom = 0; // Visual state update - if (targetWidth > size.Width - 48 * 2) + if (targetWidth > size.Width - (48 * 2)) { this.ContentGrid.MaxWidth = targetWidth; VisualStateManager.GoToState(this, nameof(this.TopBackButton), false); @@ -210,8 +210,8 @@ void UpdateLayout(double width, double height) } UpdateLayout( - maxWidth + MinimumConstrainedMarginThreshold * 2 >= size.Width ? double.NaN : maxWidth, - maxHeight + MinimumConstrainedMarginThreshold * 2 >= size.Height ? double.NaN : maxHeight); + maxWidth + (MinimumConstrainedMarginThreshold * 2) >= size.Width ? double.NaN : maxWidth, + maxHeight + (MinimumConstrainedMarginThreshold * 2) >= size.Height ? double.NaN : maxHeight); break; } diff --git a/src/Brainf_ckSharp.Uwp/Extensions/System/StringExtensions.cs b/src/Brainf_ckSharp.Uwp/Extensions/System/StringExtensions.cs index c5dd74b4..5e8528a1 100644 --- a/src/Brainf_ckSharp.Uwp/Extensions/System/StringExtensions.cs +++ b/src/Brainf_ckSharp.Uwp/Extensions/System/StringExtensions.cs @@ -31,7 +31,7 @@ public static unsafe string InterleaveWithCharacter(this ReadOnlySpan text for (int i = 0; i < textLength; i++) { Unsafe.Add(ref bufferRef, i * 2) = Unsafe.Add(ref textRef, i); - Unsafe.Add(ref bufferRef, i * 2 + 1) = c; + Unsafe.Add(ref bufferRef, (i * 2) + 1) = c; } // Create a string from the temporary buffer diff --git a/src/Brainf_ckSharp.Uwp/Extensions/Windows.Storage/IFileExtensions.cs b/src/Brainf_ckSharp.Uwp/Extensions/Windows.Storage/IFileExtensions.cs index 9fa49389..3a6ac2d6 100644 --- a/src/Brainf_ckSharp.Uwp/Extensions/Windows.Storage/IFileExtensions.cs +++ b/src/Brainf_ckSharp.Uwp/Extensions/Windows.Storage/IFileExtensions.cs @@ -21,7 +21,7 @@ public static unsafe string GetFormattedPath(this IFile file) const int separatorLength = 3; // " » " int numberOfSeparators = file.Path.Count(Path.DirectorySeparatorChar), - formattedLength = file.Path.Length + numberOfSeparators * (separatorLength - 1) + separatorLength; + formattedLength = file.Path.Length + (numberOfSeparators * (separatorLength - 1)) + separatorLength; // The temporary buffer has space for one extra separator that is // always initialized even if it's not used in the final string. diff --git a/src/Brainf_ckSharp/Brainf_ckInterpreter.Loader.cs b/src/Brainf_ckSharp/Brainf_ckInterpreter.Loader.cs index b4aafe54..550466c5 100644 --- a/src/Brainf_ckSharp/Brainf_ckInterpreter.Loader.cs +++ b/src/Brainf_ckSharp/Brainf_ckInterpreter.Loader.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; using Brainf_ckSharp.Constants; using Brainf_ckSharp.Models; @@ -78,7 +78,7 @@ private static void LoadJumpTable( // executable, because that is the maximum number of open square brackets in a valid source file. // The two temporary buffers are used to implement an indirect indexing system while building // the table, which allows to reduce the complexity of the operation from O(N^2) to O(N). - int tempBuffersLength = opcodes.Length / 2 + 1; + int tempBuffersLength = (opcodes.Length / 2) + 1; using SpanOwner rootTempIndices = SpanOwner.Allocate(tempBuffersLength); using SpanOwner functionTempIndices = SpanOwner.Allocate(tempBuffersLength); ref int rootTempIndicesRef = ref rootTempIndices.DangerousGetReference(); diff --git a/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs b/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs index b0106325..fc2b2c19 100644 --- a/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs +++ b/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs @@ -259,7 +259,7 @@ private static ExitCode Run( { // Fast path for [-] loops executionContext.ResetCell(); - totalOperations += executionContext.Current * 2 + 1; + totalOperations += (executionContext.Current * 2) + 1; i += 2; } break; diff --git a/src/Brainf_ckSharp/Enums/ExitCode.cs b/src/Brainf_ckSharp/Enums/ExitCode.cs index ff1ad1cb..3ff73a8b 100644 --- a/src/Brainf_ckSharp/Enums/ExitCode.cs +++ b/src/Brainf_ckSharp/Enums/ExitCode.cs @@ -21,60 +21,60 @@ public enum ExitCode : uint /// /// The source code produced a runtime exception /// - ExceptionThrown = 1 << 2| Failure, + ExceptionThrown = (1 << 2)| Failure, /// /// The code run into an infinite loop (according to the desired time threshold) /// - ThresholdExceeded = 1 << 3 | Failure, + ThresholdExceeded = (1 << 3) | Failure, /// /// The script execution was halted after reaching a breakpoint /// - BreakpointReached = 1 << 4 | Success, + BreakpointReached = (1 << 4) | Success, /// /// The script tried to move back from the first memory location /// - LowerBoundExceeded = 1 << 5 | ExceptionThrown, + LowerBoundExceeded = (1 << 5) | ExceptionThrown, /// /// The script tried to move over the last memory location /// - UpperBoundExceeded = 1 << 6 | ExceptionThrown, + UpperBoundExceeded = (1 << 6) | ExceptionThrown, /// /// The script tried to lower the value of a memory cell set to 0 /// - NegativeValue = 1 << 7 | ExceptionThrown, + NegativeValue = (1 << 7) | ExceptionThrown, /// /// The script tried to increase the value of a memory cell that had the maximum allowed value /// - MaxValueExceeded = 1 << 8 | ExceptionThrown, + MaxValueExceeded = (1 << 8) | ExceptionThrown, /// /// The script requested another input character when the available buffer was empty /// - StdinBufferExhausted = 1 << 9 | ExceptionThrown, + StdinBufferExhausted = (1 << 9) | ExceptionThrown, /// /// The script tried to print too many characters in the output buffer /// - StdoutBufferLimitExceeded = 1 << 10 | ExceptionThrown, + StdoutBufferLimitExceeded = (1 << 10) | ExceptionThrown, /// /// The script tried to reference an undefined function /// - UndefinedFunctionCalled = 1 << 11 | ExceptionThrown, + UndefinedFunctionCalled = (1 << 11) | ExceptionThrown, /// /// The script tried to define a function with a value that was already mapped to another function /// - DuplicateFunctionDefinition = 1 << 12 | ExceptionThrown, + DuplicateFunctionDefinition = (1 << 12) | ExceptionThrown, /// /// The script executed one or more recursive functions too many times /// - StackLimitExceeded = 1 << 13 | ExceptionThrown + StackLimitExceeded = (1 << 13) | ExceptionThrown } From 2df3761e8439751f4f32cc410cdb02d32be2e9eb Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:31:49 -0700 Subject: [PATCH 10/31] Fix IDE0251 (make member readonly) --- src/Brainf_ckSharp/Buffers/StdinBuffer.cs | 6 +++--- src/Brainf_ckSharp/Buffers/StdoutBuffer.cs | 2 +- .../Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Brainf_ckSharp/Buffers/StdinBuffer.cs b/src/Brainf_ckSharp/Buffers/StdinBuffer.cs index e838f5e3..7cf20449 100644 --- a/src/Brainf_ckSharp/Buffers/StdinBuffer.cs +++ b/src/Brainf_ckSharp/Buffers/StdinBuffer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CommunityToolkit.HighPerformance; @@ -36,7 +36,7 @@ public StdinBuffer(ReadOnlyMemory data) /// Creates a new instance to read from the underlying buffer /// /// A instance to read characters - public Reader CreateReader() + public readonly Reader CreateReader() { return new(this.Data.Span, this._Position); } @@ -100,7 +100,7 @@ public bool TryRead(out char c) } /// - public override string ToString() + public override readonly string ToString() { return StringPool.Shared.GetOrAdd(this.Data); } diff --git a/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs b/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs index d9f163cd..cfd90bee 100644 --- a/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs +++ b/src/Brainf_ckSharp/Buffers/StdoutBuffer.cs @@ -47,7 +47,7 @@ public static StdoutBuffer Allocate() /// Creates a new instance to write to the underlying buffer /// /// A instance to write characters - public Writer CreateWriter() + public readonly Writer CreateWriter() { return new(this.Buffer, this._Position); } diff --git a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs index d4805603..1dfd4eaa 100644 --- a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs +++ b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.Enumerator.cs @@ -40,7 +40,7 @@ internal IReadOnlyMachineStateEnumerator(TuringMachineState machineState) } /// - public Brainf_ckMemoryCell Current + public readonly Brainf_ckMemoryCell Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get => this.MachineState[this._Index]; From c62a872c85a2a176294a0bf041cc3cad0c3fdc4d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:33:29 -0700 Subject: [PATCH 11/31] Fix IDE0055 (fix formatting) --- .../ViewModels/Controls/StatusBarViewModel.cs | 2 +- .../SubPages/CodeLibrarySubPageViewModel.cs | 4 +- .../ViewModels/Views/ConsoleViewModel.cs | 2 +- .../ViewModels/Views/IdeViewModel.cs | 2 +- src/Brainf_ckSharp.Uwp/App.Main.cs | 4 +- .../BlinkingAnimationHelper.cs | 2 +- .../SubPages/Host/SubPageHost.xaml.cs | 42 +++++++++---------- .../Brainf_ckInterpreter.Runner.Release.cs | 4 +- src/Brainf_ckSharp/Brainf_ckParser.TOpcode.cs | 4 +- src/Brainf_ckSharp/Brainf_ckParser.cs | 2 +- .../Extensions/ConfigurationExtensions.cs | 32 +++++++------- src/Brainf_ckSharp/Enums/ExitCode.cs | 2 +- .../Interfaces/IReadOnlyMachineState.cs | 2 +- 13 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs index 3a06a696..3e9b9467 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/StatusBarViewModel.cs @@ -74,7 +74,7 @@ public StatusBarViewModel(IMessenger messenger, ISettingsService settingsService this.Context = SynchronizationContext.Current; this.Timer = new Timer(vm => ((StatusBarViewModel)vm).RunBackgroundCode(), this, default, TimeSpan.FromSeconds(2)); } - + /// protected override void OnActivated() { diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs index 4e724016..ef89becd 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Controls/SubPages/CodeLibrarySubPageViewModel.cs @@ -135,9 +135,9 @@ private async Task LoadDataAsync() { // Deserialize the metadata and prepare the model CodeMetadata? metadata = string.IsNullOrEmpty(data) ? new() : JsonSerializer.Deserialize(data, Brainf_ckSharpJsonSerializerContext.Default.CodeMetadata); - + if (metadata is null) ThrowHelper.ThrowInvalidOperationException("Failed to load the source code metadata"); - + CodeLibraryEntry? entry = await CodeLibraryEntry.TryLoadFromFileAsync(file, metadata); if (entry is null) ThrowHelper.ThrowInvalidOperationException("Failed to load the source code file"); diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs index a8664107..e1ffdd3b 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Views/ConsoleViewModel.cs @@ -128,7 +128,7 @@ private async Task TryAddOperatorAsync(char c) { using (await this.ExecutionMutex.LockAsync()) { - if (!Brainf_ckParser.IsOperator(c)) return; + if (!Brainf_ckParser.IsOperator(c)) return; if (Source.LastOrDefault() is ConsoleCommand command) { command.Command += c; diff --git a/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs b/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs index 233aafcc..b38344a7 100644 --- a/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs +++ b/src/Brainf_ckSharp.Shared/ViewModels/Views/IdeViewModel.cs @@ -290,7 +290,7 @@ public async Task RestoreStateAsync(IFile? file) { state = await JsonSerializer.DeserializeAsync(stream, Brainf_ckSharpJsonSerializerContext.Default.IdeState); } - + if (state is null) ThrowHelper.ThrowInvalidOperationException("Failed to load previous IDE state"); if (state.FilePath is null) Code = SourceCode.CreateEmpty(); diff --git a/src/Brainf_ckSharp.Uwp/App.Main.cs b/src/Brainf_ckSharp.Uwp/App.Main.cs index 8f9116d3..66f0073d 100644 --- a/src/Brainf_ckSharp.Uwp/App.Main.cs +++ b/src/Brainf_ckSharp.Uwp/App.Main.cs @@ -65,7 +65,7 @@ public static void Main(string[] args) return; } - + // If the activation uses a protocol, handle the possible cases. // Currently there are two possible protocols being used: // - [/switch?key=...] is used to request a direct switch to an existing instance. @@ -88,7 +88,7 @@ public static void Main(string[] args) return; } - + // File request by path from a timeline item if (protocolArgs.Uri.LocalPath.Equals("/file")) { diff --git a/src/Brainf_ckSharp.Uwp/AttachedProperties/BlinkingAnimationHelper.cs b/src/Brainf_ckSharp.Uwp/AttachedProperties/BlinkingAnimationHelper.cs index 13301b5e..5034e3f2 100644 --- a/src/Brainf_ckSharp.Uwp/AttachedProperties/BlinkingAnimationHelper.cs +++ b/src/Brainf_ckSharp.Uwp/AttachedProperties/BlinkingAnimationHelper.cs @@ -9,7 +9,7 @@ namespace Brainf_ckSharp.Uwp.AttachedProperties; /// A with an attached XAML property to display a blinking animation on a target /// public static class BlinkingAnimationHelper -{ +{ /// /// Gets the value of for a given /// diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs index fb253f5f..d2d06db9 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs @@ -197,32 +197,32 @@ void UpdateLayout(double width, double height) { // A constrained content, with a given maximum size case IConstrainedSubPage constrained: + { + double maxHeight = constrained.MaxExpandedHeight; + double maxWidth = constrained.MaxExpandedWidth; + + // Disable the fullscreen mode if requested, and if there's enough space + if (size.Height >= 600 && size.Width >= 540 && + double.IsInfinity(constrained.MaxExpandedHeight) && double.IsInfinity(constrained.MaxExpandedWidth)) { - double maxHeight = constrained.MaxExpandedHeight; - double maxWidth = constrained.MaxExpandedWidth; - - // Disable the fullscreen mode if requested, and if there's enough space - if (size.Height >= 600 && size.Width >= 540 && - double.IsInfinity(constrained.MaxExpandedHeight) && double.IsInfinity(constrained.MaxExpandedWidth)) - { - maxHeight = size.Height - 160; - maxWidth = size.Width - 160; - } - - UpdateLayout( - maxWidth + (MinimumConstrainedMarginThreshold * 2) >= size.Width ? double.NaN : maxWidth, - maxHeight + (MinimumConstrainedMarginThreshold * 2) >= size.Height ? double.NaN : maxHeight); - break; + maxHeight = size.Height - 160; + maxWidth = size.Width - 160; } + UpdateLayout( + maxWidth + (MinimumConstrainedMarginThreshold * 2) >= size.Width ? double.NaN : maxWidth, + maxHeight + (MinimumConstrainedMarginThreshold * 2) >= size.Height ? double.NaN : maxHeight); + break; + } + // Any content, that toggles between almost full screen and the compact state case { } _: - { - UpdateLayout( - ExpandedStateMinimumWidth >= size.Width ? double.NaN : size.Width - 160, - ExpandedStateMinimumHeight >= size.Height ? double.NaN : size.Height - 160); - break; - } + { + UpdateLayout( + ExpandedStateMinimumWidth >= size.Width ? double.NaN : size.Width - 160, + ExpandedStateMinimumHeight >= size.Height ? double.NaN : size.Height - 160); + break; + } } // Additional UI tweaks diff --git a/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs b/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs index fc2b2c19..35d7a8db 100644 --- a/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs +++ b/src/Brainf_ckSharp/Brainf_ckInterpreter.Runner.Release.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; using System.Threading; using Brainf_ckSharp.Buffers; @@ -212,7 +212,7 @@ private static ExitCode Run( // ptr-- case Operators.BackwardPtr: - if (!executionContext.TryMoveBack(opcode.Count, ref totalOperations)) + if (!executionContext.TryMoveBack(opcode.Count, ref totalOperations)) goto LowerBoundExceeded; break; diff --git a/src/Brainf_ckSharp/Brainf_ckParser.TOpcode.cs b/src/Brainf_ckSharp/Brainf_ckParser.TOpcode.cs index c9dc1ad3..6b1235f6 100644 --- a/src/Brainf_ckSharp/Brainf_ckParser.TOpcode.cs +++ b/src/Brainf_ckSharp/Brainf_ckParser.TOpcode.cs @@ -69,12 +69,12 @@ internal static string ExtractSource(Span opcodes) { return Debug.ExtractSource(opcodes.Cast()); } - + if (typeof(TOpcode) == typeof(Brainf_ckOperation)) { return Release.ExtractSource(opcodes.Cast()); } - + throw new ArgumentException($"Invalid opcode type: {typeof(TOpcode)}", nameof(TOpcode)); } } diff --git a/src/Brainf_ckSharp/Brainf_ckParser.cs b/src/Brainf_ckSharp/Brainf_ckParser.cs index 69692535..d07ea4d1 100644 --- a/src/Brainf_ckSharp/Brainf_ckParser.cs +++ b/src/Brainf_ckSharp/Brainf_ckParser.cs @@ -21,7 +21,7 @@ public static partial class Brainf_ckParser 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - Operators.FunctionStart, + Operators.FunctionStart, Operators.FunctionEnd, 0xFF, Operators.Plus, diff --git a/src/Brainf_ckSharp/Configurations/Extensions/ConfigurationExtensions.cs b/src/Brainf_ckSharp/Configurations/Extensions/ConfigurationExtensions.cs index f9f7b483..fc890e80 100644 --- a/src/Brainf_ckSharp/Configurations/Extensions/ConfigurationExtensions.cs +++ b/src/Brainf_ckSharp/Configurations/Extensions/ConfigurationExtensions.cs @@ -24,7 +24,7 @@ public static partial class DebugConfigurationExtensions public static ref readonly DebugConfiguration WithSource(in this DebugConfiguration configuration, string source) { Unsafe.AsRef(configuration.Source) = source.AsMemory(); - + return ref configuration; } @@ -38,7 +38,7 @@ public static ref readonly DebugConfiguration WithSource(in this DebugConfigurat public static ref readonly DebugConfiguration WithSource(in this DebugConfiguration configuration, ReadOnlyMemory source) { Unsafe.AsRef(configuration.Source) = source; - + return ref configuration; } @@ -52,7 +52,7 @@ public static ref readonly DebugConfiguration WithSource(in this DebugConfigurat public static ref readonly DebugConfiguration WithStdin(in this DebugConfiguration configuration, string stdin) { Unsafe.AsRef(configuration.Stdin) = stdin.AsMemory(); - + return ref configuration; } @@ -66,7 +66,7 @@ public static ref readonly DebugConfiguration WithStdin(in this DebugConfigurati public static ref readonly DebugConfiguration WithStdin(in this DebugConfiguration configuration, ReadOnlyMemory stdin) { Unsafe.AsRef(configuration.Stdin) = stdin; - + return ref configuration; } @@ -81,7 +81,7 @@ public static ref readonly DebugConfiguration WithStdin(in this DebugConfigurati public static ref readonly DebugConfiguration WithInitialState(in this DebugConfiguration configuration, IReadOnlyMachineState initialState) { Unsafe.AsRef(configuration.InitialState) = initialState; - + return ref configuration; } @@ -95,7 +95,7 @@ public static ref readonly DebugConfiguration WithInitialState(in this DebugConf public static ref readonly DebugConfiguration WithMemorySize(in this DebugConfiguration configuration, int memorySize) { Unsafe.AsRef(configuration.MemorySize) = memorySize; - + return ref configuration; } @@ -109,7 +109,7 @@ public static ref readonly DebugConfiguration WithMemorySize(in this DebugConfig public static ref readonly DebugConfiguration WithOverflowMode(in this DebugConfiguration configuration, OverflowMode overflowMode) { Unsafe.AsRef(configuration.OverflowMode) = overflowMode; - + return ref configuration; } @@ -123,7 +123,7 @@ public static ref readonly DebugConfiguration WithOverflowMode(in this DebugConf public static ref readonly DebugConfiguration WithExecutionToken(in this DebugConfiguration configuration, CancellationToken executionToken) { Unsafe.AsRef(configuration.ExecutionToken) = executionToken; - + return ref configuration; } } @@ -143,7 +143,7 @@ public static class ReleaseConfigurationExtensions public static ref readonly ReleaseConfiguration WithSource(in this ReleaseConfiguration configuration, string source) { Unsafe.AsRef(configuration.Source) = source.AsMemory(); - + return ref configuration; } @@ -157,7 +157,7 @@ public static ref readonly ReleaseConfiguration WithSource(in this ReleaseConfig public static ref readonly ReleaseConfiguration WithSource(in this ReleaseConfiguration configuration, ReadOnlyMemory source) { Unsafe.AsRef(configuration.Source) = source; - + return ref configuration; } @@ -171,7 +171,7 @@ public static ref readonly ReleaseConfiguration WithSource(in this ReleaseConfig public static ref readonly ReleaseConfiguration WithStdin(in this ReleaseConfiguration configuration, string stdin) { Unsafe.AsRef(configuration.Stdin) = stdin.AsMemory(); - + return ref configuration; } @@ -185,7 +185,7 @@ public static ref readonly ReleaseConfiguration WithStdin(in this ReleaseConfigu public static ref readonly ReleaseConfiguration WithStdin(in this ReleaseConfiguration configuration, ReadOnlyMemory stdin) { Unsafe.AsRef(configuration.Stdin) = stdin; - + return ref configuration; } @@ -200,7 +200,7 @@ public static ref readonly ReleaseConfiguration WithStdin(in this ReleaseConfigu public static ref readonly ReleaseConfiguration WithInitialState(in this ReleaseConfiguration configuration, IReadOnlyMachineState initialState) { Unsafe.AsRef(configuration.InitialState) = initialState; - + return ref configuration; } @@ -214,7 +214,7 @@ public static ref readonly ReleaseConfiguration WithInitialState(in this Release public static ref readonly ReleaseConfiguration WithMemorySize(in this ReleaseConfiguration configuration, int memorySize) { Unsafe.AsRef(configuration.MemorySize) = memorySize; - + return ref configuration; } @@ -228,7 +228,7 @@ public static ref readonly ReleaseConfiguration WithMemorySize(in this ReleaseCo public static ref readonly ReleaseConfiguration WithOverflowMode(in this ReleaseConfiguration configuration, OverflowMode overflowMode) { Unsafe.AsRef(configuration.OverflowMode) = overflowMode; - + return ref configuration; } @@ -242,7 +242,7 @@ public static ref readonly ReleaseConfiguration WithOverflowMode(in this Release public static ref readonly ReleaseConfiguration WithExecutionToken(in this ReleaseConfiguration configuration, CancellationToken executionToken) { Unsafe.AsRef(configuration.ExecutionToken) = executionToken; - + return ref configuration; } } diff --git a/src/Brainf_ckSharp/Enums/ExitCode.cs b/src/Brainf_ckSharp/Enums/ExitCode.cs index 3ff73a8b..1018b00f 100644 --- a/src/Brainf_ckSharp/Enums/ExitCode.cs +++ b/src/Brainf_ckSharp/Enums/ExitCode.cs @@ -21,7 +21,7 @@ public enum ExitCode : uint /// /// The source code produced a runtime exception /// - ExceptionThrown = (1 << 2)| Failure, + ExceptionThrown = (1 << 2) | Failure, /// /// The code run into an infinite loop (according to the desired time threshold) diff --git a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.cs b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.cs index 74162266..9c6cdb36 100644 --- a/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.cs +++ b/src/Brainf_ckSharp/Memory/Interfaces/IReadOnlyMachineState.cs @@ -7,7 +7,7 @@ namespace Brainf_ckSharp.Memory.Interfaces; /// /// An that represents a readonly machine state /// -public interface IReadOnlyMachineState : IEquatable, IReadOnlyList, ICloneable, IDisposable +public interface IReadOnlyMachineState : IEquatable, IReadOnlyList, ICloneable, IDisposable { /// /// Gets the current position on the memory buffer From 06e4c19bd3e7fc013c7cc33fede3d6a4404a5b01 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 16 Apr 2024 22:34:12 -0700 Subject: [PATCH 12/31] Fix IDE0110 (discard can be removed) --- src/Brainf_ckSharp.Git/LineDiffer.cs | 4 ++-- .../Controls/SubPages/Host/SubPageHost.xaml.cs | 2 +- .../CodeLibraryEntryItemContainerStyleSelector.cs | 4 ++-- .../TemplateSelectors/ConsoleEntryTemplateSelector.cs | 10 +++++----- .../SettingsSectionTemplateSelector.cs | 6 +++--- .../SourceCodeEntryTemplateSelector.cs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Brainf_ckSharp.Git/LineDiffer.cs b/src/Brainf_ckSharp.Git/LineDiffer.cs index 905477ec..d3e008a2 100644 --- a/src/Brainf_ckSharp.Git/LineDiffer.cs +++ b/src/Brainf_ckSharp.Git/LineDiffer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Runtime.CompilerServices; using Brainf_ckSharp.Git.Buffers; using Brainf_ckSharp.Git.Enums; @@ -214,7 +214,7 @@ public static MemoryOwner ComputeDiff(ReadOnlySpan o { Unsafe.Add(ref resultRef, i) = Unsafe.Add(ref newTemporaryValuesRef, i) switch { - int _ => LineModificationType.None, + int => LineModificationType.None, _ => LineModificationType.Modified }; } diff --git a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs index d2d06db9..8d8f21ed 100644 --- a/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs +++ b/src/Brainf_ckSharp.Uwp/Controls/SubPages/Host/SubPageHost.xaml.cs @@ -216,7 +216,7 @@ void UpdateLayout(double width, double height) } // Any content, that toggles between almost full screen and the compact state - case { } _: + case { }: { UpdateLayout( ExpandedStateMinimumWidth >= size.Width ? double.NaN : size.Width - 160, diff --git a/src/Brainf_ckSharp.Uwp/StyleSelectors/CodeLibraryEntryItemContainerStyleSelector.cs b/src/Brainf_ckSharp.Uwp/StyleSelectors/CodeLibraryEntryItemContainerStyleSelector.cs index ac0157d2..c7c0f044 100644 --- a/src/Brainf_ckSharp.Uwp/StyleSelectors/CodeLibraryEntryItemContainerStyleSelector.cs +++ b/src/Brainf_ckSharp.Uwp/StyleSelectors/CodeLibraryEntryItemContainerStyleSelector.cs @@ -28,8 +28,8 @@ public sealed class CodeLibraryEntryItemContainerStyleSelector : StyleSelector { return item switch { - CodeLibraryEntry _ => DefaultContainerStyle, - CodeLibrarySection _ => PlaceholderContainerStyle, + CodeLibraryEntry => DefaultContainerStyle, + CodeLibrarySection => PlaceholderContainerStyle, _ => ThrowHelper.ThrowArgumentNullException