Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
las-nsc committed Jun 9, 2022
1 parent 45c2afa commit f9a18eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
28 changes: 14 additions & 14 deletions XmlSchemaClassGenerator/IXmlSchemaNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ namespace XmlSchemaClassGenerator
{
public interface IXmlSchemaNode
{
string Name { get; }
//string Name { get; }
string DefaultValue { get; }
string FixedValue { get; }
XmlSchemaForm Form { get; }
XmlQualifiedName QualifiedName { get; }
XmlQualifiedName RefName { get; }
XmlSchemaType SchemaType { get; }
XmlSchemaType NodeSchemaType { get; }
XmlQualifiedName SchemaTypeName { get; }
//XmlQualifiedName SchemaTypeName { get; }
//XmlSchemaType SchemaType { get; }
//XmlSchemaType NodeSchemaType { get; }

XmlSchemaAnnotated Base { get; }
XmlSchemaForm FormDefault { get; }
Expand All @@ -25,23 +25,23 @@ public sealed class XmlSchemaAttributeEx : IXmlSchemaNode

public XmlSchemaAttribute Real { get; }

public string Name => Real.Name;
//public string Name => Real.Name;
public string DefaultValue => Real.DefaultValue;
public string FixedValue => Real.FixedValue;
public XmlSchemaForm Form => Real.Form;
public XmlQualifiedName QualifiedName => Real.QualifiedName;
public XmlQualifiedName RefName => Real.RefName;
public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
public XmlSchemaSimpleType SchemaType => Real.SchemaType;
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
//public XmlSchemaSimpleType SchemaType => Real.SchemaType;
public XmlSchemaSimpleType AttributeSchemaType => Real.AttributeSchemaType;

public XmlSchemaAnnotated Base => Real;

public XmlSchemaForm FormDefault => Base.GetSchema().AttributeFormDefault;

XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;
//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;

XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType;
//XmlSchemaType IXmlSchemaNode.NodeSchemaType => AttributeSchemaType;

public XmlSchemaUse Use => Real.Use;

Expand All @@ -55,23 +55,23 @@ public sealed class XmlSchemaElementEx : IXmlSchemaNode

public XmlSchemaElement Real { get; }

public string Name => Real.Name;
//public string Name => Real.Name;
public string DefaultValue => Real.DefaultValue;
public string FixedValue => Real.FixedValue;
public XmlSchemaForm Form => Real.Form;
public XmlQualifiedName QualifiedName => Real.QualifiedName;
public XmlQualifiedName RefName => Real.RefName;
public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
public XmlSchemaType SchemaType => Real.SchemaType;
//public XmlQualifiedName SchemaTypeName => Real.SchemaTypeName;
//public XmlSchemaType SchemaType => Real.SchemaType;
public XmlSchemaType ElementSchemaType => Real.ElementSchemaType;

public XmlSchemaAnnotated Base => Real;

public XmlSchemaForm FormDefault => Base.GetSchema().ElementFormDefault;

XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;
//XmlSchemaType IXmlSchemaNode.SchemaType => SchemaType;

XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType;
//XmlSchemaType IXmlSchemaNode.NodeSchemaType => ElementSchemaType;

public bool IsNillable => Real.IsNillable;

Expand Down
14 changes: 7 additions & 7 deletions XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -755,9 +755,9 @@ private IEnumerable<PropertyModel> CreatePropertiesForAttributes(Uri source, Typ

foreach (var item in items)
{
if (item is XmlSchemaAttribute node)
if (item is XmlSchemaAttribute xs)
{
XmlSchemaAttributeEx attribute = node;
XmlSchemaAttributeEx attribute = xs;
if (attribute.Use != XmlSchemaUse.Prohibited)
{
var attributeQualifiedName = attribute.AttributeSchemaType.QualifiedName;
Expand Down Expand Up @@ -806,10 +806,10 @@ private IEnumerable<PropertyModel> CreatePropertiesForAttributes(Uri source, Typ
var property = new PropertyModel(_configuration, name, typeModel, owningTypeModel)
{
IsAttribute = true,
IsRequired = node.Use == XmlSchemaUse.Required
IsRequired = attribute.Use == XmlSchemaUse.Required
};

property.SetFromNode(originalName, () => node.Use != XmlSchemaUse.Optional, attribute);
property.SetFromNode(originalName, () => attribute.Use != XmlSchemaUse.Optional, attribute);
property.SetSchemaNameAndNamespace(owningTypeModel, attribute);
property.Documentation.AddRange(GetDocumentation(attribute));

Expand Down Expand Up @@ -865,17 +865,17 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
if (item.XmlParticle is XmlSchemaElement xs && xs.ElementSchemaType != null)
{
XmlSchemaElementEx element = xs;
XmlSchemaElementEx effectiveElement = substitute?.Element ?? xs;
XmlSchemaElementEx effectiveElement = substitute?.Element ?? element;
var name = _configuration.NamingProvider.ElementNameFromQualifiedName(effectiveElement.QualifiedName, effectiveElement);
var originalName = name;
if (name == owningTypeModel.Name)
name += "Property"; // member names cannot be the same as their enclosing type

name = owningTypeModel.GetUniquePropertyName(name);

var typeModel = substitute?.Type ?? CreateTypeModel(GetQualifiedName(owningTypeModel, xmlParticle, xs), xs.ElementSchemaType);
var typeModel = substitute?.Type ?? CreateTypeModel(GetQualifiedName(owningTypeModel, xmlParticle, element), element.ElementSchemaType);

property = new PropertyModel(_configuration, name, typeModel, owningTypeModel) { IsNillable = xs.IsNillable };
property = new PropertyModel(_configuration, name, typeModel, owningTypeModel) { IsNillable = element.IsNillable };
property.SetFromParticles(particle, item);
property.SetFromNode(originalName, () => item.MinOccurs >= 1.0m && item.XmlParent is not XmlSchemaChoice, element);
property.SetSchemaNameAndNamespace(owningTypeModel, effectiveElement);
Expand Down

0 comments on commit f9a18eb

Please sign in to comment.