Skip to content
| Marketplace
Sign in
Visual Studio>Tools>XmlCodeGenerator
XmlCodeGenerator

XmlCodeGenerator

SeongTae Jeong

|
7,293 installs
| (3) | Free
Auto-generates source code with XML + XSLT
Download

XmlCodeGeneartor

Introduce

C#/VB.NET code can be generated by XML + XSLT.

What's New

v1.0: Initial checked-in.

v1.1: Add support for Visual Studio 2015

v1.2: Add support for Visual Studio 2017

v1.3: Add support for Visual Studio 2019

v1.4: Add support for Visual Studio 2022 (Preview)

v1.6: Only support for Visual Studio 2022

How to use

  1. Create your own XML file in your project. For example,
<IFs>     
    <DOIT condition="1" />
    <DOIT condition="2" />
    <DOIT condition="3" />
    <DOIT condition="4" />
    <DOIT condition="5" />
</IFs>
  1. Create your own XSLT file in the same directory of XML. You can write XSLT to produce source codes on XML. For example,
<?xml version="1.0" encoding="UTF-8" ?>
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="text"  encoding="utf-8" indent="yes"></output>
<template match="IFs">
        using System;
        using System.Collections.Generic;
        using System.Text;
        namespace macroTest
        {
            public partial class Test
            {
                 private void DoIt(int condition)
                 {
                     <apply-templates select="//DOIT"></apply-templates>
                 }
             }
         }
     </template>
      <template match="//DOIT">
         if (condition == <value-of select="@condition"/>)
         {
             funcName_<value-of select="@condition"/>();
         }
     </template>
</stylesheet>
  1. Finally, select Xml file and type 'XmlCodeGenerator' on 'Custom Tool' in properties.

https://sysnetblobaccount.blob.core.windows.net/sysnetimages/xml_xslt.png

  1. Now, whenever you save xml file, [xml-filename].cs file will be generated by combining with XSLT. For example,
     using System;
     using System.Collections.Generic;
     using System.Text;
     namespace macroTest
     {
         public partial class Test
         {
             private void DoIt(int condition)
             {
                  if (condition == 1)
                  {
                      funcName_1();
                  }
                    // .........[repeat]..........
             }
         }
     }

Source Code

Project site: https://github.com/stjeong/XmlCodeGenerator

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft