diff --git a/XmlSchemaClassGenerator.Console/XmlSchemaClassGenerator.Console.csproj b/XmlSchemaClassGenerator.Console/XmlSchemaClassGenerator.Console.csproj
index 97fcdccb..a7bf0a4a 100644
--- a/XmlSchemaClassGenerator.Console/XmlSchemaClassGenerator.Console.csproj
+++ b/XmlSchemaClassGenerator.Console/XmlSchemaClassGenerator.Console.csproj
@@ -27,7 +27,7 @@
-
+
\ No newline at end of file
diff --git a/XmlSchemaClassGenerator.Tests/Compiler.cs b/XmlSchemaClassGenerator.Tests/Compiler.cs
index c4b9398b..f6a468e0 100644
--- a/XmlSchemaClassGenerator.Tests/Compiler.cs
+++ b/XmlSchemaClassGenerator.Tests/Compiler.cs
@@ -82,7 +82,7 @@ public static Assembly GenerateFiles(string name, IEnumerable files, Gen
EntityFramework = false,
GenerateInterfaces = true,
NamespacePrefix = name,
- GenerateDescriptionAttribute = true
+ GenerateDescriptionAttribute = true,
};
var output = new FileWatcherOutputWriter(Path.Combine("output", name));
@@ -99,7 +99,8 @@ public static Assembly GenerateFiles(string name, IEnumerable files, Gen
EntityFramework = generatorPrototype.EntityFramework,
GenerateInterfaces = generatorPrototype.GenerateInterfaces,
MemberVisitor = generatorPrototype.MemberVisitor,
- GenerateDescriptionAttribute = generatorPrototype.GenerateDescriptionAttribute
+ GenerateDescriptionAttribute = generatorPrototype.GenerateDescriptionAttribute,
+ CodeTypeReferenceOptions = generatorPrototype.CodeTypeReferenceOptions
};
gen.Generate(files);
diff --git a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
index 125472a8..155cf683 100644
--- a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
+++ b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
@@ -18,15 +18,15 @@
-
+
all
runtime; build; native; contentfiles; analyzers
-
+
-
+
-
+
all
diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs
index 6a3b8ac3..60e26b35 100644
--- a/XmlSchemaClassGenerator.Tests/XmlTests.cs
+++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs
@@ -114,7 +114,19 @@ public void TestList()
[UseCulture("en-US")]
public void TestSimple()
{
- Compiler.Generate("Simple", SimplePattern);
+ Compiler.Generate("Simple", SimplePattern, new Generator
+ {
+ GenerateNullables = true,
+ IntegerDataType = typeof(int),
+ DataAnnotationMode = DataAnnotationMode.All,
+ GenerateDesignerCategoryAttribute = false,
+ GenerateComplexTypesForCollections = true,
+ EntityFramework = false,
+ GenerateInterfaces = true,
+ NamespacePrefix = "Simple",
+ GenerateDescriptionAttribute = true,
+ CodeTypeReferenceOptions = CodeTypeReferenceOptions.GlobalReference
+ });
TestSamples("Simple", SimplePattern);
}
diff --git a/XmlSchemaClassGenerator.Tests/xsd/simple/simple.xsd b/XmlSchemaClassGenerator.Tests/xsd/simple/simple.xsd
index 697f5526..fdc941b2 100644
--- a/XmlSchemaClassGenerator.Tests/xsd/simple/simple.xsd
+++ b/XmlSchemaClassGenerator.Tests/xsd/simple/simple.xsd
@@ -385,6 +385,7 @@
+
diff --git a/XmlSchemaClassGenerator/RestrictionModel.cs b/XmlSchemaClassGenerator/RestrictionModel.cs
index 3e430f91..6fbe2b3e 100644
--- a/XmlSchemaClassGenerator/RestrictionModel.cs
+++ b/XmlSchemaClassGenerator/RestrictionModel.cs
@@ -89,7 +89,7 @@ public override DataAnnotationMode MinimumDataAnnotationMode
public override CodeAttributeDeclaration GetAttribute()
{
- var a = new CodeAttributeDeclaration(new CodeTypeReference(typeof(StringLengthAttribute)),
+ var a = new CodeAttributeDeclaration(new CodeTypeReference(typeof(StringLengthAttribute), Configuration.CodeTypeReferenceOptions),
new CodeAttributeArgument(Max > 0 ? (CodeExpression)new CodePrimitiveExpression(Max) : new CodeSnippetExpression("int.MaxValue")));
if (Min > 0) { a.Arguments.Add(new CodeAttributeArgument("MinimumLength", new CodePrimitiveExpression(Min))); }
@@ -120,7 +120,8 @@ public override DataAnnotationMode MinimumDataAnnotationMode
public override CodeAttributeDeclaration GetAttribute()
{
- return new CodeAttributeDeclaration(new CodeTypeReference(typeof(MaxLengthAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
+ return new CodeAttributeDeclaration(new CodeTypeReference(typeof(MaxLengthAttribute), Configuration.CodeTypeReferenceOptions),
+ new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
}
}
@@ -147,7 +148,8 @@ public override DataAnnotationMode MinimumDataAnnotationMode
public override CodeAttributeDeclaration GetAttribute()
{
- return new CodeAttributeDeclaration(new CodeTypeReference(typeof(MinLengthAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
+ return new CodeAttributeDeclaration(new CodeTypeReference(typeof(MinLengthAttribute), Configuration.CodeTypeReferenceOptions),
+ new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
}
}
@@ -218,7 +220,8 @@ public override DataAnnotationMode MinimumDataAnnotationMode
public override CodeAttributeDeclaration GetAttribute()
{
- return new CodeAttributeDeclaration(new CodeTypeReference(typeof(RegularExpressionAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
+ return new CodeAttributeDeclaration(new CodeTypeReference(typeof(RegularExpressionAttribute), Configuration.CodeTypeReferenceOptions),
+ new CodeAttributeArgument(new CodePrimitiveExpression(Value)));
}
}
diff --git a/XmlSchemaClassGenerator/TypeModel.cs b/XmlSchemaClassGenerator/TypeModel.cs
index 8de61db6..9fa43b47 100644
--- a/XmlSchemaClassGenerator/TypeModel.cs
+++ b/XmlSchemaClassGenerator/TypeModel.cs
@@ -184,7 +184,7 @@ public virtual CodeTypeReference GetReferenceFor(NamespaceModel referencingNames
name = forInit ? SimpleModel.GetCollectionImplementationName(name, Configuration) : SimpleModel.GetCollectionDefinitionName(name, Configuration);
}
- return new CodeTypeReference(name);
+ return new CodeTypeReference(name, Configuration.CodeTypeReferenceOptions);
}
public virtual CodeExpression GetDefaultValueFor(string defaultString, bool attribute)
@@ -910,7 +910,7 @@ public void AddMembersTo(CodeTypeDeclaration typeDeclaration, bool withDataBindi
{
var specifiedProperty = new CodeMemberProperty
{
- Type = new CodeTypeReference(typeof(bool)),
+ Type = new CodeTypeReference(typeof(bool), Configuration.CodeTypeReferenceOptions),
Name = Name + "Specified",
HasSet = false,
HasGet = true,
@@ -1268,7 +1268,8 @@ public override CodeExpression GetDefaultValueFor(string defaultString, bool att
}
else if (type == typeof(DateTime))
{
- var rv = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(DateTime)), "Parse", new CodePrimitiveExpression(defaultString));
+ var rv = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(new CodeTypeReference(typeof(DateTime), Configuration.CodeTypeReferenceOptions)),
+ "Parse", new CodePrimitiveExpression(defaultString));
return rv;
}
else if (type == typeof(bool) && !string.IsNullOrWhiteSpace(defaultString))