/// <inheritdoc/> public override SyntaxNode?VisitIdentifierName(IdentifierNameSyntax node) { if (node.Parent is QualifiedNameSyntax) { return(base.VisitIdentifierName(node)); } SymbolInfo info = SemanticModel.GetSymbolInfo(node); if (info.Symbol is not INamedTypeSymbol symbol) { return(base.VisitIdentifierName(node)); } string[] namespaces = symbol.GetContainingNamespacesAndTypes().Select(n => n.Name).ToArray(); if (namespaces.Length == 0) { return(base.VisitIdentifierName(node)); } else if (namespaces.Length == 1) { return(QualifiedName(IdentifierName(namespaces[0]), node.WithoutTrivia()).WithTriviaFrom(node)); } else { return(QualifiedName(AnalysisUtilities.JoinIntoQualifiedName(namespaces) !, node.WithoutTrivia()).WithTriviaFrom(node)); } }
/// <summary> /// Returns a <see cref="string"/> representing the fully qualified name of the <paramref name="member"/> that can be used in the XML documentation. /// </summary> /// <param name="member"><see cref="IMemberData"/> to get the fully qualified name of.</param> /// <exception cref="ArgumentNullException"><paramref name="member"/> is <see langword="null"/>.</exception> public static string GetXmlFullyQualifiedName(this IMemberData member) { if (member is null) { throw new ArgumentNullException(nameof(member)); } return(AnalysisUtilities.ConvertFullyQualifiedNameToXml(member.Symbol.ToString())); }
/// <inheritdoc/> public override SyntaxNode?VisitQualifiedName(QualifiedNameSyntax node) { TypeInfo info = SemanticModel.GetTypeInfo(node); if (info.Type is not INamedTypeSymbol symbol) { return(base.VisitQualifiedName(node)); } string[] namespaces = symbol.GetContainingNamespacesAndTypes().Select(n => n.Name).ToArray(); if (namespaces.Length < 2) { return(base.VisitQualifiedName(node)); } else { return(QualifiedName(AnalysisUtilities.JoinIntoQualifiedName(namespaces) !, node.Right.WithoutTrivia()).WithTriviaFrom(node)); } }
/// <inheritdoc/> public override SyntaxNode?VisitGenericName(GenericNameSyntax node) { if (node.Parent is QualifiedNameSyntax) { return(base.VisitGenericName(node)); } TypeInfo info = SemanticModel.GetTypeInfo(node); if (info.Type is not INamedTypeSymbol symbol) { return(base.VisitGenericName(node)); } string[] namespaces = symbol.GetContainingNamespacesAndTypes().Select(n => n.Name).ToArray(); if (namespaces.Length == 0) { return(base.VisitGenericName(node)); } else { TypeArgumentListSyntax arguments = (TypeArgumentListSyntax)VisitTypeArgumentList(node.TypeArgumentList) !.WithoutTrivia(); GenericNameSyntax name = node.WithTypeArgumentList(arguments).WithoutTrivia(); if (namespaces.Length == 1) { return(QualifiedName(IdentifierName(namespaces[0]), name).WithTriviaFrom(node)); } else { return(QualifiedName(AnalysisUtilities.JoinIntoQualifiedName(namespaces) !, name).WithTriviaFrom(node)); } } }
/// <summary> /// Initializes a new instance of the <see cref="MemberData"/> class. /// </summary> /// <param name="declaration"><see cref="MemberDeclarationSyntax"/> this <see cref="MemberData"/> represents.</param> /// <param name="compilation">Parent <see cref="ICompilationData"/> of this <see cref="MemberData"/>.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="declaration"/> is <see langword="null"/>. -or- <paramref name="compilation"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// Specified <paramref name="declaration"/> doesn't represent any symbols. /// </exception> public MemberData(MemberDeclarationSyntax declaration, ICompilationData compilation) { (SemanticModel, Symbol) = AnalysisUtilities.GetSymbolAndSemanticModel(declaration, compilation); Declaration = declaration; ParentCompilation = compilation; }
/// <summary> /// Returns a <see cref="string"/> that contains all the parent types of the specified <paramref name="member"/> and the <paramref name="member"/>'s separated by the dot ('.') character. Can be used in XML documentation. /// </summary> /// <param name="member"><see cref="IMemberData"/> to get the <see cref="string"/> of.</param> /// <param name="includeParameters">If the value of the <see cref="IMemberData.Symbol"/> property of the <paramref name="member"/> parameter is a <see cref="IMethodSymbol"/>, determines whether to include the method's parameters in the returned <see cref="string"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="member"/> is <see langword="null"/>.</exception> public static string GetXmlParentTypesString(this IMemberData member, bool includeParameters = false) { string parentString = GetParentTypesString(member, includeParameters); return(AnalysisUtilities.ConvertFullyQualifiedNameToXml(parentString)); }
private static bool IsValidTargetNamespace(string?targetNamespace) { return(AnalysisUtilities.IsValidNamespaceIdentifier(targetNamespace) && targetNamespace != "Durian.Generator"); }