Skip to content

Fixes another code generation bug that improperly generated return type of property when an element was a simple type with enums#88

Merged
mamift merged 31 commits into
masterfrom
bug/xquery_specific_enumCodeGenBug
May 7, 2026
Merged

Fixes another code generation bug that improperly generated return type of property when an element was a simple type with enums#88
mamift merged 31 commits into
masterfrom
bug/xquery_specific_enumCodeGenBug

Conversation

@mamift
Copy link
Copy Markdown
Owner

@mamift mamift commented May 6, 2026

  • Fixes a code generation bug which did not properly generate the return type on a property getter when an element was of an XML Schema simple type with enumerations (this bug affected XSD string types like xs:string and xs:NMTOKEN, but should fix it for all simple enum types). Affected code generation for XQueryX.xsd.
  • Also fixed another code gen bug: when referencing an enum for the internal static field holding a default value, the member reference code was uncompilable when the default value in the XSD started with a number.
  • Some additional groundwork laid for future changes.

v3.4.14

Copilot AI review requested due to automatic review settings May 6, 2026 11:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR targets a code-generation issue where properties for elements typed as simple-type enums (e.g., restricted xs:string / xs:NMTOKEN with enumerations) could get an incorrect CLR return type, and it also includes related generator/config refactors plus regenerated outputs to reflect the updated generation behavior.

Changes:

  • Fixes enum/simple-type return type selection in the generator (ClrPropertyInfo.ReturnType) for enum refs vs non-refs.
  • Updates enum fixed/default value generation to use EnumFacet-derived member identifiers.
  • Refactors configuration namespace default visibility handling to use an enum, and regenerates configuration + schema library outputs accordingly.

Reviewed changes

Copilot reviewed 25 out of 38 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
XObjectsCode/Src/ClrPropertyInfo.cs Adjusts generator logic for property return type selection for enum cases (IsEnum && !IsRef).
XObjectsCode/Src/SimpleTypeCodeDomHelper.cs Changes enum literal/code expression emission to use EnumFacet.Member.
XObjectsCode/Extensions/GeneralExtensions.cs Adds ToNamespaceEnum() and refactors ToKeyword() formatting.
XObjectsCode/Configuration/Namespace.cs Makes Namespace public and switches DefaultVisibility assignment to enum-based.
XObjectsCode/Configuration/LinqToXsdConfiguration.xsd.cs Regenerates configuration types; DefaultVisibility becomes an enum-based attribute with facet validation.
XObjectsTests/RoslynCodeSplittingTests.cs Adds a prototype Roslyn-based code-splitting test that reads/writes generated files on disk.
GeneratedSchemaLibraries/SharePoint2010/wss.xsd.cs Regenerated output; includes enum facet mappings for keyword-like values (e.g., true/false, int/string).
RELEASENOTES.md Adds a 3.4.14 release note entry for the fix (formatting needs cleanup).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread GeneratedSchemaLibraries/SharePoint2010/wss.xsd.cs
Comment thread GeneratedSchemaLibraries/SharePoint2010/wss.xsd.cs
Comment on lines 702 to 739
@@ -655,16 +729,28 @@ internal virtual System.Uri Schema {
/// Occurrence: optional
/// </para>
/// </summary>
internal virtual string DefaultVisibility {
public virtual Xml.Schema.Linq.Namespace.DefaultVisibilityEnum? DefaultVisibility {
get {
XAttribute x = this.Attribute(DefaultVisibilityXName);
return XTypedServices.ParseValue<string>(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype);
if ((x == null)) {
return null;
}
return ((Xml.Schema.Linq.Namespace.DefaultVisibilityEnum)(Enum.Parse(typeof(Xml.Schema.Linq.Namespace.DefaultVisibilityEnum), XTypedServices.ParseValue(x, XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).Datatype, DefaultVisibilityEnumValidator.TypeDefinition))));
}
Comment thread XObjectsTests/RoslynCodeSplittingTests.cs
Comment thread XObjectsCode/Src/ClrPropertyInfo.cs
Comment thread RELEASENOTES.md Outdated
@mamift mamift merged commit fc0f935 into master May 7, 2026
5 checks passed
@mamift mamift deleted the bug/xquery_specific_enumCodeGenBug branch May 7, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants