Beispiel #1
0
        private static bool CanReplaceWithReducedNameInContext(this NameSyntax name, TypeSyntax reducedName, SemanticModel semanticModel, CancellationToken cancellationToken)
        {
            // Special case.  if this new minimal name parses out to a predefined type, then we
            // have to make sure that we're not in a using alias. That's the one place where the
            // language doesn't allow predefined types. You have to use the fully qualified name
            // instead.
            var invalidTransformation1  = IsNonNameSyntaxInUsingDirective(name, reducedName);
            var invalidTransformation2  = WillConflictWithExistingLocal(name, reducedName);
            var invalidTransformation3  = IsAmbiguousCast(name, reducedName);
            var invalidTransformation4  = IsNullableTypeInPointerExpression(name, reducedName);
            var isNotNullableReplacable = name.IsNotNullableReplacable(reducedName);

            if (invalidTransformation1 || invalidTransformation2 || invalidTransformation3 || invalidTransformation4 ||
                isNotNullableReplacable)
            {
                return(false);
            }

            return(true);
        }