6.1.2.1. AxivionC#Frontend

Use Axivion C# compiler for analysis compilation

Compiles a given input and (optionally) creates a C# package (.cspkg), which can be used in an independent Axivion analysis, without having to rebuild.

The input parameters can be configured in two ways:

  1. One or more loose C# files without a project:

    • The primary input should point to a .cs file or a folder containing one or more .cs files.
    • The option build_target_framework is mandatory in this case and must specify the target framework name that should be used. This should be in sync with the framework_path option.
    • The option project_is_library indicates whether the input should be compiled as library, i.e., if any of the input files contains a usable Main method, this property should be set to false, otherwise to true.
    • The option framework_path can used to set the framework directory to be used. Defaults to .NET 8.0.
    • The option references can be used to pass additional references that should be included in the compilation.
  2. A MSBuild-based C# project, solution or solution filter:

Options

The following places define options that affect this rule: BuildSystemIntegration, Project-GlobalOptions

abort_on_error

abort_on_error : bool = True

If set to true and the build step returns a non-zero exit-code, the build is aborted. Otherwise a non-zero exit-code is logged but the build continues.
 

base_path

base_path : bauhaus.analysis.config.PlainPath | None = None

All paths referencing source files in the output of AxivionC#Frontend (i.e., RFG or C# package or analysis results) are stored relative to this path. Defaults to the location of the primary input (see input).
 

binarylog

binarylog : bauhaus.analysis.config.PlainPath | None = None

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

If set, a MSBuild binlog will be produced for each project that is processed by this step. This is useful for diagnosing issues with how AxivionC#Frontend processes projects. The generated .binlog file(s) can be viewed using the (third-party) MSBuild Structured Log Viewer, which can be obtained from https://msbuildlog.com/.

 

build_configuration

build_configuration : str | None = None

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Build configuration to use for compilation.

 

build_in_parallel

build_in_parallel : bool = False

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview. Whether to run msbuild in parallel using the number of processor cores on a machine.
 

build_platform

build_platform : str | None = None

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Build platform to use for compilation.

 

build_target_framework

build_target_framework : str | None = None

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Build target framework to use for compilation. If left unspecified, attempt to detect it automatically.

 

build_targets

build_targets : list[str] = ['Clean', 'Build']

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Build targets to invoke. Multiple values can be specified separated by comma or semi-colon. Defaults to Clean, Build.

 

bytecode_analysis

bytecode_analysis : bool = False

If set, the byte-code of binary references will be analyzed and included in the RFG.
 

create_multiple_edges

create_multiple_edges : bool = False

If set, all source dependencies are reflected by edges (even if this means that there are multiple edges of the same edge descriptor type).

Warning: This cannot be set in a CI context (i.e. when using axivion_ci).

 

cwd

cwd : bauhaus.analysis.config.ProjectRelativePath | None = None

Directory for execution of tool csharp2rfg. Defaults to /Project/directory if left unspecified.
 

framework_path

framework_path : bauhaus.analysis.config.PlainPath | None = None

Note: This option is NOT applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Should point to the directory containing all framework assemblies in the .NET (Core) SDK or .NET Framework installation. Defaults to the version of .NET used to run csharp2rfg

 

input

input : bauhaus.analysis.config.ProjectRelativePath = 'None (value must be set)'

The input of this build step. Can be one of the following:
  • MSBuild solution file (.sln),
  • MSBuild solution filter file (.slnf),
  • MSBuild C# project file (.csproj),
  • A single C# source file (.cs)
  • or a folder containing one or more C# source files.
 

msbuild_path

msbuild_path : bauhaus.analysis.config.PlainPath | None = None

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Sets the path to the version of MSBuild to be used to load the solution/project. This should point directly to MSBuild.exe (or MSBuild.dll for .NET (Core) SDKs) that is used to build the solution or project.

 

no_restore

no_restore : bool = False

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

If set, no NuGet package restore will be performed.

 

only_used_types

only_used_types : bool = False

If set, only types defined in source code and their direct dependencies will be included in the RFG.
 

output

output : bauhaus.analysis.config.ProjectRelativePath | None = None

The file name of the C# package (.cspkg) output produced by this build step.
 

project_is_library

project_is_library : bool = False

Note: This option is NOT applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Use this flag to indicate, whether the result is a library or executable binary, i.e., has a Main method/entry-point.

 

properties

properties : dict[str, str] = {}

Note: This option is ONLY applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Additional MSBuild properties to use for compilation. They can be used to fine-tune the build process.

Properties that are useful when working with csharp2rfg:

  • RunAnalyzers: Set this to false to prevent execution of third-party analyzers during the analysis build.
  • RunAnalyzersDuringBuild: Set this to false to prevent execution of third-party analyzers during the analysis build.
 

references

references : list[str] = []

Note: This option is NOT applicable, if AxivionC#Frontend is configured with a project or solution (filter). See the rule description for an overview.

Binary references (.dll) to use for compilation.