Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mganss/XmlSchemaClassGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Dec 5, 2017
2 parents 790a656 + 446e601 commit d76ad43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static void Main(string[] args)
var codeTypeReferenceOptions = default(CodeTypeReferenceOptions);
string textValuePropertyName = "Value";
var generateDebuggerStepThroughAttribute = true;
var disableComments = false;

var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
Expand Down Expand Up @@ -74,7 +75,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
{ "ctro|codeTypeReferenceOptions=", "the default CodeTypeReferenceOptions Flags to use (default is unset; can be: {GlobalReference, GenericTypeParameter})", v => codeTypeReferenceOptions = v == null ? default(CodeTypeReferenceOptions) : (CodeTypeReferenceOptions)Enum.Parse(typeof(CodeTypeReferenceOptions), v, false) },
{ "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v },
{ "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null }
{ "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null },
{ "dc|disableComments", "do not include comments from xsd", v => disableComments = v != null },
};

var files = options.Parse(args);
Expand Down Expand Up @@ -116,7 +118,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
CollectionImplementationType = collectionImplementationType,
CodeTypeReferenceOptions = codeTypeReferenceOptions,
TextValuePropertyName = textValuePropertyName,
GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute
GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute,
DisableComments = disableComments
};

if (pclCompatible)
Expand All @@ -129,7 +132,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
}

if (verbose) { generator.Log = s => System.Console.Out.WriteLine(s); }

generator.Generate(files);
}

Expand Down
7 changes: 7 additions & 0 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ public Action<CodeTypeMember, PropertyModel> MemberVisitor
set { _configuration.MemberVisitor = value;}
}

public bool DisableComments
{
get { return _configuration.DisableComments; }
set { _configuration.DisableComments = value; }
}

private readonly XmlSchemaSet Set = new XmlSchemaSet();
private Dictionary<XmlQualifiedName, XmlSchemaAttributeGroup> AttributeGroups;
private Dictionary<XmlQualifiedName, XmlSchemaGroup> Groups;
Expand Down Expand Up @@ -242,6 +248,7 @@ private string ToTitleCase(string s)

private void BuildModel()
{
DocumentationModel.DisableComments = _configuration.DisableComments;
var objectModel = new SimpleModel(_configuration)
{
Name = "AnyType",
Expand Down
2 changes: 2 additions & 0 deletions XmlSchemaClassGenerator/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,7 @@ public void WriteLog(string message)
/// Provides options to customize Elementnamens with own logik
/// </summary>
public NamingProvider NamingProvider { get; set; }

public bool DisableComments { get; set; }
}
}
4 changes: 4 additions & 0 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ public class DocumentationModel
{
public string Language { get; set; }
public string Text { get; set; }
public static bool DisableComments { get; set; }

public static IEnumerable<CodeCommentStatement> GetComments(IEnumerable<DocumentationModel> docs)
{
if (DisableComments)
yield break;

yield return new CodeCommentStatement("<summary>", true);

foreach (var doc in docs.OrderBy(d => d.Language))
Expand Down

0 comments on commit d76ad43

Please sign in to comment.