예제 #1
0
        private static bool IsValueTypeFieldsShallowCopyable(WellKnownTypes wellKnownTypes, ITypeSymbol type, HashSet <ITypeSymbol> examining)
        {
            foreach (var field in type.GetInstanceMembers <IFieldSymbol>())
            {
                if (field.IsStatic)
                {
                    continue;
                }

                if (!(field.Type is INamedTypeSymbol fieldType))
                {
                    return(false);
                }

                if (type.Equals(fieldType))
                {
                    return(false);
                }

                if (!IsOrleansShallowCopyable(wellKnownTypes, fieldType, examining))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #2
0
        private static bool IsValueTypeFieldsShallowCopyable(WellKnownTypes wellKnownTypes, ITypeSymbol type, HashSet <ITypeSymbol> examining)
        {
            foreach (var field in type.GetAllMembers <IFieldSymbol>())
            {
                if (!(field.Type is INamedTypeSymbol fieldType))
                {
                    throw new NotSupportedException(
                              $"Field {field} in type {type} is not an {nameof(INamedTypeSymbol)} and therefore is not supported. Type is {field.Type.GetType()}");
                }

                if (type.Equals(fieldType))
                {
                    return(false);
                }

                if (!IsOrleansShallowCopyable(wellKnownTypes, fieldType, examining))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #3
0
        public bool ShouldPreferExplicitType(VBSyntax.ExpressionSyntax exp,
                                             ITypeSymbol expConvertedType,
                                             out bool isNothingLiteral)
        {
            var op = _semanticModel.GetExpressionOperation(exp);

            exp = op.Syntax as VBSyntax.ExpressionSyntax;
            var vbInitConstantValue = _semanticModel.GetConstantValue(exp);

            isNothingLiteral = vbInitConstantValue.HasValue && vbInitConstantValue.Value == null || exp is VBSyntax.LiteralExpressionSyntax les && les.IsKind(SyntaxKind.NothingLiteralExpression);
            bool shouldPreferExplicitType = expConvertedType != null && (expConvertedType.HasCsKeyword() || !expConvertedType.Equals(op.Type));

            return(shouldPreferExplicitType);
        }