Skip to content

Match Base as an extension element context explicitly - #707

Merged
andrzejskowronski merged 1 commit into
developfrom
feature/extension-context-base
Oct 16, 2026
Merged

andrzejskowronski merged 1 commit into
developfrom
feature/extension-context-base

Conversation

@alexzautke

Copy link
Copy Markdown
Member

Description

The Java validator 7.0.2 added Base to 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 in validateElementContext. Every POCO derives from Hl7.Fhir.Model.Base. This PR:

  • makes Base match directly, next to Element, so the result no longer depends on the model inspector resolving the element's type
  • adds a test based on _datatype

Any is 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

  • New test ExtensionContext_BaseContextOfDatatypeExtension_MatchesAnyElement. It puts _datatype on a resource, a primitive, a datatype, a backbone element and the value of a cross-version extension, then validates with context {element, Base}.
  • The new test also passes without the source change, which confirms that Base already 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 compilation ExtensionContext tests 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

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
alexzautke marked this pull request as ready for review October 15, 2026 19:01
@alexzautke
alexzautke requested review from andrzejskowronski and a balanced review from Copilot October 15, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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 Base directly alongside Element.
  • Adds _datatype extension 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
andrzejskowronski merged commit 4d3ff22 into develop Oct 16, 2026
4 checks passed
@andrzejskowronski
andrzejskowronski deleted the feature/extension-context-base branch October 16, 2026 08:47
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.

4 participants