Esempio n. 1
0
    private InstanceMemberInfo(
        ISymbol member,
        ITypeSymbol type,
        SyntaxToken identifier,
        Accessibility readAccessibility,
        bool isStatic)
    {
        _type = type;
        TypeFullyQualified = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
        TypeFullyQualifiedWithNullability = type.IsReferenceType && type.NullableAnnotation == NullableAnnotation.Annotated ? $"{TypeFullyQualified}?" : TypeFullyQualified;
        TypeMinimallyQualified            = type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat);

        _identifier  = identifier;
        ArgumentName = identifier.Text.MakeArgumentName();

        ReadAccessibility         = readAccessibility;
        IsStatic                  = isStatic;
        EnumMemberSettings        = EnumMemberSettings.Create(member);
        ValueObjectMemberSettings = ValueObjectMemberSettings.Create(member);

        foreach (var @interface in type.AllInterfaces)
        {
            if (@interface.IsFormattableInterface())
            {
                IsFormattable = true;
            }
            else if (@interface.IsComparableInterface(_type))
            {
                IsComparable = true;
            }
        }
    }
Esempio n. 2
0
    public override int GetHashCode()
    {
        unchecked
        {
            var hashCode = TypeFullyQualifiedWithNullability.GetHashCode();
            hashCode = (hashCode * 397) ^ Name.GetHashCode();
            hashCode = (hashCode * 397) ^ (int)ReadAccessibility;
            hashCode = (hashCode * 397) ^ IsStatic.GetHashCode();
            hashCode = (hashCode * 397) ^ IsReferenceType.GetHashCode();
            hashCode = (hashCode * 397) ^ _type.OriginalDefinition.SpecialType.GetHashCode();
            hashCode = (hashCode * 397) ^ SpecialType.GetHashCode();
            hashCode = (hashCode * 397) ^ IsFormattable.GetHashCode();
            hashCode = (hashCode * 397) ^ IsComparable.GetHashCode();
            hashCode = (hashCode * 397) ^ EnumMemberSettings.GetHashCode();
            hashCode = (hashCode * 397) ^ ValueObjectMemberSettings.GetHashCode();

            return(hashCode);
        }
    }
Esempio n. 3
0
    public bool Equals(InstanceMemberInfo?other)
    {
        if (ReferenceEquals(null, other))
        {
            return(false);
        }
        if (ReferenceEquals(this, other))
        {
            return(true);
        }

        return(TypeFullyQualifiedWithNullability == other.TypeFullyQualifiedWithNullability &&
               Name == other.Name &&
               ReadAccessibility == other.ReadAccessibility &&
               IsStatic == other.IsStatic &&
               IsReferenceType == other.IsReferenceType &&
               _type.OriginalDefinition.SpecialType == other._type.OriginalDefinition.SpecialType &&
               SpecialType == other.SpecialType &&
               IsFormattable == other.IsFormattable &&
               IsComparable == other.IsComparable &&
               EnumMemberSettings.Equals(other.EnumMemberSettings) &&
               ValueObjectMemberSettings.Equals(other.ValueObjectMemberSettings));
    }