@@ -16,11 +16,11 @@ internal class ModelBuilder
16
16
private const string ElementName = "Element" ;
17
17
private readonly GeneratorConfiguration _configuration ;
18
18
private readonly XmlSchemaSet _set ;
19
- private readonly Dictionary < XmlQualifiedName , HashSet < XmlSchemaAttributeGroup > > AttributeGroups = new ( ) ;
20
- private readonly Dictionary < XmlQualifiedName , HashSet < XmlSchemaGroup > > Groups = new ( ) ;
21
- private readonly Dictionary < NamespaceKey , NamespaceModel > Namespaces = new ( ) ;
22
- private readonly Dictionary < string , TypeModel > Types = new ( ) ;
23
- private readonly Dictionary < XmlQualifiedName , HashSet < Substitute > > SubstitutionGroups = new ( ) ;
19
+ private readonly Dictionary < XmlQualifiedName , HashSet < XmlSchemaAttributeGroup > > AttributeGroups = [ ] ;
20
+ private readonly Dictionary < XmlQualifiedName , HashSet < XmlSchemaGroup > > Groups = [ ] ;
21
+ private readonly Dictionary < NamespaceKey , NamespaceModel > Namespaces = [ ] ;
22
+ private readonly Dictionary < string , TypeModel > Types = [ ] ;
23
+ private readonly Dictionary < XmlQualifiedName , HashSet < Substitute > > SubstitutionGroups = [ ] ;
24
24
25
25
private static readonly XmlQualifiedName AnyType = new ( "anyType" , XmlSchema . Namespace ) ;
26
26
@@ -62,7 +62,7 @@ public ModelBuilder(GeneratorConfiguration configuration, XmlSchemaSet set)
62
62
{
63
63
if ( ! AttributeGroups . ContainsKey ( currentAttributeGroup . QualifiedName ) )
64
64
{
65
- AttributeGroups . Add ( currentAttributeGroup . QualifiedName , new HashSet < XmlSchemaAttributeGroup > ( ) ) ;
65
+ AttributeGroups . Add ( currentAttributeGroup . QualifiedName , [ ] ) ;
66
66
}
67
67
68
68
AttributeGroups [ currentAttributeGroup . QualifiedName ] . Add ( currentAttributeGroup ) ;
@@ -75,7 +75,7 @@ public ModelBuilder(GeneratorConfiguration configuration, XmlSchemaSet set)
75
75
{
76
76
if ( ! Groups . ContainsKey ( currentSchemaGroup . QualifiedName ) )
77
77
{
78
- Groups . Add ( currentSchemaGroup . QualifiedName , new HashSet < XmlSchemaGroup > ( ) ) ;
78
+ Groups . Add ( currentSchemaGroup . QualifiedName , [ ] ) ;
79
79
}
80
80
81
81
Groups [ currentSchemaGroup . QualifiedName ] . Add ( currentSchemaGroup ) ;
@@ -314,7 +314,7 @@ private void CreateElement(XmlSchemaElement rootElement)
314
314
{
315
315
if ( ! SubstitutionGroups . TryGetValue ( rootElement . SubstitutionGroup , out var substitutes ) )
316
316
{
317
- substitutes = new HashSet < Substitute > ( ) ;
317
+ substitutes = [ ] ;
318
318
SubstitutionGroups . Add ( rootElement . SubstitutionGroup , substitutes ) ;
319
319
}
320
320
@@ -422,24 +422,14 @@ private TypeModel CreateTypeModel(XmlQualifiedName qualifiedName, XmlSchemaAnnot
422
422
return typeModelBuilder . Create ( type ) ;
423
423
}
424
424
425
- private sealed class TypeModelBuilder
425
+ private sealed class TypeModelBuilder ( ModelBuilder builder , GeneratorConfiguration configuration , XmlQualifiedName qualifiedName , NamespaceModel namespaceModel , List < DocumentationModel > docs , Uri source )
426
426
{
427
- private readonly ModelBuilder builder ;
428
- private readonly GeneratorConfiguration _configuration ;
429
- private readonly XmlQualifiedName qualifiedName ;
430
- private readonly NamespaceModel namespaceModel ;
431
- private readonly List < DocumentationModel > docs ;
432
- private readonly Uri source ;
433
-
434
- public TypeModelBuilder ( ModelBuilder builder , GeneratorConfiguration configuration , XmlQualifiedName qualifiedName , NamespaceModel namespaceModel , List < DocumentationModel > docs , Uri source )
435
- {
436
- this . builder = builder ;
437
- _configuration = configuration ;
438
- this . qualifiedName = qualifiedName ;
439
- this . namespaceModel = namespaceModel ;
440
- this . docs = docs ;
441
- this . source = source ;
442
- }
427
+ private readonly ModelBuilder builder = builder ;
428
+ private readonly GeneratorConfiguration _configuration = configuration ;
429
+ private readonly XmlQualifiedName qualifiedName = qualifiedName ;
430
+ private readonly NamespaceModel namespaceModel = namespaceModel ;
431
+ private readonly List < DocumentationModel > docs = docs ;
432
+ private readonly Uri source = source ;
443
433
444
434
internal TypeModel Create ( XmlSchemaAnnotated type ) => type switch
445
435
{
@@ -661,7 +651,7 @@ XmlSchemaSimpleTypeUnion typeUnion when AllMembersHaveFacets(typeUnion, out base
661
651
restrictions = CodeUtilities . GetRestrictions ( facets , simpleType , _configuration ) . Where ( r => r != null ) . Sanitize ( ) . ToList ( ) ;
662
652
}
663
653
664
- return CreateSimpleModel ( simpleType , restrictions ?? new ( ) ) ;
654
+ return CreateSimpleModel ( simpleType , restrictions ?? [ ] ) ;
665
655
666
656
static bool AllMembersHaveFacets ( XmlSchemaSimpleTypeUnion typeUnion , out List < IEnumerable < XmlSchemaFacet > > baseFacets )
667
657
{
@@ -673,7 +663,7 @@ static bool AllMembersHaveFacets(XmlSchemaSimpleTypeUnion typeUnion, out List<IE
673
663
674
664
static List < XmlSchemaFacet > MergeRestrictions ( XmlSchemaSimpleType type )
675
665
{
676
- if ( type == null ) return new ( ) ;
666
+ if ( type == null ) return [ ] ;
677
667
var baseFacets = MergeRestrictions ( type . BaseXmlSchemaType as XmlSchemaSimpleType ) ;
678
668
if ( type . Content is XmlSchemaSimpleTypeRestriction typeRestriction )
679
669
{
@@ -908,7 +898,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
908
898
{
909
899
// ElementSchemaType must be non-null. This is not the case when maxOccurs="0".
910
900
case XmlSchemaElement element when element . ElementSchemaType != null :
911
- property = PropertyFromElement ( owningTypeModel , element , particle , item , substitute , passProperties ? properties : new List < PropertyModel > ( ) ) ;
901
+ property = PropertyFromElement ( owningTypeModel , element , particle , item , substitute , passProperties ? properties : [ ] ) ;
912
902
break ;
913
903
case XmlSchemaAny :
914
904
SimpleModel typeModel = new ( _configuration )
@@ -1093,7 +1083,7 @@ public IEnumerable<Particle> GetElements(XmlSchemaObject item, XmlSchemaObject p
1093
1083
1094
1084
public static List < DocumentationModel > GetDocumentation ( XmlSchemaAnnotated annotated )
1095
1085
{
1096
- return annotated . Annotation == null ? new List < DocumentationModel > ( )
1086
+ return annotated . Annotation == null ? [ ]
1097
1087
: annotated . Annotation . Items . OfType < XmlSchemaDocumentation > ( )
1098
1088
. Where ( d => d . Markup ? . Length > 0 )
1099
1089
. Select ( d => d . Markup . Select ( m => new DocumentationModel { Language = d . Language , Text = m . OuterXml } ) )
0 commit comments