< Summary

Class:NanoCLang.Entities.TypeParameter
Assembly:NanoCLang
File(s):C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\TypeParameter.cs
Covered lines:19
Uncovered lines:4
Coverable lines:23
Total lines:53
Line coverage:82.6% (19 of 23)
Covered branches:10
Total branches:12
Branch coverage:83.3% (10 of 12)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
.ctor(...)100%1100%
get_Name()100%1100%
get_Type()100%1100%
Tokens()100%6100%
Tokens()100%2100%
Equals(...)100%10%
Equals(...)50%4100%
GetHashCode()100%10%
op_Equality(...)100%10%
op_Inequality(...)100%10%

File(s)

C:\GitLab-Runner\builds\JxAESPd8\0\chenmichael\nanoc\src\NanoCLang\Entities\TypeParameter.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3
 4namespace NanoCLang.Entities {
 5    /// <summary>
 6    /// Provides a class for type parameters binding a type to a name.
 7    /// </summary>
 8    public class TypeParameter : Base, IEquatable<TypeParameter?> {
 9        /// <summary>
 10        /// Creates a new type parameter instance binding the <paramref name="type"/> to the <paramref name="name"/>.
 11        /// </summary>
 12        /// <param name="name">Name that the <paramref name="type"/> is bound to.</param>
 13        /// <param name="type">Type that is bound to the <paramref name="name"/>.</param>
 14214        public TypeParameter(string name, Type type) {
 7115            Name = name;
 7116            Type = type;
 7117        }
 18        /// <summary>
 19        /// Name that the <see cref="Type"/> is bound to.
 20        /// </summary>
 27421        public string Name { get; }
 22        /// <summary>
 23        /// Type that is bound to the <see cref="Name"/>.
 24        /// </summary>
 26125        public Type Type { get; }
 26        /// <inheritdoc/>
 3627        public override IEnumerable<StringFormatterToken> Tokens(NanoCSourceFormat args) {
 3628            yield return Name;
 7229            if (args.SpaceBeforeTypeOperator) yield return " ";
 3630            yield return ":";
 7231            if (args.SpaceAfterTypeOperator) yield return " ";
 228032            foreach (var tk in Type.Tokens(args)) yield return tk;
 3633        }
 34        /// <inheritdoc/>
 2635        public override IEnumerable<StringFormatterToken> Tokens(CSourceFormat args) {
 17136            foreach (var tk in Type.Tokens(args)) yield return tk;
 2637            yield return " ";
 2638            yield return Name;
 2639        }
 40        #region Equality checks
 41        /// <inheritdoc/>
 042        public override bool Equals(object? obj) => Equals(obj as TypeParameter);
 43        /// <inheritdoc/>
 3644        public bool Equals(TypeParameter? other) => !(other is null) && Name == other.Name && EqualityComparer<Type>.Def
 45        /// <inheritdoc/>
 046        public override int GetHashCode() => System.HashCode.Combine(Name, Type);
 47        /// <inheritdoc/>
 048        public static bool operator ==(TypeParameter? left, TypeParameter? right) => EqualityComparer<TypeParameter?>.De
 49        /// <inheritdoc/>
 050        public static bool operator !=(TypeParameter? left, TypeParameter? right) => !(left == right);
 51        #endregion
 52    }
 53}