Conversation
…0, FsCheck 2.16.6 - FAKE packages: 6.1.3 → 6.1.4 (patch) - NUnit: 3.13.1 → 3.13.3 (patch) - FsUnit: 4.0.4 → 4.2.0 (minor) - FsCheck: 2.15.1 → 2.16.6 (minor) Build: passes (0 errors) Tests: all offline tests pass; network tests skip due to sandbox Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add a VisitingGroups HashSet to ParsingContext and guard the GroupRef case in parseParticle. When a group is already being visited, return Empty (an empty particle) instead of recursing infinitely. This prevents a StackOverflowException when parsing XSD schemas that contain groups forming cycles (e.g. group A contains group ref B, and group B's resolved content eventually leads back to group A via the compiled XmlSchema object graph). Add a test verifying that a recursive content model schema with a group referencing itself through element content completes without error. Closes #1419 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
✅ Pull request created: #1626 |
This was referenced Feb 22, 2026
Base automatically changed from
repo-assist/deps-update-2026-02-22-22f87c2bfdc6ec83
to
main
February 22, 2026 22:10
dsyme
approved these changes
Feb 23, 2026
github-actions bot
added a commit
that referenced
this pull request
Feb 23, 2026
Add entries for: - #1613: CSS pseudo-class NotSupportedException fix (#1383) - #1617: ConvertDateTimeOffset xs:dateTime fallback fix (#1437) - #1618: Microsoft.Build security bump - #1619: XmlProvider EmbeddedResource GetSchema fix (#1310) - #1621: StrictBooleans parameter for CsvProvider - #1625: CsvProvider.InferRows multiline quoted field fix (#1439) - #1626: XSD group reference cycle guard (#1419) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🤖 This is a draft PR from Repo Assist, an automated AI assistant.
Closes #1419
Summary
Adds a cycle guard to
XsdInference.fsto prevent aStackOverflowExceptionwhen parsing XSD schemas whose compiled object graph contains group reference cycles.When
XmlProvider(Schema = "...")is used with a complex schema (such as the MS Office Custom UI schema),parseParticlecan recurse infinitely when followingXmlSchemaGroupRef.Particlechains that form a loop in the compiledXmlSchemaSetobject graph.Root Cause
In
XsdParsing.parseParticle, theXmlSchemaGroupRefcase unconditionally recursed into the resolved group's particle:After
.Compile(), the .NET XSD compiler setsgrpRef.Particleto the referenced group'sXmlSchemaGroupBase. If a complex schema has groups that (directly or transitively through the compiled object graph) reference each other, this creates a cycle:parseParticle(A.Particle)→ ... →parseParticle(A.Particle)→ ∞.The existing cycle protection in
parseElement(usingctx.Elementscache) handles recursion through element types, but not recursion through group particles themselves.Fix
Two changes:
XsdInference.fs: AddedvisitingGroups : HashSet(XmlQualifiedName)toParsingContext, exposed asmember x.VisitingGroups. InparseParticle, theXmlSchemaGroupRefcase now checks whether the group is already being visited, returningEmpty(an empty particle) to break the cycle:InferenceTests.fs: Added a test verifying that a schema with a recursive content model (a group that, through its element content, references itself) completes without error.Trade-offs
Emptyfor the back-edge of a cycle is the same convention used elsewhere in the code (e.g.XmlSchemaParticle.EmptyParticlefalls through toEmpty). The inferred type for the cyclic portion will omit the repeated elements — but this is correct behaviour since infinite nesting is not representable in the generated types anyway.GroupRefcase is affected.Test Status
✅ All 50 InferenceTests pass (including new "circular group references do not cause a stack overflow" test)
⚠️ SignatureTests: 436 pre-existing failures due to infrastructure constraints (network/assembly lookup) — not caused by this PR. These failures were present before this change.