6.2.5.53. Architecture-ActivateMembers

Add members to the entries view if they and their parent types satisfy specific rules

Required inputs: CSharpAST, RFG

This analysis adds nodes to the entries view: for each pair (P1, P2) in the list activate_patterns, P1(code_view, node) will be evaluated for each node in code_view; if True is returned, for every child child_node (also indirect ones and including node itself), P2(code_view, child_node) is evaluated; if it evaluates to True, child_node is added to entries_view.

The analysis also adds constructors of each type T to the entries view if there is a tuple (method_name, generic_arg_count, activated_arguments) in register_call_patterns for which there is an invocation of a method named method_name, with generic_arg_count many generic arguments, and T being a generic argument at one of the positions in activated_arguments.

E.g.: if ("Activate", 2, [0]) is a tuple in register_call_patterns, a call Activate(); causes the script to copy the constructors of T1 to the entries view; if we change [0] to [0,1], the constructors of T2 are copied as well.

Additionally, all constructors of all types that inherit from the type given in alive_type_name are added to the entries view.

Possible Messages

This rule has no predefined messages.

Options

activate_patterns

activate_patterns

Type: list[typing.Tuple[typing.Callable[[_dg.View, _dg.Node], bool], typing.Callable[[_dg.View, _dg.Node], bool]]]

Default: [(<function bauhaus.rules.axivion.csharp.activate_members.<lambda>(view, node)>, <function bauhaus.rules.axivion.csharp.activate_members.<lambda>(view, node)>)]

List of pairs of predicates (View X Node)->Bool; if the first predicate of a pair evaluates to True for a node in the code view, all children of the node (including the node itself) for which the second predicate evaluates to True are added to the entries view. The first argument of the predicate is always the code view.
 

alive_type

alive_type : str = ''

Types that inherit from this type are considered to be instantiated via dependency injection.
 

code_view_name

code_view_name : str = 'Code Facts'

The code view.
 

entries_view_name

entries_view_name : str = 'Entries'

The entries view.
 

export_warnings

export_warnings : bool = True

Export output messages to the analysis database.
 

loglevel

loglevel : LogLevel = 'WARNING'

Logging mode. WARNING only outputs errors and warnings, INFO additionally prints info messages, DEBUG additionally outputs info and debug messages.
 

register_call_patterns

register_call_patterns : list[typing.Tuple[str, int, typing.List[int]]] = []

List of tuples (method_name, generic_arg_count, activated_arguments); if there is an invocation of a method named method_name, with generic_arg_count many generic arguments, then the constructors of each generic argument are copied to the entries view if the argument's position is in activated_arguments. E.g.: if the option contains ("Activate", 2, [0]), then a call Activate(); causes the rule to copy the constructors of T1 to the entries view; if [0] is changed to [0,1], then the constructors of T2 are copied as well.
 

Option Types

These types are used by options listed above:

LogLevel

An enumeration.
 
  • WARNING

  • INFO

  • DEBUG