< Summary

Information
Class: Elsa.Expressions.CSharp.Handlers.AddAssembliesAndReferencesFromOptions
Assembly: Elsa.Expressions.CSharp
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.CSharp/Handlers/AddAssembliesAndReferencesFromOptions.cs
Line coverage
42%
Covered lines: 3
Uncovered lines: 4
Coverable lines: 7
Total lines: 35
Line coverage: 42.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.CSharp/Handlers/AddAssembliesAndReferencesFromOptions.cs

#LineLine coverage
 1using Elsa.Expressions.CSharp.Notifications;
 2using Elsa.Expressions.CSharp.Options;
 3using Elsa.Mediator.Contracts;
 4using JetBrains.Annotations;
 5using Microsoft.CodeAnalysis.Scripting;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Expressions.CSharp.Handlers;
 9
 10/// <summary>
 11/// This handler adds assemblies and namespaces from the <see cref="CSharpOptions"/> to the <see cref="ScriptOptions"/>.
 12/// </summary>
 13[UsedImplicitly]
 14public class AddAssembliesAndReferencesFromOptions : INotificationHandler<EvaluatingCSharp>
 15{
 16    private readonly CSharpOptions _options;
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="AddAssembliesAndReferencesFromOptions"/> class.
 20    /// </summary>
 31921    public AddAssembliesAndReferencesFromOptions(IOptions<CSharpOptions> options)
 22    {
 31923        _options = options.Value;
 31924    }
 25
 26    /// <inheritdoc />
 27    public Task HandleAsync(EvaluatingCSharp notification, CancellationToken cancellationToken)
 28    {
 029        notification.ConfigureScriptOptions(scriptOptions => scriptOptions
 030            .AddReferences(_options.Assemblies)
 031            .AddImports(_options.Namespaces));
 32
 033        return Task.CompletedTask;
 34    }
 35}