Skip to content

Fixed values generate wrong C# #568

@Ghostbird

Description

@Ghostbird

I've got an XSD with these lines in it:

…
<xs:element name="PROC-IDENT" type="xs:string" fixed="0013"/>
<xs:element name="PROC-FUNC" type="xs:string" fixed="01"/>
…

This generates:

	[XmlIgnoreAttribute()]
	private string procIdent = "0013";
	
	[RequiredAttribute(AllowEmptyStrings=true)]
	[XmlElementAttribute("PROC-IDENT", Form=XmlSchemaForm.Unqualified)]
	public string ProcIdent
	{
		get
		{
			return procIdent;
		}
		set
		{
			procIdent = value;
		}
	}
	
	[XmlIgnoreAttribute()]
	private string procFunc = "01";
	
	[RequiredAttribute(AllowEmptyStrings=true)]
	[XmlElementAttribute("PROC-FUNC", Form=XmlSchemaForm.Unqualified)]
	public string ProcFunc
	{
		get
		{
			return procFunc;
		}
		set
		{
			procFunc = value;
		}
	}

Whereas I would expect it to generate:

	[RequiredAttribute()]
	[XmlElementAttribute("PROC-IDENT", Form=XmlSchemaForm.Unqualified)]
	public string ProcIdent { get; } = "0013";

	[RequiredAttribute()]
	[XmlElementAttribute("PROC-FUNC", Form=XmlSchemaForm.Unqualified)]
	public string ProcFunc { get; } = "01";

Or if necessary for compatibility reasons, I'd expect it to generate:

	[RequiredAttribute()]
	[XmlElementAttribute("PROC-IDENT", Form=XmlSchemaForm.Unqualified)]
	public string ProcIdent { get => "0013"; set { } }

	[RequiredAttribute()]
	[XmlElementAttribute("PROC-FUNC", Form=XmlSchemaForm.Unqualified)]
	public string ProcFunc { get => "01"; set { } }

Is this caused by an error of mine, or is the fault on xscgen's side?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions