Пример #1
0
        private bool IsImmutableOrValidMutableType(ITypeSymbol typeSymbol, ExpressionSyntax value = null)
        {
            if (value.IsNullLiteral())
            {
                return(true);
            }

            if (typeSymbol is INamedTypeSymbol namedTypeSymbol)
            {
                typeSymbol = namedTypeSymbol.ConstructedFrom;
            }

            return(!typeSymbol.DerivesOrImplementsAny(MutableBaseTypes) ||
                   typeSymbol.DerivesOrImplementsAny(ImmutableBaseTypes));
        }
Пример #2
0
 private static bool IsOrDerivesOrImplementsAny(ITypeSymbol typeSymbol, ISet <KnownType> knownTypes)
 {
     return(typeSymbol.IsAny(knownTypes) ||
            typeSymbol.DerivesOrImplementsAny(knownTypes));
 }