Fixes another code generation bug that improperly generated return type of property when an element was a simple type with enums#88
Merged
Conversation
…when referencing an enum for the internal static field holding a default value, the member reference was syntactically uncompilable.
Contributor
There was a problem hiding this comment.
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 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)))); | |||
| } | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v3.4.14