Exemple #1
0
        public ImmutableTypeInfo GetImmutableTypeInfo(
            INamedTypeSymbol type
            )
        {
            // Check for [Immutable] etc.
            ImmutableTypeKind fromAttributes = GetImmutabilityFromAttributes(type);

            if (fromAttributes != ImmutableTypeKind.None)
            {
                return(ImmutableTypeInfo.Create(
                           annotationsContext: m_annotationsContext,
                           kind: fromAttributes,
                           type: type
                           ));
            }

            if (type.IsTupleType)
            {
                return(ImmutableTypeInfo.CreateWithAllConditionalTypeParameters(
                           kind: ImmutableTypeKind.Total,
                           type: type.OriginalDefinition
                           ));
            }

            // Check if we were otherwise told that this type is immutable
            if (m_extraImmutableTypes.TryGetValue(type.OriginalDefinition, out ImmutableTypeInfo info))
            {
                return(info);
            }

            return(ImmutableTypeInfo.Create(
                       annotationsContext: m_annotationsContext,
                       kind: ImmutableTypeKind.None,
                       type: type
                       ));
        }