Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
eac0157
Upgrade SDK to 6.0.0-alpha
andrzejskowronski Feb 4, 2025
bddf836
Merge branch 'develop' into feature/upgrade-sdk-to-6.0.0-alpha1
andrzejskowronski Feb 6, 2025
c02588f
Fix some test cases
andrzejskowronski Feb 12, 2025
60b5715
Temporary fix
andrzejskowronski Feb 12, 2025
3041125
changed a bit of logic in the EC validator to use Resource variable c…
Kasdejong Feb 12, 2025
3867150
Merge branch 'develop' into feature/upgrade-sdk-to-6.0.0-alpha1
andrzejskowronski Feb 25, 2025
25fcfc0
First batch of changes
Kasdejong Apr 16, 2025
9acab0a
wip
Kasdejong Apr 22, 2025
d442c58
fixed all unit tests apart from the ones that are blocked for now. Th…
Kasdejong Apr 23, 2025
c941517
reduced version to alpha2
Kasdejong Apr 23, 2025
e1985fb
Merge remote-tracking branch 'refs/remotes/origin/develop-sdk6' into …
Kasdejong Apr 23, 2025
e9b4e06
made all sdk versions appropriate
Kasdejong Apr 23, 2025
ad1dcf6
All tests should be up and running now, thanks to the packages librar…
Kasdejong Apr 24, 2025
8b2093e
Merge remote-tracking branch 'origin/develop' into feature/upgrade-sd…
Kasdejong Apr 24, 2025
39e7b12
this should still be disabled for now... It will be enabled in the ex…
Kasdejong Apr 24, 2025
fd88c3e
forgot to disable this test again
Kasdejong Apr 24, 2025
719771f
PR requested changes
Kasdejong Apr 29, 2025
3b61625
Merge branch 'develop-sdk6' into feature/upgrade-sdk-to-6.0.0-alpha2
Kasdejong Apr 29, 2025
a9301dd
manifest tests
Kasdejong Apr 29, 2025
1026bde
Update StructureDefinitionCorrectionsResolver.cs
Kasdejong Apr 29, 2025
0fa120f
Solved compiler issues, removed incorrect suggestion by Copilot.
ewoutkramer Apr 30, 2025
8d4044c
manifest update
Kasdejong May 6, 2025
226333a
re enabled ignore statement
Kasdejong May 6, 2025
0ff294e
hoping this is the right version at last
Kasdejong May 6, 2025
31f49a7
new manifest version
Kasdejong May 7, 2025
f366e28
manifest updates
Kasdejong May 15, 2025
b2500cf
?
Kasdejong May 15, 2025
b8aeda2
manifest updates
Kasdejong May 20, 2025
d5ec9d7
manifest changes after resetting artifact cache
Kasdejong May 27, 2025
c73b777
updated version
Kasdejong May 27, 2025
804d382
updated version again
Kasdejong May 27, 2025
cc4b694
added new import
Kasdejong May 27, 2025
2b6ac26
Merge branch 'develop-sdk6' into feature/upgrade-sdk-to-6.0.0-alpha2
Kasdejong May 27, 2025
e261426
merged newest sdk-5 validator into this
Kasdejong May 27, 2025
cb860a4
merge errors
Kasdejong May 27, 2025
59e6fd4
All changes for the manifest, up to date with develop this time
Kasdejong May 27, 2025
cbb3894
added extra potential source of position information to the issue ass…
Kasdejong May 27, 2025
7142677
changes to manifest after updating sdk (fixing bugs in SDK)
Kasdejong May 28, 2025
ea3b7fa
changes to manifest after updating sdk (fixing bugs in SDK)
Kasdejong May 28, 2025
6bc7efa
Merge remote-tracking branch 'origin/feature/upgrade-sdk-to-6.0.0-alp…
Kasdejong May 28, 2025
59924f3
did not work... pushing again
Kasdejong May 28, 2025
0dec6ea
added position info for primitives (valueElementNode)
Kasdejong May 28, 2025
bec3036
fixed value element node annotations
Kasdejong May 28, 2025
2d934ae
Fixed sdk crashing and erasing all errors when a version was found on…
Kasdejong Jun 11, 2025
82f5f0c
Changed manifest to reflect new SDK version. this will fail on the pi…
Kasdejong Jun 11, 2025
ce2d668
correct package version now that the required changes are pushed to g…
Kasdejong Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions firely-validator-api-tests.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<FirelySdkVersion>5.11.7</FirelySdkVersion>
<FirelySdkVersion>6.0.0-alpha3-20250611.3</FirelySdkVersion>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -37,8 +37,7 @@
</PropertyGroup>

