private string GenerateClass(VsixManifest manifest)
        {
            var sb = new StringBuilder();

            sb.AppendLine($"// ------------------------------------------------------------------------------");
            sb.AppendLine($"// <auto-generated>");
            sb.AppendLine($"//     This file was generated by {Vsix.Name}");
            sb.AppendLine($"// </auto-generated>");
            sb.AppendLine($"// ------------------------------------------------------------------------------");

            sb.AppendLine($"namespace {FileNamespace}");
            sb.AppendLine("{");
            sb.AppendLine($"    internal sealed partial class Vsix");
            sb.AppendLine($"    {{");
            sb.AppendLine($"        public const string Id = \"{manifest.ID}\";");
            sb.AppendLine($"        public const string Name = \"{manifest.Name?.Replace("\\", "\\\\").Replace("\"", "\\\"")}\";");
            sb.AppendLine($"        public const string Description = @\"{manifest.Description}\";");
            sb.AppendLine($"        public const string Language = \"{manifest.Language}\";");
            sb.AppendLine($"        public const string Version = \"{manifest.Version}\";");
            sb.AppendLine($"        public const string Author = \"{manifest.Author?.Replace("\\", "\\\\").Replace("\"", "\\\"")}\";");
            sb.AppendLine($"        public const string Tags = \"{manifest.Tags?.Replace("\\", "\\\\").Replace("\"", "\\\"")}\";");
            sb.AppendLine($"    }}");
            sb.AppendLine("}");

            return(sb.ToString());
        }
        protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            VsixManifest manifest = VsixManifestParser.FromManifest(inputFileContent);
            string       code     = GenerateClass(manifest);

            return(Encoding.UTF8.GetBytes(code));
        }
        private string GenerateClass(VsixManifest manifest)
        {
            var sb = new StringBuilder();

            sb.AppendLine($"// ------------------------------------------------------------------------------");
            sb.AppendLine($"// <auto-generated>");
            sb.AppendLine($"//     This file was generated by {Vsix.Name}");
            sb.AppendLine($"//     Available from https://marketplace.visualstudio.com/items?itemName=MadsKristensen.VsixSynchronizer64");
            sb.AppendLine($"// </auto-generated>");
            sb.AppendLine($"// ------------------------------------------------------------------------------");

            sb.AppendLine($"namespace {FileNamespace}");
            sb.AppendLine("{");
            sb.AppendLine($"    internal sealed partial class Vsix");
            sb.AppendLine($"    {{");
            sb.AppendLine($"        public const string Id = \"{EscapeString(manifest.ID)}\";");
            sb.AppendLine($"        public const string Name = \"{EscapeString(manifest.Name)}\";");
            sb.AppendLine($"        public const string Description = @\"{EscapeVerbatimString(manifest.Description)}\";");
            sb.AppendLine($"        public const string Language = \"{EscapeString(manifest.Language)}\";");
            sb.AppendLine($"        public const string Version = \"{EscapeString(manifest.Version)}\";");
            sb.AppendLine($"        public const string Author = \"{EscapeString(manifest.Author)}\";");
            sb.AppendLine($"        public const string Tags = \"{EscapeString(manifest.Tags)}\";");
            sb.AppendLine($"    }}");
            sb.AppendLine("}");

            return(sb.ToString());
        }
Ejemplo n.º 4
0
 static void Vs2010Format(XmlDocument doc, VsixManifest manifest)
 {
     manifest.Author            = ParseNode(doc, "Author", true);
     manifest.Description       = ParseNode(doc, "Description", true);
     manifest.GettingStartedUrl = ParseNode(doc, "GettingStartedGuide", false);
     manifest.Icon            = ParseNode(doc, "Icon", false);
     manifest.ID              = ParseNode(doc, "Identifier", true, "Id");
     manifest.Language        = "en-US";
     manifest.License         = ParseNode(doc, "License", false);
     manifest.MoreInfoUrl     = ParseNode(doc, "MoreInfo", false);
     manifest.Name            = ParseNode(doc, "Name", true);
     manifest.Preview         = ParseNode(doc, "PreviewImage", false);
     manifest.ReleaseNotesUrl = ParseNode(doc, "ReleaseNotes", false);
     manifest.Version         = new Version(ParseNode(doc, "Version", true)).ToString();
 }
Ejemplo n.º 5
0
 private static void Vs2012Format(XmlDocument doc, VsixManifest manifest)
 {
     manifest.Author            = ParseNode(doc, "Identity", true, "Publisher");
     manifest.Description       = ParseNode(doc, "Description", true);
     manifest.GettingStartedUrl = ParseNode(doc, "GettingStartedGuide", false);
     manifest.Icon            = ParseNode(doc, "Icon", false);
     manifest.ID              = ParseNode(doc, "Identity", true, "Id");
     manifest.Language        = ParseNode(doc, "Identity", true, "Language");
     manifest.License         = ParseNode(doc, "License", false);
     manifest.MoreInfoUrl     = ParseNode(doc, "MoreInfo", false);
     manifest.Name            = ParseNode(doc, "DisplayName", true);
     manifest.Preview         = ParseNode(doc, "PreviewImage", false);
     manifest.ReleaseNotesUrl = ParseNode(doc, "ReleaseNotes", false);
     manifest.Tags            = ParseNode(doc, "Tags", false);
     manifest.Version         = new Version(ParseNode(doc, "Identity", true, "Version")).ToString();
 }
Ejemplo n.º 6
0
        public static VsixManifest FromManifest(string vsixManifestContent)
        {
            string xml = Regex.Replace(vsixManifestContent, "( xmlns(:\\w+)?)=\"([^\"]+)\"", string.Empty)
                         .Replace(" d:", " ");

            var doc = new XmlDocument();

            doc.LoadXml(xml);

            var package = new VsixManifest();

            if (doc.GetElementsByTagName("DisplayName").Count > 0)
            {
                Vs2012Format(doc, package);
            }
            else
            {
                Vs2010Format(doc, package);
            }

            return(package);
        }