Skip to content

GU100 don't warn when generic #249

@JohanLarsson

Description

@JohanLarsson
        /// <summary>
        /// Same as DocumentEditor.ReplaceNode but nicer types.
        /// </summary>
        /// <typeparam name="T">The type of the node.</typeparam>
        /// <param name="editor">The <see cref="DocumentEditor"/>.</param>
        /// <param name="node">The <see cref="SyntaxNode"/>.</param>
        /// <param name="replacement">The replacement factory.</param>
        /// <returns>The <see cref="DocumentEditor"/> that was passed in.</returns>
        public static DocumentEditor ReplaceNode<T>(this DocumentEditor editor, T node, Func<T, SyntaxNode> replacement)
            where T : SyntaxNode
        {
            if (editor is null)
            {
                throw new ArgumentNullException(nameof(editor));
            }

            if (node is null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (replacement is null)
            {
                throw new ArgumentNullException(nameof(replacement));
            }

            editor.ReplaceNode(node, (x, _) => replacement((T)x));
            return editor;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions