< Summary

Information
Class: ZeroC.Slice.IActivator
Assembly: ZeroC.Slice
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/ZeroC.Slice/IActivator.cs
Tag: 275_13775359185
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 2
Total methods: 2
Method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FromAssembly(...)100%11100%
FromAssemblies(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/ZeroC.Slice/IActivator.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Reflection;
 4using ZeroC.Slice.Internal;
 5
 6namespace ZeroC.Slice;
 7
 8/// <summary>Provides methods that create class and exception instances from Slice type IDs.</summary>
 9/// <remarks>When decoding a Slice1-encoded buffer, a Slice decoder uses its activator to create a class or exception
 10/// instance before decoding the instance's fields.</remarks>
 11/// <seealso cref="SliceDecoder" />
 12public interface IActivator
 13{
 14    /// <summary>Gets or creates an activator for the Slice types in the specified assembly and its referenced
 15    /// assemblies.</summary>
 16    /// <param name="assembly">The assembly.</param>
 17    /// <returns>An activator that activates the Slice types defined in <paramref name="assembly" /> provided this
 18    /// assembly contains generated code (as determined by the presence of the <see cref="SliceAttribute" /> attribute).
 19    /// The Slice types defined in assemblies referenced by <paramref name="assembly" /> are included as well,
 20    /// recursively. If a referenced assembly contains no generated code, the assemblies it references are not examined.
 21    /// </returns>
 9822    public static IActivator FromAssembly(Assembly assembly) => ActivatorFactory.Instance.Get(assembly);
 23
 24    /// <summary>Gets or creates an activator for the Slice types defined in the specified assemblies and their
 25    /// referenced assemblies.</summary>
 26    /// <param name="assemblies">The assemblies.</param>
 27    /// <returns>An activator that activates the Slice types defined in <paramref name="assemblies" /> and their
 28    /// referenced assemblies. See <see cref="FromAssembly(Assembly)" />.</returns>
 29    public static IActivator FromAssemblies(params Assembly[] assemblies) =>
 430        Internal.Activator.Merge(assemblies.Select(ActivatorFactory.Instance.Get));
 31
 32    /// <summary>Creates an instance of a Slice class or Slice exception based on a type ID.</summary>
 33    /// <param name="typeId">The Slice type ID.</param>
 34    /// <returns>A new instance of the class identified by <paramref name="typeId" />, or null if the implementation
 35    /// cannot find the corresponding C# class.</returns>
 36    /// <remarks>This implementation of this method can also throw an exception if the class is found but the activation
 37    /// of an instance fails.</remarks>
 38    object? CreateInstance(string typeId);
 39}