private static SyntaxList <AttributeListSyntax> FixRemappedAttributes(
                SyntaxList <AttributeListSyntax> existingAttrList,
                List <AttributeSyntax> remappedListAttributes,
                AttributeTargetSpecifierSyntax target)
            {
                if (remappedListAttributes == null)
                {
                    return(existingAttrList);
                }

                foreach (var attrNode in remappedListAttributes)
                {
                    var attrName = attrNode.Name.ToString();
                    if (attrName.EndsWith(EncodeHelpers.AttributeToRemoveSuffix))
                    {
                        var attrNameToRemove = attrName.Substring(0, attrName.Length - EncodeHelpers.AttributeToRemoveSuffix.Length);

                        existingAttrList = SyntaxUtils.RemoveAttribute(existingAttrList, attrNameToRemove);
                    }
                    else
                    {
                        // Remove any existing attribute with the same name
                        existingAttrList = SyntaxUtils.RemoveAttribute(existingAttrList, attrName);

                        var attrListNode =
                            SyntaxFactory.AttributeList(
                                SyntaxFactory.SingletonSeparatedList <AttributeSyntax>(attrNode));
                        if (target != null)
                        {
                            attrListNode = attrListNode.WithTarget(target);
                        }

                        existingAttrList = existingAttrList.Add(attrListNode);
                    }
                }

                return(existingAttrList);
            }