From e84cc47941ad6e5043d8aed3140b94dc8ce44248 Mon Sep 17 00:00:00 2001 From: Samu Lang Date: Fri, 20 Dec 2024 12:09:48 +0100 Subject: [PATCH] No `this` --- GraphEngine/.editorconfig | 281 ++++++++++++++++++ GraphEngine/BaseBind.cs | 4 +- GraphEngine/BinaryOperation.cs | 4 +- GraphEngine/Bind.cs | 6 +- GraphEngine/Binder.cs | 10 +- GraphEngine/Case.cs | 8 +- GraphEngine/Catch.cs | 20 +- GraphEngine/Collection.cs | 16 +- GraphEngine/Collection{T}.cs | 4 +- GraphEngine/ElementInit.cs | 8 +- GraphEngine/Expressions/ArrayAccess.cs | 8 +- GraphEngine/Expressions/ArrayIndex.cs | 16 +- GraphEngine/Expressions/BaseGoto.cs | 14 +- GraphEngine/Expressions/Binary.cs | 36 +-- GraphEngine/Expressions/Block.cs | 22 +- GraphEngine/Expressions/Call.cs | 42 +-- GraphEngine/Expressions/ClearDebugInfo.cs | 2 +- GraphEngine/Expressions/Condition.cs | 22 +- GraphEngine/Expressions/Constant.cs | 14 +- GraphEngine/Expressions/DebugInfo.cs | 22 +- GraphEngine/Expressions/Default.cs | 6 +- GraphEngine/Expressions/Dynamic.cs | 16 +- GraphEngine/Expressions/Field.cs | 6 +- GraphEngine/Expressions/IfThen.cs | 2 +- GraphEngine/Expressions/IfThenElse.cs | 2 +- GraphEngine/Expressions/Invoke.cs | 8 +- GraphEngine/Expressions/Label.cs | 10 +- GraphEngine/Expressions/Lambda.cs | 12 +- GraphEngine/Expressions/ListInit.cs | 10 +- GraphEngine/Expressions/Loop.cs | 18 +- GraphEngine/Expressions/MemberAccess.cs | 12 +- GraphEngine/Expressions/MemberInit.cs | 10 +- GraphEngine/Expressions/New.cs | 12 +- GraphEngine/Expressions/NewArray.cs | 8 +- GraphEngine/Expressions/Parameter.cs | 12 +- GraphEngine/Expressions/Property.cs | 12 +- GraphEngine/Expressions/PropertyOrField.cs | 4 +- GraphEngine/Expressions/ReferenceEqual.cs | 2 +- GraphEngine/Expressions/ReferenceNotEqual.cs | 2 +- GraphEngine/Expressions/RuntimeVariables.cs | 4 +- GraphEngine/Expressions/Switch.cs | 20 +- GraphEngine/Expressions/Throw.cs | 12 +- GraphEngine/Expressions/Try.cs | 28 +- GraphEngine/Expressions/TypeBinary.cs | 18 +- GraphEngine/Expressions/Unary.cs | 24 +- GraphEngine/GlobalSuppressions.cs | 5 + GraphEngine/Graph.cs | 6 +- GraphEngine/InvokeMember.cs | 4 +- GraphEngine/ListBind.cs | 6 +- GraphEngine/Member.cs | 10 +- GraphEngine/MemberBind.cs | 6 +- GraphEngine/Method.cs | 6 +- GraphEngine/Node.cs | 16 +- GraphEngine/NodeWithGraph.cs | 2 +- GraphEngine/SerialisingVisitor.cs | 286 +++++++++---------- GraphEngine/SymbolDocument.cs | 24 +- GraphEngine/Target.cs | 14 +- GraphEngine/Type.cs | 10 +- 58 files changed, 755 insertions(+), 469 deletions(-) create mode 100644 GraphEngine/.editorconfig create mode 100644 GraphEngine/GlobalSuppressions.cs diff --git a/GraphEngine/.editorconfig b/GraphEngine/.editorconfig new file mode 100644 index 0000000..ee83259 --- /dev/null +++ b/GraphEngine/.editorconfig @@ -0,0 +1,281 @@ +# Remove the line below if you want to inherit .editorconfig settings from higher directories +root = true + +# C# files +[*.cs] + +#### 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 Code Actions #### + +# Type members +dotnet_hide_advanced_members = false +dotnet_member_insertion_location = with_other_members_of_the_same_kind +dotnet_property_generation_behavior = prefer_throwing_properties + +# Symbol search +dotnet_search_reference_assemblies = true + +#### .NET Coding Conventions #### + +# Organize usings +dotnet_separate_import_directive_groups = false +dotnet_sort_system_directives_first = false +file_header_template = unset + +# this. and Me. preferences +dotnet_style_qualification_for_event = true +dotnet_style_qualification_for_field = true +dotnet_style_qualification_for_method = true +dotnet_style_qualification_for_property = true + +# Language keywords vs BCL types preferences +dotnet_style_predefined_type_for_locals_parameters_members = true +dotnet_style_predefined_type_for_member_access = true + +# Parentheses preferences +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary +dotnet_style_parentheses_in_other_operators = never_if_unnecessary +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary + +# Modifier preferences +dotnet_style_require_accessibility_modifiers = for_non_interface_members + +# Expression-level preferences +dotnet_prefer_system_hash_code = true +dotnet_style_coalesce_expression = true +dotnet_style_collection_initializer = true +dotnet_style_explicit_tuple_names = true +dotnet_style_namespace_match_folder = true +dotnet_style_null_propagation = true +dotnet_style_object_initializer = true +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_prefer_auto_properties = true +dotnet_style_prefer_collection_expression = when_types_loosely_match +dotnet_style_prefer_compound_assignment = true +dotnet_style_prefer_conditional_expression_over_assignment = true +dotnet_style_prefer_conditional_expression_over_return = true +dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed +dotnet_style_prefer_inferred_anonymous_type_member_names = true +dotnet_style_prefer_inferred_tuple_names = true +dotnet_style_prefer_is_null_check_over_reference_equality_method = true +dotnet_style_prefer_simplified_boolean_expressions = true +dotnet_style_prefer_simplified_interpolation = true + +# Field preferences +dotnet_style_readonly_field = true + +# Parameter preferences +dotnet_code_quality_unused_parameters = all + +# Suppression preferences +dotnet_remove_unnecessary_suppression_exclusions = none + +# New line preferences +dotnet_style_allow_multiple_blank_lines_experimental = false +dotnet_style_allow_statement_immediately_after_block_experimental = false + +#### C# Coding Conventions #### + +# var preferences +csharp_style_var_elsewhere = true:suggestion +csharp_style_var_for_built_in_types = true:suggestion +csharp_style_var_when_type_is_apparent = true:suggestion + +# Expression-bodied members +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_constructors = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = true:silent +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_operators = true: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_extended_property_pattern = true:suggestion +csharp_style_prefer_not_pattern = true:suggestion +csharp_style_prefer_pattern_matching = true:silent +csharp_style_prefer_switch_expression = true:suggestion + +# Null-checking preferences +csharp_style_conditional_delegate_call = true:suggestion + +# Modifier preferences +csharp_prefer_static_anonymous_function = true:suggestion +csharp_prefer_static_local_function = true:suggestion +csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion + +# Code-block preferences +csharp_prefer_braces = true:silent +csharp_prefer_simple_using_statement = true:suggestion +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_namespace_declarations = file_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_primary_constructors = true:suggestion +csharp_style_prefer_top_level_statements = true:silent + +# Expression-level preferences +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_deconstructed_variable_declaration = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_utf8_string_literals = 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 = outside_namespace:silent + +# New line preferences +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:silent +csharp_style_allow_embedded_statements_on_same_line_experimental = false:silent + +#### 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 + +[*.{cs,vb}] +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_qualification_for_field = false:suggestion +dotnet_style_qualification_for_property = false:suggestion +dotnet_style_qualification_for_method = false:suggestion +dotnet_style_qualification_for_event = false:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_namespace_match_folder = true:suggestion +dotnet_style_readonly_field = true:suggestion +dotnet_style_predefined_type_for_locals_parameters_members = true:silent +dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent +dotnet_style_allow_multiple_blank_lines_experimental = false:silent +dotnet_style_allow_statement_immediately_after_block_experimental = false:silent +dotnet_code_quality_unused_parameters = all:suggestion +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent \ No newline at end of file diff --git a/GraphEngine/BaseBind.cs b/GraphEngine/BaseBind.cs index 5a14d6d..42f3cbe 100644 --- a/GraphEngine/BaseBind.cs +++ b/GraphEngine/BaseBind.cs @@ -6,9 +6,9 @@ public abstract class BaseBind(NodeWithGraph node, INode type) : Node(node, type { public Member Member { - get => this.GetRequired(BindMember, Member.Parse); + get => GetRequired(BindMember, Member.Parse); - set => this.SetRequired(BindMember, value); + set => SetRequired(BindMember, value); } public abstract Linq.MemberBinding LinqMemberBinding { get; } diff --git a/GraphEngine/BinaryOperation.cs b/GraphEngine/BinaryOperation.cs index ba1d85a..7c9e1b8 100644 --- a/GraphEngine/BinaryOperation.cs +++ b/GraphEngine/BinaryOperation.cs @@ -10,7 +10,7 @@ public class BinaryOperation(NodeWithGraph node) : Binder(node, Vocabulary.Binar internal override CallSiteBinder SystemBinder => Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation( CSharpBinderFlags.None, - this.ExpressionType.LinqExpressionType, + ExpressionType.LinqExpressionType, null, - from a in this.Arguments select a.Info); + from a in Arguments select a.Info); } diff --git a/GraphEngine/Bind.cs b/GraphEngine/Bind.cs index f958fe1..8ccbeaf 100644 --- a/GraphEngine/Bind.cs +++ b/GraphEngine/Bind.cs @@ -6,10 +6,10 @@ public class Bind(NodeWithGraph node) : BaseBind(node, Vocabulary.Bind) { public Expression Expression { - get => this.GetRequired(BindExpression, Expression.Parse); + get => GetRequired(BindExpression, Expression.Parse); - set => this.SetRequired(BindExpression, value); + set => SetRequired(BindExpression, value); } - public override Linq.MemberBinding LinqMemberBinding => Linq.Expression.Bind(this.Member.ReflectionMember, this.Expression.LinqExpression); + public override Linq.MemberBinding LinqMemberBinding => Linq.Expression.Bind(Member.ReflectionMember, Expression.LinqExpression); } diff --git a/GraphEngine/Binder.cs b/GraphEngine/Binder.cs index 9f6ca85..f11f9a8 100644 --- a/GraphEngine/Binder.cs +++ b/GraphEngine/Binder.cs @@ -8,19 +8,19 @@ public abstract class Binder(NodeWithGraph node, INode type) : Node(node, type) { public string Name { - get => this.GetRequired(BinderName, AsString); + get => GetRequired(BinderName, AsString); - set => this.SetOptional(BinderName, value); + set => SetOptional(BinderName, value); } public ExpressionType? ExpressionType { - get => this.GetOptional(BinderExpressionType, ExpressionType.Parse); + get => GetOptional(BinderExpressionType, ExpressionType.Parse); - set => this.SetOptional(BinderExpressionType, value); + set => SetOptional(BinderExpressionType, value); } - public ICollection Arguments => this.Collection(BinderArguments, ArgumentInfo.Parse); + public ICollection Arguments => Collection(BinderArguments, ArgumentInfo.Parse); internal abstract CallSiteBinder SystemBinder { get; } diff --git a/GraphEngine/Case.cs b/GraphEngine/Case.cs index c8384de..06cfaf4 100644 --- a/GraphEngine/Case.cs +++ b/GraphEngine/Case.cs @@ -6,14 +6,14 @@ public class Case(NodeWithGraph node) : Node(node) { public Expression Body { - get => this.GetRequired(CaseBody, Expression.Parse); + get => GetRequired(CaseBody, Expression.Parse); - set => this.SetRequired(CaseBody, value); + set => SetRequired(CaseBody, value); } - public ICollection TestValues => this.Collection(CaseTestValues, Expression.Parse); + public ICollection TestValues => Collection(CaseTestValues, Expression.Parse); - public Linq.SwitchCase LinqSwitchCase => Linq.Expression.SwitchCase(this.Body.LinqExpression, this.TestValues.LinqExpressions()); + public Linq.SwitchCase LinqSwitchCase => Linq.Expression.SwitchCase(Body.LinqExpression, TestValues.LinqExpressions()); internal static Case Parse(NodeWithGraph node) => node switch { diff --git a/GraphEngine/Catch.cs b/GraphEngine/Catch.cs index c083d95..9e93e81 100644 --- a/GraphEngine/Catch.cs +++ b/GraphEngine/Catch.cs @@ -6,38 +6,38 @@ public class Catch(NodeWithGraph node) : Node(node) { public Type? Type { - get => this.GetOptional(CatchType, Type.Parse); + get => GetOptional(CatchType, Type.Parse); - set => this.SetOptional(CatchType, value); + set => SetOptional(CatchType, value); } public Expression Body { - get => this.GetRequired(CatchBody, Expression.Parse); + get => GetRequired(CatchBody, Expression.Parse); - set => this.SetRequired(CatchBody, value); + set => SetRequired(CatchBody, value); } public Parameter? Variable { - get => this.GetOptional(CatchVariable, Parameter.Parse); + get => GetOptional(CatchVariable, Parameter.Parse); - set => this.SetOptional(CatchVariable, value); + set => SetOptional(CatchVariable, value); } public Expression? Filter { - get => this.GetOptional(CatchFilter, Expression.Parse); + get => GetOptional(CatchFilter, Expression.Parse); - set => this.SetOptional(CatchFilter, value); + set => SetOptional(CatchFilter, value); } public Linq.CatchBlock LinqCatchBlock { get { - var variable = this.Variable?.LinqParameter; - return Linq.Expression.MakeCatchBlock(this.Type?.SystemType ?? variable?.Type, variable, this.Body.LinqExpression, this.Filter?.LinqExpression); + var variable = Variable?.LinqParameter; + return Linq.Expression.MakeCatchBlock(Type?.SystemType ?? variable?.Type, variable, Body.LinqExpression, Filter?.LinqExpression); } } diff --git a/GraphEngine/Collection.cs b/GraphEngine/Collection.cs index 8bbfbb1..5665e16 100644 --- a/GraphEngine/Collection.cs +++ b/GraphEngine/Collection.cs @@ -6,19 +6,19 @@ namespace GraphEngine; public class Collection(NodeWithGraph subject, INode predicate) : ICollection { - public int Count => !this.IsValid(out var listRoot) + public int Count => !IsValid(out var listRoot) ? 0 : subject.Graph.GetListItems(listRoot).Count(); public bool IsReadOnly => false; - protected IEnumerable X => !this.IsValid(out var listRoot) + protected IEnumerable X => !IsValid(out var listRoot) ? [] : subject.Graph.GetListItems(listRoot).Select(n => n.In(subject.Graph)); public void Add(NodeWithGraph item) { - if (!this.IsValid(out var listRoot)) + if (!IsValid(out var listRoot)) { subject.Graph.Assert(subject, predicate, subject.Graph.AssertList(item.AsEnumerable())); return; @@ -29,7 +29,7 @@ public void Add(NodeWithGraph item) public void Clear() { - if (!this.IsValid(out var listRoot)) + if (!IsValid(out var listRoot)) { return; } @@ -38,11 +38,11 @@ public void Clear() subject.Graph.Retract(subject, predicate, listRoot); } - public bool Contains(NodeWithGraph item) => this.IsValid(out var listRoot) && subject.Graph.GetListItems(listRoot).Contains(item); + public bool Contains(NodeWithGraph item) => IsValid(out var listRoot) && subject.Graph.GetListItems(listRoot).Contains(item); public void CopyTo(NodeWithGraph[] array, int arrayIndex) { - if (!this.IsValid(out var listRoot)) + if (!IsValid(out var listRoot)) { return; } @@ -50,14 +50,14 @@ public void CopyTo(NodeWithGraph[] array, int arrayIndex) subject.Graph.GetListItems(listRoot).ToList().CopyTo(array, arrayIndex); } - IEnumerator IEnumerable.GetEnumerator() => this.X.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => X.GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this).GetEnumerator(); public bool Remove(NodeWithGraph item) { - if (!this.IsValid(out var listRoot)) + if (!IsValid(out var listRoot)) { return false; } diff --git a/GraphEngine/Collection{T}.cs b/GraphEngine/Collection{T}.cs index 4115a9f..f508043 100644 --- a/GraphEngine/Collection{T}.cs +++ b/GraphEngine/Collection{T}.cs @@ -11,9 +11,9 @@ public class Collection(NodeWithGraph subject, INode predicate, Func base.Contains(item); - public void CopyTo(T[] array, int arrayIndex) => this.X.ToList().CopyTo(array, arrayIndex); + public void CopyTo(T[] array, int arrayIndex) => X.ToList().CopyTo(array, arrayIndex); - public IEnumerator GetEnumerator() => this.X.Select(parser).GetEnumerator(); + public IEnumerator GetEnumerator() => X.Select(parser).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)this).GetEnumerator(); diff --git a/GraphEngine/ElementInit.cs b/GraphEngine/ElementInit.cs index 6b7370d..e3740a1 100644 --- a/GraphEngine/ElementInit.cs +++ b/GraphEngine/ElementInit.cs @@ -6,14 +6,14 @@ public class ElementInit(NodeWithGraph node) : Node(node) { public Method AddMethod { - get => this.GetRequired(ElementInitAddMethod, Method.Parse); + get => GetRequired(ElementInitAddMethod, Method.Parse); - set => this.SetRequired(ElementInitAddMethod, value); + set => SetRequired(ElementInitAddMethod, value); } - public ICollection Arguments => this.Collection(ElementInitArguments, Expression.Parse); + public ICollection Arguments => Collection(ElementInitArguments, Expression.Parse); - public Linq.ElementInit LinqElementInit => Linq.Expression.ElementInit(this.AddMethod.ReflectionMethod, this.Arguments.LinqExpressions()); + public Linq.ElementInit LinqElementInit => Linq.Expression.ElementInit(AddMethod.ReflectionMethod, Arguments.LinqExpressions()); internal static ElementInit Parse(NodeWithGraph node) => node switch { diff --git a/GraphEngine/Expressions/ArrayAccess.cs b/GraphEngine/Expressions/ArrayAccess.cs index e227863..957de10 100644 --- a/GraphEngine/Expressions/ArrayAccess.cs +++ b/GraphEngine/Expressions/ArrayAccess.cs @@ -6,12 +6,12 @@ public class ArrayAccess(NodeWithGraph node) : Expression(node) { public Expression Array { - get => this.GetRequired(ArrayAccessArray, Expression.Parse); + get => GetRequired(ArrayAccessArray, Expression.Parse); - set => this.SetRequired(ArrayAccessArray, value); + set => SetRequired(ArrayAccessArray, value); } - public ICollection Indexes => this.Collection(ArrayAccessIndexes, Expression.Parse); + public ICollection Indexes => Collection(ArrayAccessIndexes, Expression.Parse); - public override Linq.Expression LinqExpression => Linq.Expression.ArrayAccess(this.Array.LinqExpression, this.Indexes.LinqExpressions()); + public override Linq.Expression LinqExpression => Linq.Expression.ArrayAccess(Array.LinqExpression, Indexes.LinqExpressions()); } diff --git a/GraphEngine/Expressions/ArrayIndex.cs b/GraphEngine/Expressions/ArrayIndex.cs index 81640c3..4f54a76 100644 --- a/GraphEngine/Expressions/ArrayIndex.cs +++ b/GraphEngine/Expressions/ArrayIndex.cs @@ -6,23 +6,23 @@ public class ArrayIndex(NodeWithGraph node) : Expression(node) { public Expression Array { - get => this.GetRequired(ArrayIndexArray, Expression.Parse); + get => GetRequired(ArrayIndexArray, Expression.Parse); - set => this.SetRequired(ArrayIndexArray, value); + set => SetRequired(ArrayIndexArray, value); } public Expression? Index { - get => this.GetOptional(ArrayIndexIndex, Expression.Parse); + get => GetOptional(ArrayIndexIndex, Expression.Parse); - set => this.SetOptional(ArrayIndexIndex, value); + set => SetOptional(ArrayIndexIndex, value); } - public ICollection Indexes => this.Collection(ArrayIndexIndexes, Expression.Parse); + public ICollection Indexes => Collection(ArrayIndexIndexes, Expression.Parse); - public override Linq.Expression LinqExpression => this.Index switch + public override Linq.Expression LinqExpression => Index switch { - not null => Linq.Expression.ArrayIndex(this.Array.LinqExpression, this.Index.LinqExpression), - _ => Linq.Expression.ArrayIndex(this.Array.LinqExpression, this.Indexes.LinqExpressions()) + not null => Linq.Expression.ArrayIndex(Array.LinqExpression, Index.LinqExpression), + _ => Linq.Expression.ArrayIndex(Array.LinqExpression, Indexes.LinqExpressions()) }; } diff --git a/GraphEngine/Expressions/BaseGoto.cs b/GraphEngine/Expressions/BaseGoto.cs index e026f23..7760ac9 100644 --- a/GraphEngine/Expressions/BaseGoto.cs +++ b/GraphEngine/Expressions/BaseGoto.cs @@ -6,26 +6,26 @@ public abstract class BaseGoto(NodeWithGraph node, INode type) : Expression(node { public Target Target { - get => this.GetRequired(GotoTarget, Target.Parse); + get => GetRequired(GotoTarget, Target.Parse); - set => this.SetRequired(GotoTarget, value); + set => SetRequired(GotoTarget, value); } public Type? Type { - get => this.GetOptional(GotoType, Type.Parse); + get => GetOptional(GotoType, Type.Parse); - set => this.SetOptional(GotoType, value); + set => SetOptional(GotoType, value); } public Expression? Value { - get => this.GetOptional(GotoValue, Expression.Parse); + get => GetOptional(GotoValue, Expression.Parse); - set => this.SetOptional(GotoValue, value); + set => SetOptional(GotoValue, value); } - public override Linq.Expression LinqExpression => Linq.Expression.MakeGoto(this.Kind, this.Target.LinqTarget, this.Value?.LinqExpression, this.Type?.SystemType ?? typeof(void)); + public override Linq.Expression LinqExpression => Linq.Expression.MakeGoto(Kind, Target.LinqTarget, Value?.LinqExpression, Type?.SystemType ?? typeof(void)); protected abstract Linq.GotoExpressionKind Kind { get; } diff --git a/GraphEngine/Expressions/Binary.cs b/GraphEngine/Expressions/Binary.cs index 80c188a..5c193b5 100644 --- a/GraphEngine/Expressions/Binary.cs +++ b/GraphEngine/Expressions/Binary.cs @@ -6,54 +6,54 @@ public class Binary(NodeWithGraph node, INode? type = default) : Expression(node { public Expression Left { - get => this.GetRequired(BinaryLeft, Expression.Parse); + get => GetRequired(BinaryLeft, Expression.Parse); - set => this.SetRequired(BinaryLeft, value); + set => SetRequired(BinaryLeft, value); } public Expression Right { - get => this.GetRequired(BinaryRight, Expression.Parse); + get => GetRequired(BinaryRight, Expression.Parse); - set => this.SetRequired(BinaryRight, value); + set => SetRequired(BinaryRight, value); } public ExpressionType ExpressionType { - get => this.GetRequired(BinaryExpressionType, ExpressionType.Parse); + get => GetRequired(BinaryExpressionType, ExpressionType.Parse); - set => this.SetRequired(BinaryExpressionType, value); + set => SetRequired(BinaryExpressionType, value); } public Method? Method { - get => this.GetOptional(BinaryMethod, Method.Parse); + get => GetOptional(BinaryMethod, Method.Parse); - set => this.SetOptional(BinaryMethod, value); + set => SetOptional(BinaryMethod, value); } public bool? LiftToNull { - get => this.GetOptionalS(BinaryLiftToNull, AsBool); + get => GetOptionalS(BinaryLiftToNull, AsBool); - set => this.SetOptional(BinaryLiftToNull, value); + set => SetOptional(BinaryLiftToNull, value); } public Lambda? Conversion { - get => this.GetOptional(BinaryConversion, Lambda.Parse); + get => GetOptional(BinaryConversion, Lambda.Parse); - set => this.SetOptional(BinaryConversion, value); + set => SetOptional(BinaryConversion, value); } public override Linq.Expression LinqExpression => Linq.Expression.MakeBinary( - this.ExpressionType.LinqExpressionType, - this.Left.LinqExpression, - this.Right.LinqExpression, - this.LiftToNull ?? false, - this.Method?.ReflectionMethod, - this.Conversion?.LinqLambda); + ExpressionType.LinqExpressionType, + Left.LinqExpression, + Right.LinqExpression, + LiftToNull ?? false, + Method?.ReflectionMethod, + Conversion?.LinqLambda); public static Binary Create(NodeWithGraph node, Linq.ExpressionType type) => (node, type) switch { diff --git a/GraphEngine/Expressions/Block.cs b/GraphEngine/Expressions/Block.cs index d59ba2d..993f0eb 100644 --- a/GraphEngine/Expressions/Block.cs +++ b/GraphEngine/Expressions/Block.cs @@ -6,27 +6,27 @@ public class Block(NodeWithGraph node) : Expression(node) { public Type? Type { - get => this.GetOptional(BlockType, Type.Parse); + get => GetOptional(BlockType, Type.Parse); - set => this.SetOptional(BlockType, value); + set => SetOptional(BlockType, value); } - public ICollection Expressions => this.Collection(BlockExpressions, Expression.Parse); + public ICollection Expressions => Collection(BlockExpressions, Expression.Parse); - public ICollection Variables => this.Collection(BlockVariables, Parameter.Parse); + public ICollection Variables => Collection(BlockVariables, Parameter.Parse); - public override Linq.Expression LinqExpression => (type: this.Type, empty: !this.Variables.Any()) switch + public override Linq.Expression LinqExpression => (type: Type, empty: !Variables.Any()) switch { (type: not null, _) => Linq.Expression.Block( - this.Type.SystemType, - from e in this.Variables select e.LinqParameter, - this.Expressions.LinqExpressions()), + Type.SystemType, + from e in Variables select e.LinqParameter, + Expressions.LinqExpressions()), (_, empty: true) => Linq.Expression.Block( - this.Expressions.LinqExpressions().ToArray()), + Expressions.LinqExpressions().ToArray()), _ => Linq.Expression.Block( - from e in this.Variables select e.LinqParameter, - this.Expressions.LinqExpressions()), + from e in Variables select e.LinqParameter, + Expressions.LinqExpressions()), }; } diff --git a/GraphEngine/Expressions/Call.cs b/GraphEngine/Expressions/Call.cs index 6caf291..70825a2 100644 --- a/GraphEngine/Expressions/Call.cs +++ b/GraphEngine/Expressions/Call.cs @@ -6,53 +6,53 @@ public class Call(NodeWithGraph node) : Expression(node) { public Expression? Instance { - get => this.GetOptional(CallInstance, Expression.Parse); + get => GetOptional(CallInstance, Expression.Parse); - set => this.SetOptional(CallInstance, value); + set => SetOptional(CallInstance, value); } public Type? Type { - get => this.GetOptional(CallType, Type.Parse); + get => GetOptional(CallType, Type.Parse); - set => this.SetOptional(CallType, value); + set => SetOptional(CallType, value); } public Method? Method { - get => this.GetOptional(CallMethod, Method.Parse); + get => GetOptional(CallMethod, Method.Parse); - set => this.SetOptional(CallMethod, value); + set => SetOptional(CallMethod, value); } public string? MethodName { - get => this.GetOptional(CallMethodName, AsString); + get => GetOptional(CallMethodName, AsString); - set => this.SetOptional(CallMethodName, value); + set => SetOptional(CallMethodName, value); } - public ICollection Arguments => this.Collection(CallArguments, Expression.Parse); + public ICollection Arguments => Collection(CallArguments, Expression.Parse); - public ICollection TypeArguments => this.Collection(CallTypeArguments, Type.Parse); + public ICollection TypeArguments => Collection(CallTypeArguments, Type.Parse); public override Linq.Expression LinqExpression => this switch { Call { Method.ReflectionMethod: not null } => Linq.Expression.Call( - this.Instance?.LinqExpression, - this.Method.ReflectionMethod, - this.Arguments.LinqExpressions()), + Instance?.LinqExpression, + Method.ReflectionMethod, + Arguments.LinqExpressions()), Call { Type: not null } => Linq.Expression.Call( - this.Type.SystemType, - this.MethodName, - (from typeArg in this.TypeArguments select typeArg.SystemType).ToArray(), - this.Arguments.LinqExpressions().ToArray()), + Type.SystemType, + MethodName, + (from typeArg in TypeArguments select typeArg.SystemType).ToArray(), + Arguments.LinqExpressions().ToArray()), _ => Linq.Expression.Call( - this.Instance.LinqExpression, - this.MethodName, - (from typeArg in this.TypeArguments select typeArg.SystemType).ToArray(), - this.Arguments.LinqExpressions().ToArray()) + Instance.LinqExpression, + MethodName, + (from typeArg in TypeArguments select typeArg.SystemType).ToArray(), + Arguments.LinqExpressions().ToArray()) }; } diff --git a/GraphEngine/Expressions/ClearDebugInfo.cs b/GraphEngine/Expressions/ClearDebugInfo.cs index 2e00cbd..b4fef22 100644 --- a/GraphEngine/Expressions/ClearDebugInfo.cs +++ b/GraphEngine/Expressions/ClearDebugInfo.cs @@ -4,5 +4,5 @@ namespace GraphEngine; public class ClearDebugInfo(NodeWithGraph node) : DebugInfo(node, Vocabulary.ClearDebugInfo) { - public override Linq.Expression LinqExpression => Linq.Expression.ClearDebugInfo(this.Document.LinqDocument); + public override Linq.Expression LinqExpression => Linq.Expression.ClearDebugInfo(Document.LinqDocument); } diff --git a/GraphEngine/Expressions/Condition.cs b/GraphEngine/Expressions/Condition.cs index 5d6b39b..acce416 100644 --- a/GraphEngine/Expressions/Condition.cs +++ b/GraphEngine/Expressions/Condition.cs @@ -6,35 +6,35 @@ public class Condition(NodeWithGraph node, INode? type = default) : Expression(n { public Expression Test { - get => this.GetRequired(ConditionTest, Expression.Parse); + get => GetRequired(ConditionTest, Expression.Parse); - set => this.SetRequired(ConditionTest, value); + set => SetRequired(ConditionTest, value); } public Expression IfTrue { - get => this.GetRequired(ConditionIfTrue, Expression.Parse); + get => GetRequired(ConditionIfTrue, Expression.Parse); - set => this.SetRequired(ConditionIfTrue, value); + set => SetRequired(ConditionIfTrue, value); } public Expression IfFalse { - get => this.GetRequired(ConditionIfFalse, Expression.Parse); + get => GetRequired(ConditionIfFalse, Expression.Parse); - set => this.SetRequired(ConditionIfFalse, value); + set => SetRequired(ConditionIfFalse, value); } public Type? Type { - get => this.GetOptional(ConditionType, Type.Parse); + get => GetOptional(ConditionType, Type.Parse); - set => this.SetOptional(ConditionType, value); + set => SetOptional(ConditionType, value); } - public override Linq.Expression LinqExpression => this.Type switch + public override Linq.Expression LinqExpression => Type switch { - Type type => Linq.Expression.Condition(this.Test.LinqExpression, this.IfTrue.LinqExpression, this.IfFalse.LinqExpression, type.SystemType), - _ => Linq.Expression.Condition(this.Test.LinqExpression, this.IfTrue.LinqExpression, this.IfFalse.LinqExpression) + Type type => Linq.Expression.Condition(Test.LinqExpression, IfTrue.LinqExpression, IfFalse.LinqExpression, type.SystemType), + _ => Linq.Expression.Condition(Test.LinqExpression, IfTrue.LinqExpression, IfFalse.LinqExpression) }; } diff --git a/GraphEngine/Expressions/Constant.cs b/GraphEngine/Expressions/Constant.cs index 50d15da..3b1df5e 100644 --- a/GraphEngine/Expressions/Constant.cs +++ b/GraphEngine/Expressions/Constant.cs @@ -6,21 +6,21 @@ public class Constant(NodeWithGraph node) : Expression(node) { public object? Value { - get => this.GetOptional(ConstantValue, AsObject); + get => GetOptional(ConstantValue, AsObject); - set => this.SetOptional(ConstantValue, value); + set => SetOptional(ConstantValue, value); } public Type? Type { - get => this.GetOptional(ConstantType, Type.Parse); + get => GetOptional(ConstantType, Type.Parse); - set => this.SetOptional(ConstantType, value); + set => SetOptional(ConstantType, value); } - public override Linq.Expression LinqExpression => this.Type switch + public override Linq.Expression LinqExpression => Type switch { - Type type => Linq.Expression.Constant(this.Value, type.SystemType), - _ => Linq.Expression.Constant(this.Value) + Type type => Linq.Expression.Constant(Value, type.SystemType), + _ => Linq.Expression.Constant(Value) }; } diff --git a/GraphEngine/Expressions/DebugInfo.cs b/GraphEngine/Expressions/DebugInfo.cs index 3e7b623..8d72d80 100644 --- a/GraphEngine/Expressions/DebugInfo.cs +++ b/GraphEngine/Expressions/DebugInfo.cs @@ -6,38 +6,38 @@ public class DebugInfo(NodeWithGraph node, INode? type = default) : Expression(n { public SymbolDocument Document { - get => this.GetRequired(DebugInfoDocument, n => new SymbolDocument(n)); + get => GetRequired(DebugInfoDocument, n => new SymbolDocument(n)); - set => this.SetRequired(DebugInfoDocument, value); + set => SetRequired(DebugInfoDocument, value); } public int StartLine { - get => this.GetRequiredS(DebugInfoStartLine, AsInt); + get => GetRequiredS(DebugInfoStartLine, AsInt); - set => this.SetRequired(DebugInfoStartLine, value); + set => SetRequired(DebugInfoStartLine, value); } public int StartColumn { - get => this.GetRequiredS(DebugInfoStartColumn, AsInt); + get => GetRequiredS(DebugInfoStartColumn, AsInt); - set => this.SetRequired(DebugInfoStartColumn, value); + set => SetRequired(DebugInfoStartColumn, value); } public int EndLine { - get => this.GetRequiredS(DebugInfoEndLine, AsInt); + get => GetRequiredS(DebugInfoEndLine, AsInt); - set => this.SetRequired(DebugInfoEndLine, value); + set => SetRequired(DebugInfoEndLine, value); } public int EndColumn { - get => this.GetRequiredS(DebugInfoEndColumn, AsInt); + get => GetRequiredS(DebugInfoEndColumn, AsInt); - set => this.SetRequired(DebugInfoEndColumn, value); + set => SetRequired(DebugInfoEndColumn, value); } - public override Linq.Expression LinqExpression => Linq.Expression.DebugInfo(this.Document.LinqDocument, this.StartLine, this.StartColumn, this.EndLine, this.EndColumn); + public override Linq.Expression LinqExpression => Linq.Expression.DebugInfo(Document.LinqDocument, StartLine, StartColumn, EndLine, EndColumn); } diff --git a/GraphEngine/Expressions/Default.cs b/GraphEngine/Expressions/Default.cs index cf3ea0d..bf27847 100644 --- a/GraphEngine/Expressions/Default.cs +++ b/GraphEngine/Expressions/Default.cs @@ -6,10 +6,10 @@ public class Default(NodeWithGraph node) : Expression(node) { public Type Type { - get => this.GetRequired(DefaultType, Type.Parse); + get => GetRequired(DefaultType, Type.Parse); - set => this.SetRequired(DefaultType, value); + set => SetRequired(DefaultType, value); } - public override Linq.Expression LinqExpression => Linq.Expression.Default(this.Type.SystemType); + public override Linq.Expression LinqExpression => Linq.Expression.Default(Type.SystemType); } diff --git a/GraphEngine/Expressions/Dynamic.cs b/GraphEngine/Expressions/Dynamic.cs index 01469e8..ae9fbda 100644 --- a/GraphEngine/Expressions/Dynamic.cs +++ b/GraphEngine/Expressions/Dynamic.cs @@ -6,23 +6,23 @@ public class Dynamic(NodeWithGraph node) : Expression(node) { public Binder Binder { - get => this.GetRequired(DynamicBinder, Binder.Parse); + get => GetRequired(DynamicBinder, Binder.Parse); - set => this.SetRequired(DynamicBinder, value); + set => SetRequired(DynamicBinder, value); } public Type ReturnType { - get => this.GetRequired(DynamicReturnType, Type.Parse); + get => GetRequired(DynamicReturnType, Type.Parse); - set => this.SetRequired(DynamicReturnType, value); + set => SetRequired(DynamicReturnType, value); } - public ICollection Arguments => this.Collection(DynamicArguments, Expression.Parse); + public ICollection Arguments => Collection(DynamicArguments, Expression.Parse); public override Linq.Expression LinqExpression => Linq.Expression.Dynamic( - this.Binder.SystemBinder, - this.ReturnType.SystemType, - this.Arguments.LinqExpressions()); + Binder.SystemBinder, + ReturnType.SystemType, + Arguments.LinqExpressions()); } diff --git a/GraphEngine/Expressions/Field.cs b/GraphEngine/Expressions/Field.cs index bcadb67..e317873 100644 --- a/GraphEngine/Expressions/Field.cs +++ b/GraphEngine/Expressions/Field.cs @@ -4,9 +4,9 @@ namespace GraphEngine; public class Field(NodeWithGraph node) : MemberAccess(node, Vocabulary.Field) { - public override Linq.Expression LinqExpression => this.Type switch + public override Linq.Expression LinqExpression => Type switch { - Type type => Linq.Expression.Field(this.Expression?.LinqExpression, type.SystemType, this.Name), - _ => Linq.Expression.Field(this.Expression?.LinqExpression, this.Name) + Type type => Linq.Expression.Field(Expression?.LinqExpression, type.SystemType, Name), + _ => Linq.Expression.Field(Expression?.LinqExpression, Name) }; } diff --git a/GraphEngine/Expressions/IfThen.cs b/GraphEngine/Expressions/IfThen.cs index 81c4722..0dccf6f 100644 --- a/GraphEngine/Expressions/IfThen.cs +++ b/GraphEngine/Expressions/IfThen.cs @@ -4,5 +4,5 @@ namespace GraphEngine; public class IfThen(NodeWithGraph node) : Condition(node, Vocabulary.IfThen) { - public override Linq.Expression LinqExpression => Linq.Expression.IfThen(this.Test.LinqExpression, this.IfTrue.LinqExpression); + public override Linq.Expression LinqExpression => Linq.Expression.IfThen(Test.LinqExpression, IfTrue.LinqExpression); } diff --git a/GraphEngine/Expressions/IfThenElse.cs b/GraphEngine/Expressions/IfThenElse.cs index 5db6806..8629dee 100644 --- a/GraphEngine/Expressions/IfThenElse.cs +++ b/GraphEngine/Expressions/IfThenElse.cs @@ -4,5 +4,5 @@ namespace GraphEngine; public class IfThenElse(NodeWithGraph node) : Condition(node, Vocabulary.IfThenElse) { - public override Linq.Expression LinqExpression => Linq.Expression.IfThenElse(this.Test.LinqExpression, this.IfTrue.LinqExpression, this.IfFalse.LinqExpression); + public override Linq.Expression LinqExpression => Linq.Expression.IfThenElse(Test.LinqExpression, IfTrue.LinqExpression, IfFalse.LinqExpression); } diff --git a/GraphEngine/Expressions/Invoke.cs b/GraphEngine/Expressions/Invoke.cs index efaffdf..71ce814 100644 --- a/GraphEngine/Expressions/Invoke.cs +++ b/GraphEngine/Expressions/Invoke.cs @@ -6,12 +6,12 @@ public class Invoke(NodeWithGraph node) : Expression(node) { public Expression Expression { - get => this.GetRequired(InvokeExpression, Expression.Parse); + get => GetRequired(InvokeExpression, Expression.Parse); - set => this.SetRequired(InvokeExpression, value); + set => SetRequired(InvokeExpression, value); } - public ICollection Arguments => this.Collection(InvokeArguments, Expression.Parse); + public ICollection Arguments => Collection(InvokeArguments, Expression.Parse); - public override Linq.Expression LinqExpression => Linq.Expression.Invoke(this.Expression.LinqExpression, this.Arguments.LinqExpressions()); + public override Linq.Expression LinqExpression => Linq.Expression.Invoke(Expression.LinqExpression, Arguments.LinqExpressions()); } diff --git a/GraphEngine/Expressions/Label.cs b/GraphEngine/Expressions/Label.cs index d31e41f..a7bcc2c 100644 --- a/GraphEngine/Expressions/Label.cs +++ b/GraphEngine/Expressions/Label.cs @@ -6,17 +6,17 @@ public class Label(NodeWithGraph node) : Expression(node) { public Target Target { - get => this.GetRequired(LabelTarget, Target.Parse); + get => GetRequired(LabelTarget, Target.Parse); - set => this.SetRequired(LabelTarget, value); + set => SetRequired(LabelTarget, value); } public Expression? DefaultValue { - get => this.GetOptional(LabelDefaultValue, Expression.Parse); + get => GetOptional(LabelDefaultValue, Expression.Parse); - set => this.SetOptional(LabelDefaultValue, value); + set => SetOptional(LabelDefaultValue, value); } - public override Linq.Expression LinqExpression => Linq.Expression.Label(this.Target.LinqTarget, this.DefaultValue?.LinqExpression); + public override Linq.Expression LinqExpression => Linq.Expression.Label(Target.LinqTarget, DefaultValue?.LinqExpression); } diff --git a/GraphEngine/Expressions/Lambda.cs b/GraphEngine/Expressions/Lambda.cs index 6818e38..eb2dc64 100644 --- a/GraphEngine/Expressions/Lambda.cs +++ b/GraphEngine/Expressions/Lambda.cs @@ -6,19 +6,19 @@ public class Lambda(NodeWithGraph node) : Expression(node) { public Expression Body { - get => this.GetRequired(LambdaBody, Expression.Parse); + get => GetRequired(LambdaBody, Expression.Parse); - set => this.SetRequired(LambdaBody, value); + set => SetRequired(LambdaBody, value); } - public ICollection Parameters => this.Collection(LambdaParameters, Parameter.Parse); + public ICollection Parameters => Collection(LambdaParameters, Parameter.Parse); - public override Linq.Expression LinqExpression => this.LinqLambda; + public override Linq.Expression LinqExpression => LinqLambda; public Linq.LambdaExpression LinqLambda => Linq.Expression.Lambda( - this.Body.LinqExpression, - from param in this.Parameters select param.LinqParameter); + Body.LinqExpression, + from param in Parameters select param.LinqParameter); internal static new Lambda Parse(NodeWithGraph node) => node switch { diff --git a/GraphEngine/Expressions/ListInit.cs b/GraphEngine/Expressions/ListInit.cs index a499338..ea87311 100644 --- a/GraphEngine/Expressions/ListInit.cs +++ b/GraphEngine/Expressions/ListInit.cs @@ -7,15 +7,15 @@ public class ListInit(NodeWithGraph node) : Expression(node) { public New NewExpression { - get => this.GetRequired(ListInitNewExpression, New.Parse); + get => GetRequired(ListInitNewExpression, New.Parse); - set => this.SetRequired(ListInitNewExpression, value); + set => SetRequired(ListInitNewExpression, value); } - public ICollection Initializers => this.Collection(ListInitInitializers, ElementInit.Parse); + public ICollection Initializers => Collection(ListInitInitializers, ElementInit.Parse); public override Linq.Expression LinqExpression => Linq.Expression.ListInit( - this.NewExpression.LinqNewExpression, - from i in this.Initializers select i.LinqElementInit); + NewExpression.LinqNewExpression, + from i in Initializers select i.LinqElementInit); } diff --git a/GraphEngine/Expressions/Loop.cs b/GraphEngine/Expressions/Loop.cs index 5cbfb74..56a8885 100644 --- a/GraphEngine/Expressions/Loop.cs +++ b/GraphEngine/Expressions/Loop.cs @@ -6,29 +6,29 @@ internal class Loop(NodeWithGraph node) : Expression(node) { public Expression Body { - get => this.GetRequired(LoopBody, Expression.Parse); + get => GetRequired(LoopBody, Expression.Parse); - set => this.SetRequired(LoopBody, value); + set => SetRequired(LoopBody, value); } public Target? Break { - get => this.GetOptional(LoopBreak, Target.Parse); + get => GetOptional(LoopBreak, Target.Parse); - set => this.SetOptional(LoopBreak, value); + set => SetOptional(LoopBreak, value); } public Target? Continue { - get => this.GetOptional(LoopContinue, Target.Parse); + get => GetOptional(LoopContinue, Target.Parse); - set => this.SetOptional(LoopContinue, value); + set => SetOptional(LoopContinue, value); } public override Linq.Expression LinqExpression => this switch { - { Break: not null, Continue: not null } => Linq.Expression.Loop(this.Body.LinqExpression, this.Break.LinqTarget, this.Continue.LinqTarget), - { Break: not null } => Linq.Expression.Loop(this.Body.LinqExpression, this.Break.LinqTarget), - _ => Linq.Expression.Loop(this.Body.LinqExpression) + { Break: not null, Continue: not null } => Linq.Expression.Loop(Body.LinqExpression, Break.LinqTarget, Continue.LinqTarget), + { Break: not null } => Linq.Expression.Loop(Body.LinqExpression, Break.LinqTarget), + _ => Linq.Expression.Loop(Body.LinqExpression) }; } diff --git a/GraphEngine/Expressions/MemberAccess.cs b/GraphEngine/Expressions/MemberAccess.cs index 34f64ab..573ae40 100644 --- a/GraphEngine/Expressions/MemberAccess.cs +++ b/GraphEngine/Expressions/MemberAccess.cs @@ -6,22 +6,22 @@ public abstract class MemberAccess(NodeWithGraph node, INode type) : Expression( { public Expression? Expression { - get => this.GetOptional(MemberAccessExpression, Expression.Parse); + get => GetOptional(MemberAccessExpression, Expression.Parse); - set => this.SetOptional(MemberAccessExpression, value); + set => SetOptional(MemberAccessExpression, value); } public string Name { - get => this.GetRequired(MemberAccessName, AsString); + get => GetRequired(MemberAccessName, AsString); - set => this.SetRequired(MemberAccessName, value); + set => SetRequired(MemberAccessName, value); } public Type? Type { - get => this.GetOptional(MemberAccessType, Type.Parse); + get => GetOptional(MemberAccessType, Type.Parse); - set => this.SetOptional(MemberAccessType, value); + set => SetOptional(MemberAccessType, value); } } diff --git a/GraphEngine/Expressions/MemberInit.cs b/GraphEngine/Expressions/MemberInit.cs index 0c54cd8..f7a0397 100644 --- a/GraphEngine/Expressions/MemberInit.cs +++ b/GraphEngine/Expressions/MemberInit.cs @@ -6,14 +6,14 @@ public class MemberInit(NodeWithGraph node) : Expression(node) { public New NewExpression { - get => this.GetRequired(MemberInitNewExpression, New.Parse); + get => GetRequired(MemberInitNewExpression, New.Parse); - set => this.SetRequired(MemberInitNewExpression, value); + set => SetRequired(MemberInitNewExpression, value); } - public ICollection Bindings => this.Collection(MemberInitBindings, BaseBind.Parse); + public ICollection Bindings => Collection(MemberInitBindings, BaseBind.Parse); public override Linq.Expression LinqExpression => Linq.Expression.MemberInit( - this.NewExpression.LinqNewExpression, - from binding in this.Bindings select binding.LinqMemberBinding); + NewExpression.LinqNewExpression, + from binding in Bindings select binding.LinqMemberBinding); } diff --git a/GraphEngine/Expressions/New.cs b/GraphEngine/Expressions/New.cs index 95a0d1b..81d30f7 100644 --- a/GraphEngine/Expressions/New.cs +++ b/GraphEngine/Expressions/New.cs @@ -6,24 +6,24 @@ namespace GraphEngine; // TODO: Create ConstructorInfo node public class New(NodeWithGraph node) : Expression(node) { - public ICollection Arguments => this.Collection(NewArguments, Expression.Parse); + public ICollection Arguments => Collection(NewArguments, Expression.Parse); public Type Type { - get => this.GetRequired(NewType, Type.Parse); + get => GetRequired(NewType, Type.Parse); - set => this.SetRequired(NewType, value); + set => SetRequired(NewType, value); } - public override Linq.Expression LinqExpression => this.LinqNewExpression; + public override Linq.Expression LinqExpression => LinqNewExpression; internal Linq.NewExpression LinqNewExpression { get { - var argumentExpressions = this.Arguments.LinqExpressions(); + var argumentExpressions = Arguments.LinqExpressions(); var types = (from expression in argumentExpressions select expression.Type).ToArray(); - var constructor = this.Type.SystemType.GetConstructor(types); + var constructor = Type.SystemType.GetConstructor(types); return Linq.Expression.New(constructor, argumentExpressions); } diff --git a/GraphEngine/Expressions/NewArray.cs b/GraphEngine/Expressions/NewArray.cs index 963bfca..8c3f4cd 100644 --- a/GraphEngine/Expressions/NewArray.cs +++ b/GraphEngine/Expressions/NewArray.cs @@ -8,14 +8,14 @@ public abstract class NewArray(NodeWithGraph node, INode type) : Expression(node public Type Type { - get => this.GetRequired(NewArrayType, Type.Parse); + get => GetRequired(NewArrayType, Type.Parse); - set => this.SetRequired(NewArrayType, value); + set => SetRequired(NewArrayType, value); } - public ICollection Expressions => this.Collection(NewArrayExpressions, Expression.Parse); + public ICollection Expressions => Collection(NewArrayExpressions, Expression.Parse); - public override Linq.Expression LinqExpression => this.FactoryMethod(this.Type.SystemType, this.Expressions.LinqExpressions()); + public override Linq.Expression LinqExpression => FactoryMethod(Type.SystemType, Expressions.LinqExpressions()); protected abstract NewArrayExpressionFactory FactoryMethod { get; } } diff --git a/GraphEngine/Expressions/Parameter.cs b/GraphEngine/Expressions/Parameter.cs index bf11766..1d59f69 100644 --- a/GraphEngine/Expressions/Parameter.cs +++ b/GraphEngine/Expressions/Parameter.cs @@ -8,19 +8,19 @@ public class Parameter(NodeWithGraph node) : Expression(node) public Type Type { - get => this.GetRequired(ParameterType, Type.Parse); + get => GetRequired(ParameterType, Type.Parse); - set => this.SetRequired(ParameterType, value); + set => SetRequired(ParameterType, value); } public string? Name { - get => this.GetOptional(ParameterName, AsString); + get => GetOptional(ParameterName, AsString); - set => this.SetOptional(ParameterName, value); + set => SetOptional(ParameterName, value); } - public override Linq.Expression LinqExpression => this.LinqParameter; + public override Linq.Expression LinqExpression => LinqParameter; public Linq.ParameterExpression LinqParameter { @@ -28,7 +28,7 @@ public Linq.ParameterExpression LinqParameter { if (!Cache.TryGetValue(this, out var param)) { - param = Cache[this] = Linq.Expression.Parameter(this.Type.SystemType, this.Name); + param = Cache[this] = Linq.Expression.Parameter(Type.SystemType, Name); } return param; diff --git a/GraphEngine/Expressions/Property.cs b/GraphEngine/Expressions/Property.cs index 0b68661..50da140 100644 --- a/GraphEngine/Expressions/Property.cs +++ b/GraphEngine/Expressions/Property.cs @@ -4,24 +4,24 @@ namespace GraphEngine; public class Property(NodeWithGraph node) : MemberAccess(node, Vocabulary.Property) { - public ICollection Arguments => this.Collection(PropertyArguments, Expression.Parse); + public ICollection Arguments => Collection(PropertyArguments, Expression.Parse); public override Linq.Expression LinqExpression { get { - var arguments = this.Arguments; + var arguments = Arguments; if (arguments.Any()) { - return Linq.Expression.Property(this.Expression?.LinqExpression, this.Name, arguments.LinqExpressions().ToArray()); + return Linq.Expression.Property(Expression?.LinqExpression, Name, arguments.LinqExpressions().ToArray()); } - if (this.Type is Type type) + if (Type is Type type) { - return Linq.Expression.Property(this.Expression?.LinqExpression, type.SystemType, this.Name); + return Linq.Expression.Property(Expression?.LinqExpression, type.SystemType, Name); } - return Linq.Expression.Property(this.Expression?.LinqExpression, this.Name); + return Linq.Expression.Property(Expression?.LinqExpression, Name); } } } diff --git a/GraphEngine/Expressions/PropertyOrField.cs b/GraphEngine/Expressions/PropertyOrField.cs index 0f55040..7c8cecf 100644 --- a/GraphEngine/Expressions/PropertyOrField.cs +++ b/GraphEngine/Expressions/PropertyOrField.cs @@ -4,9 +4,9 @@ namespace GraphEngine; public class PropertyOrField(NodeWithGraph node) : MemberAccess(node, Vocabulary.PropertyOrField) { - public override Linq.Expression LinqExpression => this.Expression switch + public override Linq.Expression LinqExpression => Expression switch { - not null => Linq.Expression.PropertyOrField(this.Expression.LinqExpression, this.Name), + not null => Linq.Expression.PropertyOrField(Expression.LinqExpression, Name), _ => throw new InvalidOperationException($"Expression missing from node {this}") }; } diff --git a/GraphEngine/Expressions/ReferenceEqual.cs b/GraphEngine/Expressions/ReferenceEqual.cs index a1d0657..40843f7 100644 --- a/GraphEngine/Expressions/ReferenceEqual.cs +++ b/GraphEngine/Expressions/ReferenceEqual.cs @@ -4,5 +4,5 @@ namespace GraphEngine; public class ReferenceEqual(NodeWithGraph node) : Binary(node, Vocabulary.ReferenceEqual) { - public override Linq.Expression LinqExpression => Linq.Expression.ReferenceEqual(this.Left.LinqExpression, this.Right.LinqExpression); + public override Linq.Expression LinqExpression => Linq.Expression.ReferenceEqual(Left.LinqExpression, Right.LinqExpression); } diff --git a/GraphEngine/Expressions/ReferenceNotEqual.cs b/GraphEngine/Expressions/ReferenceNotEqual.cs index d667f86..771b2b4 100644 --- a/GraphEngine/Expressions/ReferenceNotEqual.cs +++ b/GraphEngine/Expressions/ReferenceNotEqual.cs @@ -4,5 +4,5 @@ namespace GraphEngine; public class ReferenceNotEqual(NodeWithGraph node) : Binary(node, Vocabulary.ReferenceNotEqual) { - public override Linq.Expression LinqExpression => Linq.Expression.ReferenceNotEqual(this.Left.LinqExpression, this.Right.LinqExpression); + public override Linq.Expression LinqExpression => Linq.Expression.ReferenceNotEqual(Left.LinqExpression, Right.LinqExpression); } diff --git a/GraphEngine/Expressions/RuntimeVariables.cs b/GraphEngine/Expressions/RuntimeVariables.cs index f4ee736..1e1e739 100644 --- a/GraphEngine/Expressions/RuntimeVariables.cs +++ b/GraphEngine/Expressions/RuntimeVariables.cs @@ -4,7 +4,7 @@ namespace GraphEngine; public class RuntimeVariables(NodeWithGraph node) : Expression(node) { - public ICollection Variables => this.Collection(RuntimeVariablesVariables, Parameter.Parse); + public ICollection Variables => Collection(RuntimeVariablesVariables, Parameter.Parse); - public override Linq.Expression LinqExpression => Linq.Expression.RuntimeVariables(from e in this.Variables select e.LinqParameter); + public override Linq.Expression LinqExpression => Linq.Expression.RuntimeVariables(from e in Variables select e.LinqParameter); } diff --git a/GraphEngine/Expressions/Switch.cs b/GraphEngine/Expressions/Switch.cs index 771941e..d6511c2 100644 --- a/GraphEngine/Expressions/Switch.cs +++ b/GraphEngine/Expressions/Switch.cs @@ -6,33 +6,33 @@ public class Switch(NodeWithGraph node) : Expression(node) { public Type? Type { - get => this.GetOptional(SwitchType, Type.Parse); + get => GetOptional(SwitchType, Type.Parse); - set => this.SetOptional(SwitchType, value); + set => SetOptional(SwitchType, value); } public Expression SwitchValue { - get => this.GetRequired(SwitchSwitchValue, Expression.Parse); + get => GetRequired(SwitchSwitchValue, Expression.Parse); - set => this.SetRequired(SwitchSwitchValue, value); + set => SetRequired(SwitchSwitchValue, value); } public Expression? DeafultBody { - get => this.GetOptional(SwitchDefaultBody, Expression.Parse); + get => GetOptional(SwitchDefaultBody, Expression.Parse); - set => this.SetOptional(SwitchDefaultBody, value); + set => SetOptional(SwitchDefaultBody, value); } public Method? Comparison { - get => this.GetOptional(SwitchComparison, Method.Parse); + get => GetOptional(SwitchComparison, Method.Parse); - set => this.SetOptional(SwitchComparison, value); + set => SetOptional(SwitchComparison, value); } - public ICollection Cases => this.Collection(SwitchCases, Case.Parse); + public ICollection Cases => Collection(SwitchCases, Case.Parse); - public override Linq.Expression LinqExpression => Linq.Expression.Switch(this.Type?.SystemType, this.SwitchValue.LinqExpression, this.DeafultBody?.LinqExpression, this.Comparison?.ReflectionMethod, this.Cases.Select(@case => @case.LinqSwitchCase)); + public override Linq.Expression LinqExpression => Linq.Expression.Switch(Type?.SystemType, SwitchValue.LinqExpression, DeafultBody?.LinqExpression, Comparison?.ReflectionMethod, Cases.Select(@case => @case.LinqSwitchCase)); } diff --git a/GraphEngine/Expressions/Throw.cs b/GraphEngine/Expressions/Throw.cs index db275e3..0280eae 100644 --- a/GraphEngine/Expressions/Throw.cs +++ b/GraphEngine/Expressions/Throw.cs @@ -6,20 +6,20 @@ public class Throw(NodeWithGraph node, INode? type = default) : Expression(node, { public Expression? Value { - get => this.GetOptional(ThrowValue, Expression.Parse); + get => GetOptional(ThrowValue, Expression.Parse); - set => this.SetOptional(ThrowValue, value); + set => SetOptional(ThrowValue, value); } public Type? Type { - get => this.GetOptional(ThrowType, Type.Parse); + get => GetOptional(ThrowType, Type.Parse); - set => this.SetOptional(ThrowType, value); + set => SetOptional(ThrowType, value); } public override Linq.Expression LinqExpression => Linq.Expression.Throw( - this.Value?.LinqExpression, - this.Type?.SystemType ?? typeof(void)); + Value?.LinqExpression, + Type?.SystemType ?? typeof(void)); } diff --git a/GraphEngine/Expressions/Try.cs b/GraphEngine/Expressions/Try.cs index 92b9f37..99009dc 100644 --- a/GraphEngine/Expressions/Try.cs +++ b/GraphEngine/Expressions/Try.cs @@ -6,38 +6,38 @@ public class Try(NodeWithGraph node) : Expression(node) { public Type? Type { - get => this.GetOptional(TryType, Type.Parse); + get => GetOptional(TryType, Type.Parse); - set => this.SetOptional(TryType, value); + set => SetOptional(TryType, value); } public Expression Body { - get => this.GetRequired(TryBody, Expression.Parse); + get => GetRequired(TryBody, Expression.Parse); - set => this.SetRequired(TryBody, value); + set => SetRequired(TryBody, value); } public Expression? Finally { - get => this.GetOptional(TryFinally, Expression.Parse); + get => GetOptional(TryFinally, Expression.Parse); - set => this.SetOptional(TryFinally, value); + set => SetOptional(TryFinally, value); } public Expression? Fault { - get => this.GetOptional(TryFault, Expression.Parse); + get => GetOptional(TryFault, Expression.Parse); - set => this.SetOptional(TryFault, value); + set => SetOptional(TryFault, value); } - public ICollection Handlers => this.Collection(TryHandlers, Catch.Parse); + public ICollection Handlers => Collection(TryHandlers, Catch.Parse); public override Linq.Expression LinqExpression => Linq.Expression.MakeTry( - this.Type?.SystemType, - this.Body.LinqExpression, - this.Finally?.LinqExpression, - this.Fault?.LinqExpression, - from h in this.Handlers select h.LinqCatchBlock); + Type?.SystemType, + Body.LinqExpression, + Finally?.LinqExpression, + Fault?.LinqExpression, + from h in Handlers select h.LinqCatchBlock); } diff --git a/GraphEngine/Expressions/TypeBinary.cs b/GraphEngine/Expressions/TypeBinary.cs index 7eb935f..841cb6e 100644 --- a/GraphEngine/Expressions/TypeBinary.cs +++ b/GraphEngine/Expressions/TypeBinary.cs @@ -6,29 +6,29 @@ public class TypeBinary(NodeWithGraph node) : Expression(node) { public ExpressionType ExpressionType { - get => this.GetRequired(TypeBinaryExpressionType, ExpressionType.Parse); + get => GetRequired(TypeBinaryExpressionType, ExpressionType.Parse); - set => this.SetRequired(TypeBinaryExpressionType, value); + set => SetRequired(TypeBinaryExpressionType, value); } public Expression Expression { - get => this.GetRequired(TypeBinaryExpression, Expression.Parse); + get => GetRequired(TypeBinaryExpression, Expression.Parse); - set => this.SetRequired(TypeBinaryExpression, value); + set => SetRequired(TypeBinaryExpression, value); } public Type Type { - get => this.GetRequired(TypeBinaryType, Type.Parse); + get => GetRequired(TypeBinaryType, Type.Parse); - set => this.SetRequired(TypeBinaryType, value); + set => SetRequired(TypeBinaryType, value); } - public override Linq.Expression LinqExpression => this.ExpressionType.LinqExpressionType switch + public override Linq.Expression LinqExpression => ExpressionType.LinqExpressionType switch { - Linq.ExpressionType.TypeEqual => Linq.Expression.TypeEqual(this.Expression.LinqExpression, this.Type.SystemType), - Linq.ExpressionType.TypeIs => Linq.Expression.TypeIs(this.Expression.LinqExpression, this.Type.SystemType), + Linq.ExpressionType.TypeEqual => Linq.Expression.TypeEqual(Expression.LinqExpression, Type.SystemType), + Linq.ExpressionType.TypeIs => Linq.Expression.TypeIs(Expression.LinqExpression, Type.SystemType), var unknown => throw new InvalidOperationException($"{unknown} is not binarytype"), }; diff --git a/GraphEngine/Expressions/Unary.cs b/GraphEngine/Expressions/Unary.cs index 2b9029e..a9b2672 100644 --- a/GraphEngine/Expressions/Unary.cs +++ b/GraphEngine/Expressions/Unary.cs @@ -6,37 +6,37 @@ public class Unary(NodeWithGraph node) : Expression(node) { public Expression Operand { - get => this.GetRequired(UnaryOperand, Expression.Parse); + get => GetRequired(UnaryOperand, Expression.Parse); - set => this.SetRequired(UnaryOperand, value); + set => SetRequired(UnaryOperand, value); } public Type? Type { - get => this.GetOptional(UnaryType, Type.Parse); + get => GetOptional(UnaryType, Type.Parse); - set => this.SetOptional(UnaryType, value); + set => SetOptional(UnaryType, value); } public ExpressionType ExpressionType { - get => this.GetRequired(UnaryExpressionType, ExpressionType.Parse); + get => GetRequired(UnaryExpressionType, ExpressionType.Parse); - set => this.SetRequired(UnaryExpressionType, value); + set => SetRequired(UnaryExpressionType, value); } public Method? Method { - get => this.GetOptional(UnaryMethod, Method.Parse); + get => GetOptional(UnaryMethod, Method.Parse); - set => this.SetOptional(UnaryMethod, value); + set => SetOptional(UnaryMethod, value); } public override Linq.Expression LinqExpression => Linq.Expression.MakeUnary( - this.ExpressionType.LinqExpressionType, - this.Operand.LinqExpression, - this.Type?.SystemType, - this.Method?.ReflectionMethod); + ExpressionType.LinqExpressionType, + Operand.LinqExpression, + Type?.SystemType, + Method?.ReflectionMethod); public static Unary Create(NodeWithGraph node, Linq.ExpressionType type) => type switch { diff --git a/GraphEngine/GlobalSuppressions.cs b/GraphEngine/GlobalSuppressions.cs new file mode 100644 index 0000000..9701f12 --- /dev/null +++ b/GraphEngine/GlobalSuppressions.cs @@ -0,0 +1,5 @@ +// MIT License, Copyright 2020 Samu Lang + +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Seems to be new default style")] diff --git a/GraphEngine/Graph.cs b/GraphEngine/Graph.cs index ec4bce2..f9c9d51 100644 --- a/GraphEngine/Graph.cs +++ b/GraphEngine/Graph.cs @@ -26,15 +26,15 @@ static Graph() public Graph() : base() { - this.AttachEventHandlers(); - this.TripleAsserted += this.Graph_TripleAsserted; + AttachEventHandlers(); + TripleAsserted += Graph_TripleAsserted; } public Graph(IGraph g) : base(g) { Reasoner.Apply(this); - this.TripleAsserted += this.Graph_TripleAsserted; + TripleAsserted += Graph_TripleAsserted; } private static IEnumerable ExcludedClasses diff --git a/GraphEngine/InvokeMember.cs b/GraphEngine/InvokeMember.cs index db79029..50c28ff 100644 --- a/GraphEngine/InvokeMember.cs +++ b/GraphEngine/InvokeMember.cs @@ -9,8 +9,8 @@ public class InvokeMember(NodeWithGraph node) : Binder(node, Vocabulary.InvokeMe { internal override CallSiteBinder SystemBinder => CSharp.Binder.InvokeMember( CSharp.CSharpBinderFlags.None, - this.Name, + Name, null, null, - from a in this.Arguments select a.Info); + from a in Arguments select a.Info); } diff --git a/GraphEngine/ListBind.cs b/GraphEngine/ListBind.cs index 80636d7..4b37d92 100644 --- a/GraphEngine/ListBind.cs +++ b/GraphEngine/ListBind.cs @@ -4,9 +4,9 @@ namespace GraphEngine; public class ListBind(NodeWithGraph node) : BaseBind(node, Vocabulary.ListBind) { - public ICollection Initializers => this.Collection(ListBindInitializers, ElementInit.Parse); + public ICollection Initializers => Collection(ListBindInitializers, ElementInit.Parse); public override Linq.MemberBinding LinqMemberBinding => Linq.Expression.ListBind( - this.Member.ReflectionMember, - from initializer in this.Initializers select initializer.LinqElementInit); + Member.ReflectionMember, + from initializer in Initializers select initializer.LinqElementInit); } diff --git a/GraphEngine/Member.cs b/GraphEngine/Member.cs index dc72ece..171451f 100644 --- a/GraphEngine/Member.cs +++ b/GraphEngine/Member.cs @@ -8,19 +8,19 @@ public class Member(NodeWithGraph node) : Node(node) { public Type Type { - get => this.GetRequired(MemberType, Type.Parse); + get => GetRequired(MemberType, Type.Parse); - set => this.SetRequired(MemberType, value); + set => SetRequired(MemberType, value); } public string Name { - get => this.GetRequired(MemberName, AsString); + get => GetRequired(MemberName, AsString); - set => this.SetRequired(MemberName, value); + set => SetRequired(MemberName, value); } - public MemberInfo ReflectionMember => this.Type.SystemType.GetMember(this.Name).Single(); + public MemberInfo ReflectionMember => Type.SystemType.GetMember(Name).Single(); internal static Member Parse(NodeWithGraph node) => node switch { diff --git a/GraphEngine/MemberBind.cs b/GraphEngine/MemberBind.cs index d6b6823..8dae076 100644 --- a/GraphEngine/MemberBind.cs +++ b/GraphEngine/MemberBind.cs @@ -5,9 +5,9 @@ namespace GraphEngine; // TODO: Add overloads public class MemberBind(NodeWithGraph node) : BaseBind(node, Vocabulary.MemberBind) { - public ICollection Bindings => this.Collection(MemberBindBindings, BaseBind.Parse); + public ICollection Bindings => Collection(MemberBindBindings, BaseBind.Parse); public override Linq.MemberBinding LinqMemberBinding => Linq.Expression.MemberBind( - this.Member.ReflectionMember, - from binding in this.Bindings select binding.LinqMemberBinding); + Member.ReflectionMember, + from binding in Bindings select binding.LinqMemberBinding); } diff --git a/GraphEngine/Method.cs b/GraphEngine/Method.cs index 7a6f939..f73c8a9 100644 --- a/GraphEngine/Method.cs +++ b/GraphEngine/Method.cs @@ -7,15 +7,15 @@ namespace GraphEngine; // TODO: Improve derivation public class Method(NodeWithGraph node) : Member(node) { - public ICollection TypeArguments => this.Collection(MethodTypeArguments, Type.Parse); + public ICollection TypeArguments => Collection(MethodTypeArguments, Type.Parse); public MethodInfo? ReflectionMethod { get { - var methodInfo = this.Type.SystemType.GetMethod(this.Name); + var methodInfo = Type.SystemType.GetMethod(Name); - var typeArguments = this.TypeArguments.Select(ta => ta.SystemType).ToArray(); + var typeArguments = TypeArguments.Select(ta => ta.SystemType).ToArray(); if (typeArguments.Any()) { methodInfo = methodInfo.MakeGenericMethod(typeArguments); diff --git a/GraphEngine/Node.cs b/GraphEngine/Node.cs index 143f9cd..4ed49b3 100644 --- a/GraphEngine/Node.cs +++ b/GraphEngine/Node.cs @@ -12,14 +12,14 @@ public Node(NodeWithGraph node, INode? type = default) return; } - this.RdfType = type; + RdfType = type; } public INode? RdfType { get => Vocabulary.RdfType.ObjectOf(this); - set => this.SetOptional(Vocabulary.RdfType, value); + set => SetOptional(Vocabulary.RdfType, value); } protected static int AsInt(NodeWithGraph node) @@ -121,20 +121,20 @@ protected ICollection Collection(INode predicate, Func p where T : NodeWithGraph => new Collection(this, predicate, parser); - protected void SetRequired(INode predicate, object @object) => this.SetOptional( + protected void SetRequired(INode predicate, object @object) => SetOptional( predicate, @object ?? throw new ArgumentNullException(nameof(@object))); protected void SetOptional(INode predicate, object? @object) { - this.Graph.Retract( - this.Graph.GetTriplesWithSubjectPredicate( + Graph.Retract( + Graph.GetTriplesWithSubjectPredicate( this, predicate).ToList()); if (@object is not null) { - this.Graph.Assert(this, predicate, @object.AsNode(this.Graph)); + Graph.Assert(this, predicate, @object.AsNode(Graph)); } } @@ -157,11 +157,11 @@ protected void SetOptional(INode predicate, object? @object) protected T GetRequired(INode predicate, Func parser) where T : class => - this.GetOptional(predicate, parser) + GetOptional(predicate, parser) ?? throw new Exception($"Single {predicate} not found on {this}"); protected T GetRequiredS(INode predicate, Func parser) where T : struct => - this.GetOptionalS(predicate, parser) + GetOptionalS(predicate, parser) ?? throw new Exception($"Single {predicate} not found on {this}"); } diff --git a/GraphEngine/NodeWithGraph.cs b/GraphEngine/NodeWithGraph.cs index 5567c5e..2602de0 100644 --- a/GraphEngine/NodeWithGraph.cs +++ b/GraphEngine/NodeWithGraph.cs @@ -6,5 +6,5 @@ public class NodeWithGraph(INode node, IGraph graph) : WrapperNode(node) { public IGraph Graph { get; } = graph; - public INode Original => this.Node; + public INode Original => Node; } diff --git a/GraphEngine/SerialisingVisitor.cs b/GraphEngine/SerialisingVisitor.cs index 8b192b0..a064ac0 100644 --- a/GraphEngine/SerialisingVisitor.cs +++ b/GraphEngine/SerialisingVisitor.cs @@ -13,23 +13,23 @@ public class SerialisingVisitor(NodeWithGraph node) : Linq.ExpressionVisitor() private readonly Stack path = new(); private bool initialised; - private NodeWithGraph Current => this.path.Peek(); + private NodeWithGraph Current => path.Peek(); private NodeWithGraph this[object index] { get { - if (!this.initialised) + if (!initialised) { - this.mapping[index] = this.node; - this.initialised = true; + mapping[index] = node; + initialised = true; - return this.node; + return node; } - if (!this.mapping.TryGetValue(index, out var current)) + if (!mapping.TryGetValue(index, out var current)) { - current = this.mapping[index] = this.node.Graph.CreateBlankNode().In(this.node.Graph); + current = mapping[index] = node.Graph.CreateBlankNode().In(node.Graph); } return current; @@ -38,7 +38,7 @@ private NodeWithGraph this[object index] public override Linq.Expression Visit(Linq.Expression? node) { - using (this.Wrap(node)) + using (Wrap(node)) { return base.Visit(node); } @@ -48,10 +48,10 @@ protected override Linq.Expression VisitBinary(Linq.BinaryExpression node) { if (node.NodeType == Linq.ExpressionType.ArrayIndex) { - _ = new ArrayIndex(this.Current) + _ = new ArrayIndex(Current) { - Array = this.VisitCacheParse(node.Left), - Index = this.VisitCacheParse(node.Right), + Array = VisitCacheParse(node.Left), + Index = VisitCacheParse(node.Right), }; } else @@ -62,25 +62,25 @@ protected override Linq.Expression VisitBinary(Linq.BinaryExpression node) { if (node.NodeType == Linq.ExpressionType.Equal) { - binary = new ReferenceEqual(this.Current); + binary = new ReferenceEqual(Current); } else { - binary = new ReferenceNotEqual(this.Current); + binary = new ReferenceNotEqual(Current); } } else { - binary = Binary.Create(this.Current, node.NodeType); + binary = Binary.Create(Current, node.NodeType); if (node.Method is MethodInfo method) { - binary.Method = this.VisitMethod(method); + binary.Method = VisitMethod(method); } if (node.Conversion is Linq.LambdaExpression lambda) { - binary.Conversion = new Lambda(this.VisitCache(lambda)); + binary.Conversion = new Lambda(VisitCache(lambda)); } if (node.IsLiftedToNull) @@ -89,8 +89,8 @@ protected override Linq.Expression VisitBinary(Linq.BinaryExpression node) } } - binary.Left = this.VisitCacheParse(node.Left); - binary.Right = this.VisitCacheParse(node.Right); + binary.Left = VisitCacheParse(node.Left); + binary.Right = VisitCacheParse(node.Right); } return node; @@ -98,21 +98,21 @@ protected override Linq.Expression VisitBinary(Linq.BinaryExpression node) protected override Linq.Expression VisitBlock(Linq.BlockExpression node) { - var block = new Block(this.Current); + var block = new Block(Current); if (!Extensions.AreEquivalent(node.Type, node.Expressions.Last().Type)) { - block.Type = this.VisitType(node.Type); + block.Type = VisitType(node.Type); } foreach (var variable in node.Variables) { - block.Variables.Add(new Parameter(this.VisitCache(variable))); + block.Variables.Add(new Parameter(VisitCache(variable))); } foreach (var blockExpression in node.Expressions) { - block.Expressions.Add(this.VisitCacheParse(blockExpression)); + block.Expressions.Add(VisitCacheParse(blockExpression)); } return node; @@ -126,45 +126,45 @@ protected override Linq.Expression VisitConditional(Linq.ConditionalExpression n { if (node.IfFalse is Linq.DefaultExpression defaultExpression && defaultExpression.Type == typeof(void)) { - condition = new IfThen(this.Current); + condition = new IfThen(Current); } else { - condition = new IfThenElse(this.Current) + condition = new IfThenElse(Current) { - IfFalse = this.VisitCacheParse(node.IfFalse), + IfFalse = VisitCacheParse(node.IfFalse), }; } } else { - condition = new Condition(this.Current) + condition = new Condition(Current) { - IfFalse = this.VisitCacheParse(node.IfFalse), + IfFalse = VisitCacheParse(node.IfFalse), }; if (node.Type != node.IfTrue.Type) { - condition.Type = this.VisitType(node.Type); + condition.Type = VisitType(node.Type); } } - condition.Test = this.VisitCacheParse(node.Test); - condition.IfTrue = this.VisitCacheParse(node.IfTrue); + condition.Test = VisitCacheParse(node.Test); + condition.IfTrue = VisitCacheParse(node.IfTrue); return node; } protected override Linq.Expression VisitConstant(Linq.ConstantExpression node) { - var constant = new Constant(this.Current) + var constant = new Constant(Current) { Value = node.Value, }; if (node.Type != node.Value.GetType()) { - constant.Type = this.VisitType(node.Type); + constant.Type = VisitType(node.Type); } return node; @@ -174,11 +174,11 @@ protected override Linq.Expression VisitDebugInfo(Linq.DebugInfoExpression node) { var debugInfo = node.IsClear switch { - true => new ClearDebugInfo(this.Current), - false => new DebugInfo(this.Current), + true => new ClearDebugInfo(Current), + false => new DebugInfo(Current), }; - debugInfo.Document = this.VisitSymbolDocument(node.Document); + debugInfo.Document = VisitSymbolDocument(node.Document); debugInfo.StartLine = node.StartLine; debugInfo.StartColumn = node.StartLine; debugInfo.EndLine = node.EndLine; @@ -191,13 +191,13 @@ protected override Linq.Expression VisitDefault(Linq.DefaultExpression node) { if (node.Type == typeof(void)) { - _ = new Empty(this.Current); + _ = new Empty(Current); } else { - _ = new Default(this.Current) + _ = new Default(Current) { - Type = this.VisitType(node.Type), + Type = VisitType(node.Type), }; } @@ -206,15 +206,15 @@ protected override Linq.Expression VisitDefault(Linq.DefaultExpression node) protected override Linq.Expression VisitDynamic(Linq.DynamicExpression node) { - var dynamicNode = new Dynamic(this.Current) + var dynamicNode = new Dynamic(Current) { - Binder = this.VisitBinder(node.Binder), - ReturnType = this.VisitType(node.Type), + Binder = VisitBinder(node.Binder), + ReturnType = VisitType(node.Type), }; foreach (var argument in node.Arguments) { - dynamicNode.Arguments.Add(this.VisitCacheParse(argument)); + dynamicNode.Arguments.Add(VisitCacheParse(argument)); } return node; @@ -222,16 +222,16 @@ protected override Linq.Expression VisitDynamic(Linq.DynamicExpression node) protected override Linq.ElementInit VisitElementInit(Linq.ElementInit node) { - using (this.Wrap(node)) + using (Wrap(node)) { - var elementInit = new ElementInit(this.Current) + var elementInit = new ElementInit(Current) { - AddMethod = this.VisitMethod(node.AddMethod), + AddMethod = VisitMethod(node.AddMethod), }; foreach (var argument in node.Arguments) { - elementInit.Arguments.Add(this.VisitCacheParse(argument)); + elementInit.Arguments.Add(VisitCacheParse(argument)); } return node; @@ -242,7 +242,7 @@ protected override Linq.Expression VisitExtension(Linq.Expression node) { if (node is Linq.DynamicExpression dynamicExpression) { - return this.VisitDynamic(dynamicExpression); + return VisitDynamic(dynamicExpression); } throw new InvalidOperationException($"unknown extension {node}"); @@ -250,18 +250,18 @@ protected override Linq.Expression VisitExtension(Linq.Expression node) protected override Linq.Expression VisitGoto(Linq.GotoExpression node) { - var @goto = BaseGoto.Create(this.Current, node.Kind); + var @goto = BaseGoto.Create(Current, node.Kind); - @goto.Target = new Target(this[this.VisitLabelTarget(node.Target)]); + @goto.Target = new Target(this[VisitLabelTarget(node.Target)]); if (node.Value is not null) { - @goto.Value = this.VisitCacheParse(node.Value); + @goto.Value = VisitCacheParse(node.Value); } if (node.Type != typeof(void)) { - @goto.Type = this.VisitType(node.Type); + @goto.Type = VisitType(node.Type); } return node; @@ -271,27 +271,27 @@ protected override Linq.Expression VisitIndex(Linq.IndexExpression node) { if (node.Indexer is not null) { - var property = new Property(this.Current) + var property = new Property(Current) { - Expression = this.VisitCacheParse(node.Object), + Expression = VisitCacheParse(node.Object), Name = node.Indexer.Name, }; foreach (var index in node.Arguments) { - property.Arguments.Add(this.VisitCacheParse(index)); + property.Arguments.Add(VisitCacheParse(index)); } } else { - var arrayAccess = new ArrayAccess(this.Current) + var arrayAccess = new ArrayAccess(Current) { - Array = this.VisitCacheParse(node.Object), + Array = VisitCacheParse(node.Object), }; foreach (var index in node.Arguments) { - arrayAccess.Indexes.Add(this.VisitCacheParse(index)); + arrayAccess.Indexes.Add(VisitCacheParse(index)); } } @@ -300,13 +300,13 @@ protected override Linq.Expression VisitIndex(Linq.IndexExpression node) protected override Linq.LabelTarget VisitLabelTarget(Linq.LabelTarget? node) { - using (this.Wrap(node)) + using (Wrap(node)) { - var target = new Target(this.Current); + var target = new Target(Current); if (node.Type != typeof(void)) { - target.Type = this.VisitType(node.Type); + target.Type = VisitType(node.Type); } if (node.Name is not null) @@ -320,14 +320,14 @@ protected override Linq.LabelTarget VisitLabelTarget(Linq.LabelTarget? node) protected override Linq.Expression VisitListInit(Linq.ListInitExpression node) { - var listInit = new ListInit(this.Current) + var listInit = new ListInit(Current) { - NewExpression = new New(this.VisitCache(node.NewExpression)), + NewExpression = new New(VisitCache(node.NewExpression)), }; foreach (var initializer in node.Initializers) { - listInit.Initializers.Add(new ElementInit(this[this.VisitElementInit(initializer)])); + listInit.Initializers.Add(new ElementInit(this[VisitElementInit(initializer)])); } return node; @@ -335,14 +335,14 @@ protected override Linq.Expression VisitListInit(Linq.ListInitExpression node) protected override Linq.Expression VisitLambda(Linq.Expression node) { - var lambda = new Lambda(this.Current) + var lambda = new Lambda(Current) { - Body = this.VisitCacheParse(node.Body), + Body = VisitCacheParse(node.Body), }; foreach (var parameter in node.Parameters) { - lambda.Parameters.Add(new Parameter(this.VisitCache(parameter))); + lambda.Parameters.Add(new Parameter(VisitCache(parameter))); } return node; @@ -350,19 +350,19 @@ protected override Linq.Expression VisitLambda(Linq.Expression node) protected override Linq.Expression VisitLoop(Linq.LoopExpression node) { - var loop = new Loop(this.Current) + var loop = new Loop(Current) { - Body = this.VisitCacheParse(node.Body), + Body = VisitCacheParse(node.Body), }; if (node.ContinueLabel is not null) { - loop.Continue = new Target(this[this.VisitLabelTarget(node.ContinueLabel)]); + loop.Continue = new Target(this[VisitLabelTarget(node.ContinueLabel)]); } if (node.BreakLabel is not null) { - loop.Break = new Target(this[this.VisitLabelTarget(node.BreakLabel)]); + loop.Break = new Target(this[VisitLabelTarget(node.BreakLabel)]); } return node; @@ -372,8 +372,8 @@ protected override Linq.Expression VisitMember(Linq.MemberExpression node) { var memberAccess = node.Member.MemberType switch { - MemberTypes.Field => new Field(this.Current) as MemberAccess, - MemberTypes.Property => new Property(this.Current) as MemberAccess, + MemberTypes.Field => new Field(Current) as MemberAccess, + MemberTypes.Property => new Property(Current) as MemberAccess, var mt => throw new Exception($"unknown member type {mt}") }; @@ -381,12 +381,12 @@ protected override Linq.Expression VisitMember(Linq.MemberExpression node) if (node.Expression is not null) { - memberAccess.Expression = this.VisitCacheParse(node.Expression); + memberAccess.Expression = VisitCacheParse(node.Expression); } if (node.Expression is null || node.Expression.Type != node.Member.DeclaringType) { - memberAccess.Type = this.VisitType(node.Member.DeclaringType); + memberAccess.Type = VisitType(node.Member.DeclaringType); } return node; @@ -394,10 +394,10 @@ protected override Linq.Expression VisitMember(Linq.MemberExpression node) protected override Linq.MemberAssignment VisitMemberAssignment(Linq.MemberAssignment node) { - _ = new Bind(this.Current) + _ = new Bind(Current) { - Member = this.VisitMember(node.Member), - Expression = this.VisitCacheParse(node.Expression), + Member = VisitMember(node.Member), + Expression = VisitCacheParse(node.Expression), }; return node; @@ -405,13 +405,13 @@ protected override Linq.MemberAssignment VisitMemberAssignment(Linq.MemberAssign protected override Linq.MemberBinding VisitMemberBinding(Linq.MemberBinding node) { - using (this.Wrap(node)) + using (Wrap(node)) { return node switch { - Linq.MemberAssignment binding => this.VisitMemberAssignment(binding), - Linq.MemberMemberBinding binding => this.VisitMemberMemberBinding(binding), - Linq.MemberListBinding binding => this.VisitMemberListBinding(binding), + Linq.MemberAssignment binding => VisitMemberAssignment(binding), + Linq.MemberMemberBinding binding => VisitMemberMemberBinding(binding), + Linq.MemberListBinding binding => VisitMemberListBinding(binding), var n => throw new Exception($"unknown member binding {n}") }; } @@ -419,14 +419,14 @@ protected override Linq.MemberBinding VisitMemberBinding(Linq.MemberBinding node protected override Linq.Expression VisitMemberInit(Linq.MemberInitExpression node) { - var memberInit = new MemberInit(this.Current) + var memberInit = new MemberInit(Current) { - NewExpression = new New(this.VisitCache(node.NewExpression)), + NewExpression = new New(VisitCache(node.NewExpression)), }; foreach (var binding in node.Bindings) { - memberInit.Bindings.Add(BaseBind.Create(this[this.VisitMemberBinding(binding)], binding.BindingType)); + memberInit.Bindings.Add(BaseBind.Create(this[VisitMemberBinding(binding)], binding.BindingType)); } return node; @@ -434,14 +434,14 @@ protected override Linq.Expression VisitMemberInit(Linq.MemberInitExpression nod protected override Linq.MemberListBinding VisitMemberListBinding(Linq.MemberListBinding node) { - var listBinding = new ListBind(this.Current) + var listBinding = new ListBind(Current) { - Member = this.VisitMember(node.Member), + Member = VisitMember(node.Member), }; foreach (var item in node.Initializers) { - listBinding.Initializers.Add(new ElementInit(this[this.VisitElementInit(item)])); + listBinding.Initializers.Add(new ElementInit(this[VisitElementInit(item)])); } return node; @@ -449,14 +449,14 @@ protected override Linq.MemberListBinding VisitMemberListBinding(Linq.MemberList protected override Linq.MemberMemberBinding VisitMemberMemberBinding(Linq.MemberMemberBinding node) { - var memberBinding = new MemberBind(this.Current) + var memberBinding = new MemberBind(Current) { - Member = this.VisitMember(node.Member), + Member = VisitMember(node.Member), }; foreach (var binding in node.Bindings) { - memberBinding.Bindings.Add(BaseBind.Create(this[this.VisitMemberBinding(binding)], binding.BindingType)); + memberBinding.Bindings.Add(BaseBind.Create(this[VisitMemberBinding(binding)], binding.BindingType)); } return node; @@ -464,19 +464,19 @@ protected override Linq.MemberMemberBinding VisitMemberMemberBinding(Linq.Member protected override Linq.Expression VisitMethodCall(Linq.MethodCallExpression node) { - var call = new Call(this.Current) + var call = new Call(Current) { - Method = this.VisitMethod(node.Method), + Method = VisitMethod(node.Method), }; if (node.Object is not null) { - call.Instance = this.VisitCacheParse(node.Object); + call.Instance = VisitCacheParse(node.Object); } foreach (var argument in node.Arguments) { - call.Arguments.Add(this.VisitCacheParse(argument)); + call.Arguments.Add(VisitCacheParse(argument)); } return node; @@ -484,9 +484,9 @@ protected override Linq.Expression VisitMethodCall(Linq.MethodCallExpression nod protected override Linq.Expression VisitNew(Linq.NewExpression node) { - _ = new New(this.Current) + _ = new New(Current) { - Type = this.VisitType(node.Type), + Type = VisitType(node.Type), }; return node; @@ -497,18 +497,18 @@ protected override Linq.Expression VisitNewArray(Linq.NewArrayExpression node) NewArray newArray; if (node.NodeType == Linq.ExpressionType.NewArrayBounds) { - newArray = new NewArrayBounds(this.Current); + newArray = new NewArrayBounds(Current); } else { - newArray = new NewArrayInit(this.Current); + newArray = new NewArrayInit(Current); } - newArray.Type = this.VisitType(node.Type.GetElementType()); + newArray.Type = VisitType(node.Type.GetElementType()); foreach (var expression in node.Expressions) { - newArray.Expressions.Add(this.VisitCacheParse(expression)); + newArray.Expressions.Add(VisitCacheParse(expression)); } return node; @@ -516,9 +516,9 @@ protected override Linq.Expression VisitNewArray(Linq.NewArrayExpression node) protected override Linq.Expression VisitParameter(Linq.ParameterExpression node) { - var parameter = new Parameter(this.Current) + var parameter = new Parameter(Current) { - Type = this.VisitType(node.Type), + Type = VisitType(node.Type), }; if (node.Name is not null) @@ -531,11 +531,11 @@ protected override Linq.Expression VisitParameter(Linq.ParameterExpression node) protected override Linq.Expression VisitRuntimeVariables(Linq.RuntimeVariablesExpression node) { - var runtimeVariables = new RuntimeVariables(this.Current); + var runtimeVariables = new RuntimeVariables(Current); foreach (var variable in node.Variables) { - runtimeVariables.Variables.Add(new Parameter(this.VisitCache(variable))); + runtimeVariables.Variables.Add(new Parameter(VisitCache(variable))); } return node; @@ -543,11 +543,11 @@ protected override Linq.Expression VisitRuntimeVariables(Linq.RuntimeVariablesEx protected override Linq.Expression VisitTypeBinary(Linq.TypeBinaryExpression node) { - _ = new TypeBinary(this.Current) + _ = new TypeBinary(Current) { - ExpressionType = this.VisitExpressionType(node.NodeType), - Expression = this.VisitCacheParse(node.Expression), - Type = this.VisitType(node.TypeOperand), + ExpressionType = VisitExpressionType(node.NodeType), + Expression = VisitCacheParse(node.Expression), + Type = VisitType(node.TypeOperand), }; return node; @@ -559,83 +559,83 @@ protected override Linq.Expression VisitUnary(Linq.UnaryExpression node) { if (node.Operand is null && node.Type == typeof(void)) { - _ = new Rethrow(this.Current); + _ = new Rethrow(Current); } - var @throw = new Throw(this.Current); + var @throw = new Throw(Current); if (node.Operand is Linq.Expression value) { - @throw.Value = this.VisitCacheParse(value); + @throw.Value = VisitCacheParse(value); } if (node.Type is System.Type type) { - @throw.Type = this.VisitType(type); + @throw.Type = VisitType(type); } } else { - var unary = Unary.Create(this.Current, node.NodeType); + var unary = Unary.Create(Current, node.NodeType); - unary.Type = this.VisitType(node.Type); + unary.Type = VisitType(node.Type); - unary.Operand = this.VisitCacheParse(node.Operand); + unary.Operand = VisitCacheParse(node.Operand); if (node.Method is MethodInfo method) { - unary.Method = this.VisitMethod(method); + unary.Method = VisitMethod(method); } } return node; } - private Expression VisitCacheParse(Linq.Expression node) => Expression.Parse(this.VisitCache(node)); + private Expression VisitCacheParse(Linq.Expression node) => Expression.Parse(VisitCache(node)); - private NodeWithGraph VisitCache(Linq.Expression node) => this[this.Visit(node)]; + private NodeWithGraph VisitCache(Linq.Expression node) => this[Visit(node)]; private ArgumentInfo VisitArgumentInfo(string argument) { - using (this.Wrap(argument)) + using (Wrap(argument)) { - return new ArgumentInfo(this.Current); + return new ArgumentInfo(Current); } } private Binder VisitBinder(CallSiteBinder callSiteBinder) { - using (this.Wrap(callSiteBinder)) + using (Wrap(callSiteBinder)) { switch (callSiteBinder) { case InvokeMemberBinder invokeMember: - var invokeMemberBinder = new InvokeMember(this.Current) + var invokeMemberBinder = new InvokeMember(Current) { Name = invokeMember.Name, }; // Object member is invoked on - invokeMemberBinder.Arguments.Add(new ArgumentInfo(this[this.VisitArgumentInfo(string.Empty)])); + invokeMemberBinder.Arguments.Add(new ArgumentInfo(this[VisitArgumentInfo(string.Empty)])); foreach (var argument in invokeMember.CallInfo.ArgumentNames) { - invokeMemberBinder.Arguments.Add(new ArgumentInfo(this[this.VisitArgumentInfo(argument)])); + invokeMemberBinder.Arguments.Add(new ArgumentInfo(this[VisitArgumentInfo(argument)])); } return invokeMemberBinder; case BinaryOperationBinder binaryOperation: - var binaryOperationBinder = new BinaryOperation(this.Current) + var binaryOperationBinder = new BinaryOperation(Current) { - ExpressionType = this.VisitExpressionType(binaryOperation.Operation), + ExpressionType = VisitExpressionType(binaryOperation.Operation), }; // Left operand - binaryOperationBinder.Arguments.Add(new ArgumentInfo(this[this.VisitArgumentInfo(string.Empty)])); + binaryOperationBinder.Arguments.Add(new ArgumentInfo(this[VisitArgumentInfo(string.Empty)])); // Right operand - binaryOperationBinder.Arguments.Add(new ArgumentInfo(this[this.VisitArgumentInfo(string.Empty)])); + binaryOperationBinder.Arguments.Add(new ArgumentInfo(this[VisitArgumentInfo(string.Empty)])); return binaryOperationBinder; @@ -647,19 +647,19 @@ private Binder VisitBinder(CallSiteBinder callSiteBinder) private ExpressionType VisitExpressionType(Linq.ExpressionType expressionType) { - using (this.Wrap(expressionType)) + using (Wrap(expressionType)) { - return ExpressionType.Create(expressionType, this.node.Graph); + return ExpressionType.Create(expressionType, node.Graph); } } private Member VisitMember(MemberInfo member) { - using (this.Wrap(member)) + using (Wrap(member)) { - return new Member(this.Current) + return new Member(Current) { - Type = this.VisitType(member.DeclaringType), + Type = VisitType(member.DeclaringType), Name = member.Name, }; } @@ -667,17 +667,17 @@ private Member VisitMember(MemberInfo member) private Method VisitMethod(MethodInfo method) { - using (this.Wrap(method)) + using (Wrap(method)) { - var methodNode = new Method(this.Current) + var methodNode = new Method(Current) { - Type = this.VisitType(method.DeclaringType), + Type = VisitType(method.DeclaringType), Name = method.Name, }; foreach (var type in method.GetGenericArguments()) { - methodNode.TypeArguments.Add(this.VisitType(type)); + methodNode.TypeArguments.Add(VisitType(type)); } return methodNode; @@ -686,9 +686,9 @@ private Method VisitMethod(MethodInfo method) private SymbolDocument VisitSymbolDocument(Linq.SymbolDocumentInfo document) { - using (this.Wrap(document)) + using (Wrap(document)) { - return new SymbolDocument(this.Current) + return new SymbolDocument(Current) { FileName = document.FileName, Language = NullIfEmpty(document.Language), @@ -702,16 +702,16 @@ private SymbolDocument VisitSymbolDocument(Linq.SymbolDocumentInfo document) private Type VisitType(System.Type type) { - using (this.Wrap(type)) + using (Wrap(type)) { - var t = new Type(this.Current) + var t = new Type(Current) { Name = $"{type}, {type.Assembly}", }; foreach (var argument in type.GenericTypeArguments) { - t.Arguments.Add(this.VisitType(argument)); + t.Arguments.Add(VisitType(argument)); } return t; @@ -730,6 +730,6 @@ internal Wrapper(SerialisingVisitor visitor, NodeWithGraph node) this.visitor.path.Push(node); } - void IDisposable.Dispose() => this.visitor.path.Pop(); + void IDisposable.Dispose() => visitor.path.Pop(); } } diff --git a/GraphEngine/SymbolDocument.cs b/GraphEngine/SymbolDocument.cs index 3833e08..56d28ea 100644 --- a/GraphEngine/SymbolDocument.cs +++ b/GraphEngine/SymbolDocument.cs @@ -6,37 +6,37 @@ public class SymbolDocument(NodeWithGraph node) : Node(node) { public string FileName { - get => this.GetRequired(SymbolDocumentFileName, AsString); + get => GetRequired(SymbolDocumentFileName, AsString); - set => this.SetRequired(SymbolDocumentFileName, value); + set => SetRequired(SymbolDocumentFileName, value); } public Guid? Language { - get => this.GetOptionalS(SymbolDocumentLanguage, AsGuid); + get => GetOptionalS(SymbolDocumentLanguage, AsGuid); - set => this.SetOptional(SymbolDocumentLanguage, value); + set => SetOptional(SymbolDocumentLanguage, value); } public Guid? LanguageVendor { - get => this.GetOptionalS(SymbolDocumentLanguageVendor, AsGuid); + get => GetOptionalS(SymbolDocumentLanguageVendor, AsGuid); - set => this.SetOptional(SymbolDocumentLanguageVendor, value); + set => SetOptional(SymbolDocumentLanguageVendor, value); } public Guid? DocumentType { - get => this.GetOptionalS(SymbolDocumentDocumentType, AsGuid); + get => GetOptionalS(SymbolDocumentDocumentType, AsGuid); - set => this.SetOptional(SymbolDocumentDocumentType, value); + set => SetOptional(SymbolDocumentDocumentType, value); } public Linq.SymbolDocumentInfo LinqDocument => this switch { - { Language: Guid language, LanguageVendor: Guid languageVendor, DocumentType: Guid documentType } => Linq.Expression.SymbolDocument(this.FileName, language, languageVendor, documentType), - { Language: Guid language, LanguageVendor: Guid languageVendor } => Linq.Expression.SymbolDocument(this.FileName, language, languageVendor), - { Language: Guid language } => Linq.Expression.SymbolDocument(this.FileName, language), - _ => Linq.Expression.SymbolDocument(this.FileName) + { Language: Guid language, LanguageVendor: Guid languageVendor, DocumentType: Guid documentType } => Linq.Expression.SymbolDocument(FileName, language, languageVendor, documentType), + { Language: Guid language, LanguageVendor: Guid languageVendor } => Linq.Expression.SymbolDocument(FileName, language, languageVendor), + { Language: Guid language } => Linq.Expression.SymbolDocument(FileName, language), + _ => Linq.Expression.SymbolDocument(FileName) }; } diff --git a/GraphEngine/Target.cs b/GraphEngine/Target.cs index b30c46d..09d62a9 100644 --- a/GraphEngine/Target.cs +++ b/GraphEngine/Target.cs @@ -8,16 +8,16 @@ public class Target(NodeWithGraph node) : Node(node) public Type? Type { - get => this.GetOptional(TargetType, Type.Parse); + get => GetOptional(TargetType, Type.Parse); - set => this.SetOptional(TargetType, value); + set => SetOptional(TargetType, value); } public string? Name { - get => this.GetOptional(TargetName, AsString); + get => GetOptional(TargetName, AsString); - set => this.SetOptional(TargetName, value); + set => SetOptional(TargetName, value); } public Linq.LabelTarget LinqTarget @@ -28,9 +28,9 @@ public Linq.LabelTarget LinqTarget { Cache[this] = label = this switch { - { Type: not null, Name: not null } => Linq.Expression.Label(this.Type.SystemType, this.Name), - { Type: not null } => Linq.Expression.Label(this.Type.SystemType), - { Name: not null } => Linq.Expression.Label(this.Name), + { Type: not null, Name: not null } => Linq.Expression.Label(Type.SystemType, Name), + { Type: not null } => Linq.Expression.Label(Type.SystemType), + { Name: not null } => Linq.Expression.Label(Name), _ => Linq.Expression.Label() }; } diff --git a/GraphEngine/Type.cs b/GraphEngine/Type.cs index fb1338a..4da549a 100644 --- a/GraphEngine/Type.cs +++ b/GraphEngine/Type.cs @@ -6,22 +6,22 @@ public class Type(NodeWithGraph node) : Node(node) { public string Name { - get => this.GetRequired(TypeName, AsString); + get => GetRequired(TypeName, AsString); - set => this.SetRequired(TypeName, value); + set => SetRequired(TypeName, value); } - public ICollection Arguments => this.Collection(TypeArguments, Parse); + public ICollection Arguments => Collection(TypeArguments, Parse); public System.Type SystemType { get { - var t = System.Type.GetType(this.Name) ?? throw new InvalidOperationException($"Type {this.Name} not found."); + var t = System.Type.GetType(Name) ?? throw new InvalidOperationException($"Type {Name} not found."); if (t.IsGenericTypeDefinition) { - return t.MakeGenericType(this.Arguments.Select(arg => arg.SystemType).ToArray()); + return t.MakeGenericType(Arguments.Select(arg => arg.SystemType).ToArray()); } return t;