Skip to content

Commit 6ccc105

Browse files
authored
Merge pull request #26 from atheck/master
Order for Any Attribute, optional DebuggerStepThroughAttribute
2 parents d94aead + 0a43907 commit 6ccc105

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

XmlSchemaClassGenerator.Console/Program.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static void Main(string[] args)
3333
Type collectionImplementationType = null;
3434
var codeTypeReferenceOptions = default(CodeTypeReferenceOptions);
3535
string textValuePropertyName = "Value";
36+
var generateDebuggerStepThroughAttribute = true;
3637

3738
var options = new OptionSet {
3839
{ "h|help", "show this message and exit", v => showHelp = v != null },
@@ -72,7 +73,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
7273
{ "ct|collectionType=", "collection type to use (default is " + typeof(Collection<>).FullName + ")", v => collectionType = v == null ? typeof(Collection<>) : Type.GetType(v, true) },
7374
{ "cit|collectionImplementationType=", "the default collection type implementation to use (default is null)", v => collectionImplementationType = v == null ? null : Type.GetType(v, true) },
7475
{ "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) },
75-
{ "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v }
76+
{ "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v },
77+
{ "dst|debuggerStepThrough", "generate DebuggerStepThroughAttribute (default is enabled)", v => generateDebuggerStepThroughAttribute = v != null }
7678
};
7779

7880
var files = options.Parse(args);
@@ -113,14 +115,16 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l
113115
CollectionType = collectionType,
114116
CollectionImplementationType = collectionImplementationType,
115117
CodeTypeReferenceOptions = codeTypeReferenceOptions,
116-
TextValuePropertyName = textValuePropertyName
118+
TextValuePropertyName = textValuePropertyName,
119+
GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute
117120
};
118121

119122
if (pclCompatible)
120123
{
121124
generator.UseXElementForAny = true;
122125
generator.GenerateDesignerCategoryAttribute = false;
123126
generator.GenerateSerializableAttribute = false;
127+
generator.GenerateDebuggerStepThroughAttribute = false;
124128
generator.DataAnnotationMode = DataAnnotationMode.None;
125129
}
126130

XmlSchemaClassGenerator/Generator.cs

+6
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public bool GenerateSerializableAttribute
103103
set { _configuration.GenerateSerializableAttribute = value; }
104104
}
105105

106+
public bool GenerateDebuggerStepThroughAttribute
107+
{
108+
get { return _configuration.GenerateDebuggerStepThroughAttribute; }
109+
set { _configuration.GenerateDebuggerStepThroughAttribute = value; }
110+
}
111+
106112
public bool GenerateDesignerCategoryAttribute
107113
{
108114
get { return _configuration.GenerateDesignerCategoryAttribute; }

XmlSchemaClassGenerator/GeneratorConfiguration.cs

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ public GeneratorConfiguration()
8383
/// </summary>
8484
public bool GenerateSerializableAttribute { get; set; }
8585
/// <summary>
86+
/// Generate the DebuggerStepThroughAttribute?
87+
/// </summary>
88+
public bool GenerateDebuggerStepThroughAttribute { get; set; }
89+
/// <summary>
8690
/// Generate the DesignerCategoryAttribute?
8791
/// </summary>
8892
public bool GenerateDesignerCategoryAttribute { get; set; }

XmlSchemaClassGenerator/TypeModel.cs

+12-4
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,10 @@ public override CodeTypeDeclaration Generate()
361361
classDeclaration.Members.Add(text);
362362
}
363363

364-
classDeclaration.CustomAttributes.Add(
365-
new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerStepThroughAttribute), Configuration.CodeTypeReferenceOptions)));
364+
if (Configuration.GenerateDebuggerStepThroughAttribute)
365+
classDeclaration.CustomAttributes.Add(
366+
new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerStepThroughAttribute), Configuration.CodeTypeReferenceOptions)));
367+
366368
if (Configuration.GenerateDesignerCategoryAttribute)
367369
{
368370
classDeclaration.CustomAttributes.Add(
@@ -864,7 +866,10 @@ private IEnumerable<CodeAttributeDeclaration> GetAttributes(bool isArray)
864866
{
865867
if (IsAny)
866868
{
867-
attributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyAttributeAttribute), Configuration.CodeTypeReferenceOptions)));
869+
var anyAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyAttributeAttribute), Configuration.CodeTypeReferenceOptions));
870+
if (Order != null)
871+
anyAttribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(Order.Value)));
872+
attributes.Add(anyAttribute);
868873
}
869874
else
870875
{
@@ -876,7 +881,10 @@ private IEnumerable<CodeAttributeDeclaration> GetAttributes(bool isArray)
876881
{
877882
if (IsAny)
878883
{
879-
attributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyElementAttribute), Configuration.CodeTypeReferenceOptions)));
884+
var anyAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyElementAttribute), Configuration.CodeTypeReferenceOptions));
885+
if (Order != null)
886+
anyAttribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(Order.Value)));
887+
attributes.Add(anyAttribute);
880888
}
881889
else
882890
{

0 commit comments

Comments
 (0)