Exemple #1
0
        private static SyntaxNode GetUpdatedNode(SyntaxNode node, SyntaxGenerator generator, string name)
        {
            return(node switch
            {
                // Many usages (constructing a type, casting to a type, etc.) will use a qualified name syntax
                // to refer to the type.
                var nameSyntax when nameSyntax.IsNameSyntax() => QualifiedNameBuilder.BuildQualifiedNameSyntax(generator, name),

                // Accessing a static member of a type will use a member access expression to refer to the type.
                var maeSyntax when maeSyntax.IsMemberAccessExpression() => QualifiedNameBuilder.BuildMemberAccessExpression(generator, name),

                // Because the node is retrieved by location, it may sometimes be necessary to check children.
                _ => GetUpdatedNode(node.ChildNodes().FirstOrDefault(), generator, name)
            });