diff --git a/XmlSchemaClassGenerator.Console/Program.cs b/XmlSchemaClassGenerator.Console/Program.cs index d7ab27b1..4ef476fc 100644 --- a/XmlSchemaClassGenerator.Console/Program.cs +++ b/XmlSchemaClassGenerator.Console/Program.cs @@ -33,6 +33,7 @@ static void Main(string[] args) Type collectionImplementationType = null; var codeTypeReferenceOptions = default(CodeTypeReferenceOptions); string textValuePropertyName = "Value"; + var generateDebuggerStepThroughAttribute = true; var options = new OptionSet { { "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 { "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) }, - { "tvpn|textValuePropertyName=", "the name of the property that holds the text value of an element (default is Value)", v => textValuePropertyName = v } + { "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 } }; var files = options.Parse(args); @@ -113,7 +115,8 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l CollectionType = collectionType, CollectionImplementationType = collectionImplementationType, CodeTypeReferenceOptions = codeTypeReferenceOptions, - TextValuePropertyName = textValuePropertyName + TextValuePropertyName = textValuePropertyName, + GenerateDebuggerStepThroughAttribute = generateDebuggerStepThroughAttribute }; if (pclCompatible) @@ -121,6 +124,7 @@ A file name may be given by appending a pipe sign (|) followed by a file name (l generator.UseXElementForAny = true; generator.GenerateDesignerCategoryAttribute = false; generator.GenerateSerializableAttribute = false; + generator.GenerateDebuggerStepThroughAttribute = false; generator.DataAnnotationMode = DataAnnotationMode.None; } diff --git a/XmlSchemaClassGenerator/Generator.cs b/XmlSchemaClassGenerator/Generator.cs index b8f5807a..bece22f1 100644 --- a/XmlSchemaClassGenerator/Generator.cs +++ b/XmlSchemaClassGenerator/Generator.cs @@ -103,6 +103,12 @@ public bool GenerateSerializableAttribute set { _configuration.GenerateSerializableAttribute = value; } } + public bool GenerateDebuggerStepThroughAttribute + { + get { return _configuration.GenerateDebuggerStepThroughAttribute; } + set { _configuration.GenerateDebuggerStepThroughAttribute = value; } + } + public bool GenerateDesignerCategoryAttribute { get { return _configuration.GenerateDesignerCategoryAttribute; } diff --git a/XmlSchemaClassGenerator/GeneratorConfiguration.cs b/XmlSchemaClassGenerator/GeneratorConfiguration.cs index abf55c49..2d23919e 100644 --- a/XmlSchemaClassGenerator/GeneratorConfiguration.cs +++ b/XmlSchemaClassGenerator/GeneratorConfiguration.cs @@ -83,6 +83,10 @@ public GeneratorConfiguration() /// public bool GenerateSerializableAttribute { get; set; } /// + /// Generate the DebuggerStepThroughAttribute? + /// + public bool GenerateDebuggerStepThroughAttribute { get; set; } + /// /// Generate the DesignerCategoryAttribute? /// public bool GenerateDesignerCategoryAttribute { get; set; } diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs index f842388e..7f45f5e4 100644 --- a/XmlSchemaClassGenerator/TypeModel.cs +++ b/XmlSchemaClassGenerator/TypeModel.cs @@ -361,8 +361,10 @@ public override CodeTypeDeclaration Generate() classDeclaration.Members.Add(text); } - classDeclaration.CustomAttributes.Add( - new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerStepThroughAttribute), Configuration.CodeTypeReferenceOptions))); + if (Configuration.GenerateDebuggerStepThroughAttribute) + classDeclaration.CustomAttributes.Add( + new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerStepThroughAttribute), Configuration.CodeTypeReferenceOptions))); + if (Configuration.GenerateDesignerCategoryAttribute) { classDeclaration.CustomAttributes.Add( @@ -864,7 +866,10 @@ private IEnumerable GetAttributes(bool isArray) { if (IsAny) { - attributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyAttributeAttribute), Configuration.CodeTypeReferenceOptions))); + var anyAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyAttributeAttribute), Configuration.CodeTypeReferenceOptions)); + if (Order != null) + anyAttribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(Order.Value))); + attributes.Add(anyAttribute); } else { @@ -876,7 +881,10 @@ private IEnumerable GetAttributes(bool isArray) { if (IsAny) { - attributes.Add(new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyElementAttribute), Configuration.CodeTypeReferenceOptions))); + var anyAttribute = new CodeAttributeDeclaration(new CodeTypeReference(typeof(XmlAnyElementAttribute), Configuration.CodeTypeReferenceOptions)); + if (Order != null) + anyAttribute.Arguments.Add(new CodeAttributeArgument("Order", new CodePrimitiveExpression(Order.Value))); + attributes.Add(anyAttribute); } else {