From 481169b022a3cdb130ee69e6775a1e0a3ae5706e Mon Sep 17 00:00:00 2001 From: Cody Merritt Anhorn Date: Sun, 11 Jul 2021 12:12:15 -0500 Subject: [PATCH 1/2] fix: Fixed issues caused by cleaning up .NET objects. Keeping the JavaScript and .NET objects in sync causes more overhead and management that just trigging a delete during a .NET object finalize call. Because the .NET object can go out of scope, for some reason or another, it could cause the JavaScript reference to be lost, when the cache is cleared. To make this library as easy as possible to use without having to micro manage the state of all objects created/destroyed, it will just hold onto the cache for the life of the browser page request. The automatic cache remove was reverted, the 'removeEntity' interop is still available for custom code to be easily created. General Styles and Cleanup needed after adding .editorconfig. --- .editorconfig | 217 ++++++++++++++++++ ...ropResultClassCallbackValidationTest.razor | 2 +- EventHorizon.Blazor.Interop.sln | 1 + EventHorizon.Blazor.Interop/CachedEntity.cs | 11 +- .../CachedEntityConverter.cs | 12 +- .../CachedEntityRef.cs | 84 ------- .../Callbacks/ActionCallback.cs | 10 +- .../Callbacks/ActionCallbackArgs1.cs | 10 +- .../Callbacks/ActionCallbackArgs10.cs | 10 +- .../Callbacks/ActionCallbackArgs2.cs | 10 +- .../Callbacks/ActionCallbackArgs3.cs | 10 +- .../Callbacks/ActionCallbackArgs4.cs | 10 +- .../Callbacks/ActionCallbackArgs5.cs | 10 +- .../Callbacks/ActionCallbackArgs6.cs | 10 +- .../Callbacks/ActionCallbackArgs7.cs | 10 +- .../Callbacks/ActionCallbackArgs8.cs | 10 +- .../Callbacks/ActionCallbackArgs9.cs | 10 +- .../EventHorizonBlazorInterop.cs | 27 +-- EventHorizon.Blazor.Interop/ICachedEntity.cs | 2 +- .../ResultCallbacks/ActionResultCallback.cs | 11 +- .../ActionResultCallbackArgs1.cs | 8 +- .../ActionResultCallbackArgs10.cs | 9 +- .../ActionResultCallbackArgs2.cs | 9 +- .../ActionResultCallbackArgs3.cs | 9 +- .../ActionResultCallbackArgs4.cs | 9 +- .../ActionResultCallbackArgs5.cs | 9 +- .../ActionResultCallbackArgs6.cs | 9 +- .../ActionResultCallbackArgs7.cs | 9 +- .../ActionResultCallbackArgs8.cs | 9 +- .../ActionResultCallbackArgs9.cs | 9 +- 30 files changed, 354 insertions(+), 212 deletions(-) create mode 100644 .editorconfig delete mode 100644 EventHorizon.Blazor.Interop/CachedEntityRef.cs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f4c44bb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,217 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +# Enforce _ fields instances +dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion +dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields +dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style + +dotnet_naming_symbols.instance_fields.applicable_kinds = field + +dotnet_naming_style.instance_field_style.capitalization = camel_case +dotnet_naming_style.instance_field_style.required_prefix = _ + +#### Core EditorConfig Options #### + +# Indentation and spacing +indent_size = 4 +indent_style = space +tab_width = 4 + +# New line preferences +end_of_line = crlf +insert_final_newline = false + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = true +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# Expression-level preferences +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_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_prefer_compound_assignment = true:suggestion +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:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion + +# Field preferences +dotnet_style_readonly_field = true:suggestion + +# Parameter preferences +dotnet_code_quality_unused_parameters = all:suggestion + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent + +# Pattern matching preferences +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_local_function = true:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_pattern_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_unused_value_assignment_preference = discard_variable:suggestion +csharp_style_unused_value_expression_statement_preference = discard_variable:silent + +# 'using' directive preferences +csharp_using_directive_placement = inside_namespace: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 = true +csharp_indent_labels = one_less_than_current +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 styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +# IDE1006: Naming Styles +dotnet_diagnostic.IDE1006.severity = none + +# CS0108: Naming Styles +dotnet_diagnostic.CS0108.severity = suggestion \ No newline at end of file diff --git a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/ResultCallback/Validation/InteropResultClassCallbackValidationTest.razor b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/ResultCallback/Validation/InteropResultClassCallbackValidationTest.razor index 1b2844b..d50e817 100644 --- a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/ResultCallback/Validation/InteropResultClassCallbackValidationTest.razor +++ b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/ResultCallback/Validation/InteropResultClassCallbackValidationTest.razor @@ -34,7 +34,7 @@ private string testId => "InteropResultClassCallbackValidationTest"; private bool initialized = false; - private async Task HandleRunTest() + private void HandleRunTest() { TestStatus = "Running..."; if (!initialized) diff --git a/EventHorizon.Blazor.Interop.sln b/EventHorizon.Blazor.Interop.sln index 1f07f97..a39073b 100644 --- a/EventHorizon.Blazor.Interop.sln +++ b/EventHorizon.Blazor.Interop.sln @@ -9,6 +9,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventHorizon.Blazor.Interop EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BDF1BB12-22E3-4E8F-85E9-6DA870B48917}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig .gitignore = .gitignore GitVersion.yml = GitVersion.yml README.md = README.md diff --git a/EventHorizon.Blazor.Interop/CachedEntity.cs b/EventHorizon.Blazor.Interop/CachedEntity.cs index d75cbe0..b9a06f4 100644 --- a/EventHorizon.Blazor.Interop/CachedEntity.cs +++ b/EventHorizon.Blazor.Interop/CachedEntity.cs @@ -1,14 +1,15 @@ -using System.Text.Json.Serialization; - -namespace EventHorizon.Blazor.Interop +namespace EventHorizon.Blazor.Interop { + using System.Text.Json.Serialization; + /// /// A base class that is created as an easy way to interface with Client side implementation. /// [JsonConverter(typeof(CachedEntityConverter))] - public class CachedEntity : ICachedEntity + public class CachedEntity + : ICachedEntity { /// - public CachedEntityRef ___guid { get; set; } + public string ___guid { get; set; } } } diff --git a/EventHorizon.Blazor.Interop/CachedEntityConverter.cs b/EventHorizon.Blazor.Interop/CachedEntityConverter.cs index bab3283..4de0158 100644 --- a/EventHorizon.Blazor.Interop/CachedEntityConverter.cs +++ b/EventHorizon.Blazor.Interop/CachedEntityConverter.cs @@ -1,9 +1,9 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace EventHorizon.Blazor.Interop +namespace EventHorizon.Blazor.Interop { + using System; + using System.Text.Json; + using System.Text.Json.Serialization; + /// /// This helps with the payload of passing a CacheEntity between the C# and client. /// @@ -38,7 +38,7 @@ JsonSerializerOptions options switch (propertyName) { case "___guid": - entity.___guid = new CachedEntityRef(reader.GetString()); + entity.___guid = reader.GetString(); break; } } diff --git a/EventHorizon.Blazor.Interop/CachedEntityRef.cs b/EventHorizon.Blazor.Interop/CachedEntityRef.cs deleted file mode 100644 index d0169ab..0000000 --- a/EventHorizon.Blazor.Interop/CachedEntityRef.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace EventHorizon.Blazor.Interop -{ - /// - /// Represents a root reference to JS object. The JS object will live as long as this reference exists, - /// and once it is collected, the JS object will also be released for collection by the JS runtime. - /// - [JsonConverter(typeof(CachedEntityRefConverter))] - public sealed class CachedEntityRef : IEquatable - { - readonly string _guid; - - internal CachedEntityRef(string guid) - { - _guid = guid; - } - - /// - ~CachedEntityRef() - { - EventHorizonBlazorInterop.RemoveEntity(_guid); - } - - /// - public override string ToString() - { - return _guid; - } - - /// - public override int GetHashCode() - { - return (_guid != null ? _guid.GetHashCode() : 0); - } - - /// - public bool Equals(CachedEntityRef other) - { - return _guid == other?._guid; - } - - /// - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj.GetType() == GetType() && Equals((CachedEntityRef) obj); - } - - /// - /// Converts an instance of this object to string. - /// - /// A cached entity reference. - /// The internal UUID of the cached entity. - public static implicit operator string(CachedEntityRef obj) => obj.ToString(); - } - - - /// - /// This helps with the payload of passing a CacheEntity between the C# and client. - /// - /// - internal class CachedEntityRefConverter : JsonConverter - { - /// - public override bool CanConvert(Type typeToConvert) => - typeof(CachedEntityRef).IsAssignableFrom(typeToConvert); - - /// - public override CachedEntityRef Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return reader.Read() ? new CachedEntityRef(reader.GetString()) : null; - } - - /// - public override void Write(Utf8JsonWriter writer, CachedEntityRef value, JsonSerializerOptions options) - { - writer.WriteStringValue(value.ToString()); - } - } -} diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallback.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallback.cs index 363ecd2..b3c1a9b 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallback.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallback.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs1.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs1.cs index b7713a0..b404d7a 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs1.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs1.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs10.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs10.cs index 10d1299..29b8f89 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs10.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs10.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs2.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs2.cs index 80092d7..2865b58 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs2.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs2.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs3.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs3.cs index 57d334c..1395fb7 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs3.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs3.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs4.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs4.cs index bee55e4..0e34ece 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs4.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs4.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs5.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs5.cs index 63367e9..2a8a3a9 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs5.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs5.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs6.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs6.cs index 0ca1d10..dafe7cb 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs6.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs6.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs7.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs7.cs index 02565d6..0335753 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs7.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs7.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs8.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs8.cs index ba42ec9..36d6957 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs8.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs8.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs9.cs b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs9.cs index 1fa5457..8dbd5a1 100644 --- a/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs9.cs +++ b/EventHorizon.Blazor.Interop/Callbacks/ActionCallbackArgs9.cs @@ -1,9 +1,9 @@ -using System; -using System.Threading.Tasks; -using Microsoft.JSInterop; - -namespace EventHorizon.Blazor.Interop.Callbacks +namespace EventHorizon.Blazor.Interop.Callbacks { + using System; + using System.Threading.Tasks; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs b/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs index 3d24857..3d90258 100644 --- a/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs +++ b/EventHorizon.Blazor.Interop/EventHorizonBlazorInterop.cs @@ -1,7 +1,6 @@ namespace EventHorizon.Blazor.Interop { using System; - using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.JSInterop; using Microsoft.JSInterop.WebAssembly; @@ -118,7 +117,7 @@ params object[] args "blazorInterop.funcClass", args ); - return classBuilder(new CachedEntity { ___guid = new CachedEntityRef(cacheKey) }); + return classBuilder(new CachedEntity { ___guid = cacheKey }); } /// @@ -192,7 +191,7 @@ params object[] args var index = 0; foreach (var result in results) { - array[index] = classBuilder(new CachedEntity { ___guid = new CachedEntityRef(result) }); + array[index] = classBuilder(new CachedEntity { ___guid = result }); index++; } @@ -287,7 +286,7 @@ Func classBuilder ) ); - return classBuilder(new CachedEntity { ___guid = new CachedEntityRef(result) }); + return classBuilder(new CachedEntity { ___guid = result }); } /// @@ -331,7 +330,7 @@ Func classBuilder var index = 0; foreach (var result in results) { - array[index] = classBuilder(new CachedEntity { ___guid = new CachedEntityRef(result) }); + array[index] = classBuilder(new CachedEntity { ___guid = result }); index++; } @@ -409,10 +408,10 @@ public static ICachedEntity New( params object[] args ) { - var cacheRef = new CachedEntityRef(RUNTIME.Invoke( + var cacheRef = RUNTIME.Invoke( "blazorInterop.new", args - )); + ); return new CachedEntity { ___guid = cacheRef }; } @@ -536,12 +535,10 @@ public static ICachedEntity CacheEntity( string prop ) { - var cacheRef = new CachedEntityRef( - RUNTIME.Invoke( - "blazorInterop.cacheEntity", - identifier, - prop - ) + var cacheRef = RUNTIME.Invoke( + "blazorInterop.cacheEntity", + identifier, + prop ); return new CachedEntity { ___guid = cacheRef }; @@ -619,7 +616,7 @@ params object[] args "blazorInterop.taskClass", args ); - return classBuilder(new CachedEntity { ___guid = new CachedEntityRef(cacheKey) }); + return classBuilder(new CachedEntity { ___guid = cacheKey }); } /// @@ -697,7 +694,7 @@ params object[] args var index = 0; foreach (var result in results) { - array[index] = classBuilder(new CachedEntity { ___guid = new CachedEntityRef(result) }); + array[index] = classBuilder(new CachedEntity { ___guid = result }); index++; } diff --git a/EventHorizon.Blazor.Interop/ICachedEntity.cs b/EventHorizon.Blazor.Interop/ICachedEntity.cs index 3660762..0b9c8a0 100644 --- a/EventHorizon.Blazor.Interop/ICachedEntity.cs +++ b/EventHorizon.Blazor.Interop/ICachedEntity.cs @@ -8,6 +8,6 @@ public interface ICachedEntity /// /// The Client identifier for this specific entity. /// - CachedEntityRef ___guid { get; set; } + string ___guid { get; set; } } } diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallback.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallback.cs index a41cf7f..78c1445 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallback.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallback.cs @@ -1,12 +1,13 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// Includes Result when Called /// + /// public class ActionResultCallback { /// @@ -22,7 +23,7 @@ public class ActionResultCallback /// public string method => "HandleCallback"; - private Func _callback; + private readonly Func _callback; /// /// Create a new Action callback representation that will be triggered when the Client calls the method. diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs1.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs1.cs index 8a08b3c..609f5e2 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs1.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs1.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs10.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs10.cs index b780afa..66d39a7 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs10.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs10.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -16,6 +16,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs2.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs2.cs index cb5acad..3bad4e7 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs2.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs2.cs @@ -1,13 +1,14 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs3.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs3.cs index cd0fe3a..a466441 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs3.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs3.cs @@ -1,14 +1,15 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs4.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs4.cs index c1c3ff0..e76d3b0 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs4.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs4.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -10,6 +10,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs5.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs5.cs index 32979d4..7cc54af 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs5.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs5.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -11,6 +11,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs6.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs6.cs index 79d0439..6cf4f40 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs6.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs6.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -12,6 +12,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs7.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs7.cs index 40bc389..469e7de 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs7.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs7.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -13,6 +13,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs8.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs8.cs index 6e797ba..5f48fa5 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs8.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs8.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -14,6 +14,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// diff --git a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs9.cs b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs9.cs index fa8723d..f7ef8db 100644 --- a/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs9.cs +++ b/EventHorizon.Blazor.Interop/ResultCallbacks/ActionResultCallbackArgs9.cs @@ -1,8 +1,8 @@ -using Microsoft.JSInterop; -using System; - -namespace EventHorizon.Blazor.Interop.ResultCallbacks +namespace EventHorizon.Blazor.Interop.ResultCallbacks { + using System; + using Microsoft.JSInterop; + /// /// A platform provided abstraction to help with creation of a action that will trigger when called from the Client side. /// @@ -15,6 +15,7 @@ namespace EventHorizon.Blazor.Interop.ResultCallbacks /// /// /// + /// public class ActionResultCallback { /// From 621e609f65a83026a1ed69e5d0f738d7c4d760ed Mon Sep 17 00:00:00 2001 From: Cody Merritt Anhorn Date: Sun, 11 Jul 2021 12:18:33 -0500 Subject: [PATCH 2/2] Removed not needed testing. --- .../Scenarios/InteropFinalizationTest.razor | 86 ------------------- .../Scenarios/InteropScenariosPage.razor | 1 - 2 files changed, 87 deletions(-) delete mode 100644 EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropFinalizationTest.razor diff --git a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropFinalizationTest.razor b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropFinalizationTest.razor deleted file mode 100644 index 98e1f40..0000000 --- a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropFinalizationTest.razor +++ /dev/null @@ -1,86 +0,0 @@ -
-