<PropertyGroup>
<NoWarn>ExperimentalApi</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NoWarn>ExperimentalApi;SDK0001</NoWarn>
</PropertyGroup>

</Project>
10 changes: 5 additions & 5 deletions firely-validator-api.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<!-- Solution-wide properties for NuGet packaging -->
<PropertyGroup>
<VersionPrefix>2.6.7</VersionPrefix>
<VersionPrefix>2.7.0</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<Authors>Firely</Authors>
<Company>Firely (https://fire.ly)</Company>
<Copyright>Copyright 2015-2025 Firely</Copyright>
Expand All @@ -24,11 +25,10 @@
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<FirelySdkVersion>5.11.7</FirelySdkVersion>
<FirelySdkVersion>6.0.0-alpha3-20250611.3</FirelySdkVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand All @@ -54,9 +54,9 @@
<!-- Error CS4014 Because this call is not awaited, execution of the current method continues before the call is completed.
Consider applying the 'await' operator to the result of the call. -->
<WarningsAsErrors>CS4014</WarningsAsErrors>
<!-- <WarningsNotAsErrors>NU5104</WarningsNotAsErrors>-->
<WarningsNotAsErrors>NU5104, CS8602, CS8604, CS8619, CS8620, CS8603</WarningsNotAsErrors>
Copy link
Contributor

Choose a reason for hiding this comment

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

From #513, we should not disable those warnings once PR is ready :)

Copy link
Member Author

Choose a reason for hiding this comment

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

This will require a TON of effort right now!!! I have well over 1000 of these errors because our model is now nullable! We should make a separate issue for this once the dust settles.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot Can you create a PR for this?

Copy link
Member

Choose a reason for hiding this comment

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

(aaah.....we don't have the preview of this new copilot stuff :-()

<!-- RS0027 falsely complains about misuse of optional parameters in the public API-->
<NoWarn>RS0027;ExperimentalApi</NoWarn>
<NoWarn>RS0027;ExperimentalApi;SDK0001</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Navigation;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Navigation;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Navigation;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Specification.Navigation;
using System.Collections.Generic;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class StandardBuilders(IAsyncResourceResolver source) : ISchemaBuilder
new CanonicalBuilder(),
new FhirStringBuilder(),
new FhirUriBuilder(),
// new ExtensionContextBuilder()
//new ExtensionContextBuilder()
];

/// <inheritdoc/>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ internal StructureDefinitionToElementSchemaResolver(IAsyncResourceResolver sourc
{
try
{
return TaskHelper.Await(() => Source.FindStructureDefinitionAsync((string)schemaUri)) is StructureDefinition sd
return TaskHelper.Await(() => Source.FindStructureDefinitionAsync((string)schemaUri)) is { } sd
? _schemaBuilder.BuildSchema(sd)
: null;
}
Expand Down
16 changes: 9 additions & 7 deletions src/Firely.Fhir.Validation.Shared/Validator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public Validator(
o switch
{
null => null,
ElementNode en => en,
Resource r => r.ToTypedElement(),
ElementNode en => en.ToPocoNode(ModelInfo.ModelInspector),
Resource r => r.ToPocoNode(ModelInfo.ModelInspector),
_ => throw new ArgumentException("Reference resolver must return either a Resource or ElementNode.")
};

Expand All @@ -74,22 +74,24 @@ public Validator(
/// </summary>
/// <returns>A report containing the issues found during validation.</returns>
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
// Suppressing this issue since this will be a single method call when we introduce IScopedNode.
public OperationOutcome Validate(Resource instance, string? profile = null) => Validate(instance.ToTypedElement(ModelInfo.ModelInspector).AsScopedNode(), profile);
// Suppressing this issue since this will be a single method call when we introduce ITypedElement.
#pragma warning disable CS0618 // Type or member is obsolete
public OperationOutcome Validate(Resource instance, string? profile = null) => Validate(instance.ToPocoNode(ModelInfo.ModelInspector), profile);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters

/// <summary>
/// Validates an instance against a profile.
/// </summary>
/// <returns>A report containing the issues found during validation.</returns>
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
public OperationOutcome Validate(ElementNode instance, string? profile = null) => Validate(instance.AsScopedNode(), profile);
public OperationOutcome Validate(ElementNode instance, string? profile = null) => Validate(instance.ToPocoNode(ModelInfo.ModelInspector), profile);
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters

internal OperationOutcome Validate(IScopedNode sn, string? profile = null)
internal OperationOutcome Validate(ITypedElement sn, string? profile = null)
{
if (sn.InstanceType is null)
throw new ArgumentException($"Cannot validate the resource because {nameof(IScopedNode)} does not have an instance type.");
throw new ArgumentException($"Cannot validate the resource because {nameof(ITypedElement)} does not have an instance type.");

profile ??= _settings.TypeNameMapper.MapTypeName(sn.InstanceType).ToString();

Expand Down
8 changes: 5 additions & 3 deletions src/Firely.Fhir.Validation/Impl/AllValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/


using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -74,9 +76,9 @@ public AllValidator(bool shortcircuitEvaluation, params IAssertion[] members) :
{
}

/// <inheritdoc cref="IGroupValidatable.Validate(IEnumerable{IScopedNode}, ValidationSettings, ValidationState)"/>
/// <inheritdoc cref="IGroupValidatable.Validate(IEnumerable{ITypedElement}, ValidationSettings, ValidationState)"/>
ResultReport IGroupValidatable.Validate(
IEnumerable<IScopedNode> input,
IEnumerable<ITypedElement> input,
ValidationSettings vc,
ValidationState state)
{
Expand All @@ -98,7 +100,7 @@ ResultReport IGroupValidatable.Validate(
}

/// <inheritdoc />
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState state) => ((IGroupValidatable)this).Validate(new[] { input }, vc, state);
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState state) => ((IGroupValidatable)this).Validate(new[] { input }, vc, state);


/// <inheritdoc />
Expand Down
8 changes: 5 additions & 3 deletions src/Firely.Fhir.Validation/Impl/AnyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* available at https://github.com/FirelyTeam/firely-validator-api/blob/main/LICENSE
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.ComponentModel;
Expand Down Expand Up @@ -56,9 +58,9 @@ public AnyValidator(params IAssertion[] members) : this(members.AsEnumerable(),
{
}

/// <inheritdoc cref="IGroupValidatable.Validate(IEnumerable{IScopedNode}, ValidationSettings, ValidationState)"/>
/// <inheritdoc cref="IGroupValidatable.Validate(IEnumerable{ITypedElement}, ValidationSettings, ValidationState)"/>
ResultReport IGroupValidatable.Validate(
IEnumerable<IScopedNode> input,
IEnumerable<ITypedElement> input,
ValidationSettings vc,
ValidationState state)
{
Expand Down Expand Up @@ -90,7 +92,7 @@ ResultReport IGroupValidatable.Validate(
}

/// <inheritdoc />
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState state) => ((IGroupValidatable)this).Validate(new[] { input }, vc, state);
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState state) => ((IGroupValidatable)this).Validate(new[] { input }, vc, state);


/// <inheritdoc cref="IJsonSerializable.ToJson"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Hl7.Fhir.ElementModel;
using Newtonsoft.Json.Linq;
using System;
using System.ComponentModel;
Expand Down Expand Up @@ -31,10 +32,10 @@ internal class BaseTypeInvariantConstraintsValidator : IValidatable
/// <param name="vc"></param>
/// <param name="state"></param>
/// <returns></returns>
public ResultReport Validate(IScopedNode input, ValidationSettings vc, ValidationState state)
public ResultReport Validate(ITypedElement input, ValidationSettings vc, ValidationState state)
{
if (input.InstanceType is null)
throw new ArgumentException($"Cannot validate the resource because {nameof(IScopedNode)} does not have an instance type.");
throw new ArgumentException($"Cannot validate the resource because {nameof(ITypedElement)} does not have an instance type.");

return FhirSchemaGroupAnalyzer.FetchSchema(vc.ElementSchemaResolver, state, vc.TypeNameMapper.MapTypeName(input.InstanceType)) switch
{
Expand Down
6 changes: 4 additions & 2 deletions src/Firely.Fhir.Validation/Impl/BasicValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* available at https://github.com/FirelyTeam/firely-validator-api/blob/main/LICENSE
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Newtonsoft.Json.Linq;
using System.ComponentModel;

Expand All @@ -26,10 +28,10 @@ public abstract class BasicValidator : IValidatable
public virtual JToken ToJson() => new JProperty(Key, Value);

/// <inheritdoc />
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState state) =>
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState state) =>
BasicValidate(input, vc, state);

internal abstract ResultReport BasicValidate(IScopedNode input, ValidationSettings vc, ValidationState state);
internal abstract ResultReport BasicValidate(ITypedElement input, ValidationSettings vc, ValidationState state);


/// <summary>
Expand Down
13 changes: 7 additions & 6 deletions src/Firely.Fhir.Validation/Impl/BindingValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* available at https://github.com/FirelyTeam/firely-validator-api/blob/main/LICENSE
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Model;
using Hl7.Fhir.Rest;
Expand Down Expand Up @@ -100,7 +101,7 @@ public BindingValidator(Canonical valueSetUri, BindingStrength? strength, bool a
}

/// <inheritdoc />
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState s)
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState s)
{
if (input is null) throw Error.ArgumentNull(nameof(input));
if (input.InstanceType is null) throw Error.Argument(nameof(input), "Binding validation requires input to have an instance type.");
Expand Down Expand Up @@ -138,7 +139,7 @@ ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, Val
/// Validates whether the instance has the minimum required coded content, depending on the binding.
/// </summary>
/// <remarks>Will throw an <c>InvalidOperationException</c> when the input is not of a bindeable type.</remarks>
private ResultReport verifyContentRequirements(IScopedNode source, Element bindable, ValidationState s)
private ResultReport verifyContentRequirements(ITypedElement source, Element bindable, ValidationState s)
{
switch (bindable)
{
Expand All @@ -162,7 +163,7 @@ private static bool codeableConceptHasCode(CodeableConcept cc) =>
cc.Coding.Any(cd => !string.IsNullOrEmpty(cd.Code));


private ResultReport validateCode(Element bindable, ValidationSettings vc, ValidationState s, IScopedNode input)
private ResultReport validateCode(Element bindable, ValidationSettings vc, ValidationState s, ITypedElement input)
{
//EK 20170605 - disabled inclusion of warnings/errors for all but required bindings since this will
// 1) create superfluous messages (both saying the code is not valid) coming from the validateResult + the outcome.AddIssue()
Expand Down Expand Up @@ -211,14 +212,14 @@ private static string buildCodingDisplay(ValidateCodeParameters p)
_ => throw new NotSupportedException("Logic error: one of code/coding/cc should have been not null.")
};

static string codeToString(string code, string? system)
static string codeToString(string? code, string? system)
{
var systemAddition = system is null ? string.Empty : $" (system '{system}')";
return $"'{code}'{systemAddition}";
return $"'{code ?? "(node code)"}'{systemAddition}";
}

static string ccToString(CodeableConcept cc) =>
string.Join(',', cc.Coding?.Select(c => codeToString(c.Code, c.System)) ?? Enumerable.Empty<string>());
string.Join(',', cc.Coding?.Select(c => codeToString(c.Code, c.System)) ?? []);
}


Expand Down
4 changes: 3 additions & 1 deletion src/Firely.Fhir.Validation/Impl/CanonicalValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* available at https://github.com/FirelyTeam/firely-validator-api/blob/main/LICENSE
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Support;
using Newtonsoft.Json.Linq;
using System.ComponentModel;
Expand All @@ -31,7 +33,7 @@ public class CanonicalValidator : IValidatable
public JToken ToJson() => new JProperty("canonical", new JObject());

/// <inheritdoc/>
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState state)
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState state)
{
switch (input.Value)
{
Expand Down
10 changes: 6 additions & 4 deletions src/Firely.Fhir.Validation/Impl/CardinalityValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* available at https://github.com/FirelyTeam/firely-validator-api/blob/main/LICENSE
*/

using Hl7.Fhir.ElementModel;
using Hl7.Fhir.Model;
using Hl7.Fhir.Support;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
Expand Down Expand Up @@ -82,21 +84,21 @@ string other when int.TryParse(other, out var maximum) => maximum,
}

/// <inheritdoc />
ResultReport IGroupValidatable.Validate(IEnumerable<IScopedNode> input, ValidationSettings _, ValidationState s)
ResultReport IGroupValidatable.Validate(IEnumerable<ITypedElement> input, ValidationSettings _, ValidationState s)
{
var count = input.Count();
return buildResult(input.FirstOrDefault(), count, s);
}

private ResultReport buildResult(IScopedNode? input, int count, ValidationState s) => !inRange(count) ?
private ResultReport buildResult(ITypedElement? input, int count, ValidationState s) => !inRange(count) ?
new IssueAssertion(Issue.CONTENT_INCORRECT_OCCURRENCE,
$"Instance count is {count}, which is not within the specified cardinality of {CardinalityDisplay}").AsResult(s, input, nameof(CardinalityValidator))
: ResultReport.SUCCESS;

/// <inheritdoc />
ResultReport IValidatable.Validate(IScopedNode input, ValidationSettings vc, ValidationState state) =>
ResultReport IValidatable.Validate(ITypedElement input, ValidationSettings vc, ValidationState state) =>
buildResult(input, 1, state);

private bool inRange(int x) => (!Min.HasValue || x >= Min.Value) && (!Max.HasValue || x <= Max.Value);

private string CardinalityDisplay => $"{Min?.ToString() ?? "<-"}..{Max?.ToString() ?? "*"}";
Expand Down
Loading