Repository navigation
Match Base as an extension element context explicitly - #707
Merged
Merged
Conversation
The _datatype extension in the FHIR extensions pack declares its context
as {element, Base}. This already matched through the type-hierarchy check,
but now short-circuits like Element, mirroring the Java validator (7.0.2).
Adds a test placing _datatype on a resource, primitive, datatype, backbone
element and the value of a cross-version extension.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ST5JwEcxHr8vYcyDk6zwQk
alexzautke
marked this pull request as ready for review
October 15, 2026 19:01
alexzautke
requested review from
andrzejskowronski
and
a balanced review from Copilot
October 15, 2026 19:01
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow change implements the intended behavior with focused test coverage and no identified blocking issues.
0 open findings
What changed in this PR
Makes Base an explicit universal match for extension element contexts, preserving existing behavior without relying on model type resolution.
Changes:
- Matches
Basedirectly alongsideElement. - Adds
_datatypeextension coverage across five host locations.
| File | Description |
|---|---|
| test/Firely.Fhir.Validation.Tests/Impl/ExtensionContextValidatorTests.cs | Tests Base contexts on resources, primitives, datatypes, backbone elements, and extension values. |
| src/Firely.Fhir.Validation/Impl/ExtensionContextValidator.cs | Accepts Base before type-hierarchy checks. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
andrzejskowronski
approved these changes
Oct 16, 2026
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.
Description
The Java validator 7.0.2 added
Baseto the element-context expressions that always match ("Element", "Any", "Base").In the FHIR extensions pack (5.3.0, and CI build 5.4.0), one extension uses this:
_datatype, with context{element, Base}.We already accepted
Base, through the type-hierarchy check invalidateElementContext. Every POCO derives fromHl7.Fhir.Model.Base. This PR:Basematch directly, next toElement, so the result no longer depends on the model inspector resolving the element's type_datatypeAnyis deliberately left out. Java also accepts it in element contexts and we don't, but no extension in the pack uses it.Related issues
None. This follows up on the Java validator changelog.
Testing
ExtensionContext_BaseContextOfDatatypeExtension_MatchesAnyElement. It puts_datatypeon a resource, a primitive, a datatype, a backbone element and the value of a cross-version extension, then validates with context{element, Base}.Basealready worked. Swapping the context for an unrelated type makes all five cases fail, so the test does check the context.Firely.Fhir.Validation.Tests: 327 passed. R4 compilationExtensionContexttests pass. The library builds for net10.0, net8.0 and netstandard2.1 with no warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01ST5JwEcxHr8vYcyDk6zwQk
Generated by Claude Code