Finalization Validation

-
-
- Status: - @if (TestStatus == "Passed") - { - @TestStatus - } - else if (TestStatus == "Failed") - { - @TestStatus - } - else - { - @TestStatus - } -
- -
- - -@code { - public string TestStatus = "Pending"; - - private int result; - - private async Task HandleRunTest() - { - result = 0; - - await RunTest(); - ValidateTest(); - } - - public async Task RunTest() - { - var list = CreateEntities(); - - GC.Collect(); - - // GC won't collect until we release the thread, so we offload - // the rest of it to be completed async. - await Task.Delay(10); - - foreach (var guid in list) - { - var value = EventHorizonBlazorInterop.Get(guid, "X"); - if (value is not null) - result++; - } - } - - static List CreateEntities() - { - var list = new List(); - - for (var i = 0; i < 100; i++) - { - var entity = EventHorizonBlazorInterop.FuncClass( - e => new Vector3CachedEntity(e), - new object[] - { - new[] { "funcClass", "func" }, - } - ); - - list.Add(entity.___guid); - } - - return list; - } - - public void ValidateTest() - { - if (result == 0) - { - TestStatus = "Passed"; - } - else - { - TestStatus = "Failed"; - } - } - -} diff --git a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropScenariosPage.razor b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropScenariosPage.razor index fef91dd..40d141d 100644 --- a/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropScenariosPage.razor +++ b/EventHorizon.Blazor.Interop.Sample/Pages/Testing/InteropTesting/Scenarios/InteropScenariosPage.razor @@ -4,5 +4,4 @@
-