Skip to content

Commit

Permalink
Merge pull request #15 from dafanasiev/master
Browse files Browse the repository at this point in the history
Add optional "codeTypeReferenceOptions" options to support type reference generation with "global::" prefix
  • Loading branch information
mganss authored Jul 13, 2016
2 parents 38c2ceb + a840e58 commit 9f2fd42
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 42 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ Options:
--cit, --collectionImplementationType=VALUE
the default collection type implementation to use (
default is null)
--ctro, --codeTypeReferenceOptions=VALUE
the default CodeTypeReferenceOptions Flags to use (
default is unset;
can be: {GlobalReference, GenericTypeParameter})
```

From code:
Expand Down
6 changes: 5 additions & 1 deletion XmlSchemaClassGenerator.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using XmlSchemaClassGenerator;
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
Expand Down Expand Up @@ -30,6 +31,7 @@ static void Main(string[] args)
var pascal = true;
var collectionType = typeof(Collection<>);
Type collectionImplementationType = null;
var codeTypeReferenceOptions = default(CodeTypeReferenceOptions);

var options = new OptionSet {
{ "h|help", "show this message and exit", v => showHelp = v != null },
Expand Down Expand Up @@ -68,6 +70,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
{ "a|pascal", "use Pascal case for class and property names (default is enabled)", v => pascal = v != null },
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
{ "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) }
};

var files = options.Parse(args);
Expand Down Expand Up @@ -104,7 +107,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
GenerateInterfaces = interfaces,
NamingScheme = pascal ? NamingScheme.PascalCase : NamingScheme.Direct,
CollectionType = collectionType,
CollectionImplementationType = collectionImplementationType
CollectionImplementationType = collectionImplementationType,
CodeTypeReferenceOptions = codeTypeReferenceOptions
};

if (pclCompatible)
Expand Down
6 changes: 6 additions & 0 deletions XmlSchemaClassGenerator/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public bool GenerateInterfaces
set { _configuration.GenerateInterfaces = value; }
}

public CodeTypeReferenceOptions CodeTypeReferenceOptions
{
get { return _configuration.CodeTypeReferenceOptions; }
set { _configuration.CodeTypeReferenceOptions = value; }
}

private readonly XmlSchemaSet Set = new XmlSchemaSet();
private Dictionary<XmlQualifiedName, XmlSchemaAttributeGroup> AttributeGroups;
private Dictionary<XmlQualifiedName, XmlSchemaGroup> Groups;
Expand Down
6 changes: 6 additions & 0 deletions XmlSchemaClassGenerator/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
Expand Down Expand Up @@ -106,6 +107,11 @@ public GeneratorConfiguration()
/// </summary>
public bool GenerateInterfaces { get; set; }

/// <summary>
/// Generator Code reference options
/// </summary>
public CodeTypeReferenceOptions CodeTypeReferenceOptions { get; set; }

/// <summary>
/// Provides a fast and safe way to write to the Log
/// </summary>
Expand Down
Loading

0 comments on commit 9f2fd42

Please sign in to comment.