Skip to content

Commit

Permalink
Merge branch 'develop' into fix/add_check_on_definition_when_visiting
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsmits authored Mar 21, 2024
2 parents 932ae47 + bd07ced commit 84b18cf
Show file tree
Hide file tree
Showing 125 changed files with 3,886 additions and 2,088 deletions.
12 changes: 11 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ updates:
- package-ecosystem: "nuget" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "weekly"
ignore:
- dependency-name: "Moq"
- dependency-name: "xunit"
update-types: ["version-update:semver-patch"]
- dependency-name: "xunit.runner.visualstudio"
update-types: ["version-update:semver-patch"]
- dependency-name: Microsoft.NET.Test.Sdk
update-types: ["version-update:semver-patch"]
- dependency-name: MSTest.TestAdapter
update-types: ["version-update:semver-patch"]
- dependency-name: MSTest.TestFramework
update-types: ["version-update:semver-patch"]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ src/Hl7.Fhir.Model/EwoutFhirNetApi.snk
sonar-project.properties
src/.vs/
.vs/
.idea/
build/runbuild.txt

dist/
2 changes: 2 additions & 0 deletions .idea/.idea.Hl7.Fhir/.idea/.gitignore

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

2 changes: 1 addition & 1 deletion Hl7.Fhir.sln
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hl7.Fhir.Specification.STU3
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hl7.Fhir.STU3.Tests", "src\Hl7.Fhir.STU3.Tests\Hl7.Fhir.STU3.Tests.csproj", "{CFF0DDA5-5155-4144-B426-91C7623D08E7}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Hl7.Fhir.Shims.Conformance", "src\Hl7.Fhir.Shims.Base\Hl7.Fhir.Shims.Conformance.shproj", "{150A59A2-371D-4747-8B08-C8E6340EC962}"
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Hl7.Fhir.Shims.Base", "src\Hl7.Fhir.Shims.Base\Hl7.Fhir.Shims.Base.shproj", "{150A59A2-371D-4747-8B08-C8E6340EC962}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2013-2020, HL7, Firely (info@fire.ly), Microsoft Open Technologies
Copyright (c) 2013-2024, HL7, Firely (info@fire.ly), Microsoft Open Technologies
and contributors. See the file CONTRIBUTORS for details

All rights reserved.
Expand Down
14 changes: 9 additions & 5 deletions build/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,15 @@ stages:
inputs:
versionSpec: '6.4.0'

- template: restore.yml@templates
parameters:
nuGetServiceConnections: GitHubPackageGetFeed
nuGetSources: --source https://nuget.pkg.github.com/FirelyTeam/index.json
- ${{ if eq(variables.useGitHubPackageFeed, 'yes') }}:
- template: restore.yml@templates
parameters:
nuGetServiceConnections: GitHubPackageGetFeed
nuGetSources: --source https://nuget.pkg.github.com/FirelyTeam/index.json

- ${{ if eq(variables.useGitHubPackageFeed, 'no') }}:
- script: dotnet restore --source https://api.nuget.org/v3/index.json
displayName: 'Run dotnet restore'

- task: DotNetCoreCLI@2
displayName: Build
Expand Down Expand Up @@ -203,7 +208,6 @@ stages:
testRunTitle: Tests Serialization R4 test project
projects: |
**/publish/Hl7.Fhir.Serialization.R4.Tests.dll
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # not a PR
- job:
displayName: Tests Serialization R4B test project
Expand Down
4 changes: 2 additions & 2 deletions build/build-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Variables used during builds.

variables:
NET_CORE_SDK: 7.0.x
NET_CORE_SDK: 8.0.x
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
TEST_TARGETFRAMEWORK: net6.0
TEST_TARGETFRAMEWORK: net8.0
buildConfiguration: Release
3 changes: 2 additions & 1 deletion build/pipeline-variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
variables:
isTagBranch: $[startswith(variables['Build.SourceBranch'], 'refs/tags/v')]
GITHUB_PACKAGES_APIKEY: $(GitHubPushPackagesAPIKey) # key is set in variable group APIKeys
NUGET_APIKEY: $(NuGetSDKAPIKey) # key is set in variable group APIKeys
NUGET_APIKEY: $(NuGetSDKAPIKey) # key is set in variable group APIKeys
useGitHubPackageFeed: 'no' # possible values: 'yes', 'no'
2 changes: 1 addition & 1 deletion build/templates/test-job-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ steps:
displayName: 'Use .NET Core sdk $(NET_CORE_SDK)'
inputs:
packageType: runtime
version: 6.0.x
version: $(NET_CORE_SDK)
- task: DownloadPipelineArtifact@2
inputs:
displayName: Download Build artifacts
Expand Down
7 changes: 2 additions & 5 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
## Intro:

Highlights of this new release:

- The `MultiTerminologyService` has been extended with a routing mechanism, so you can customize which ValueSets should be handled by which service.
- The FhirDateTime, Date and Time types now avoid re-parsing their values for every operation, increasing their performance dramatically.
- Resources now implement `IIdentifiable` and `ICoded` for easy polymorphic access to the identifiers and codes in a resource. See https://docs.fire.ly/projects/Firely-NET-SDK/model/other-features.html.
- Work has been done to use the SDK's POCO's in the upcoming .NET CQL engine.

Many small improvements
5 changes: 3 additions & 2 deletions src/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>Benchmarks</AssemblyName>
<RootNamespace>Firely.Sdk.Benchmarks</RootNamespace>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.8" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
</ItemGroup>

<ItemGroup>
Expand Down
65 changes: 65 additions & 0 deletions src/Benchmarks/EnumUtilityBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using BenchmarkDotNet.Attributes;
using Hl7.Fhir.Model;
using Hl7.Fhir.Utility;
using System;

#nullable enable

namespace Firely.Sdk.Benchmarks
{
[MemoryDiagnoser]
public class EnumUtilityBenchmarks
{
private static readonly SearchParamType StringSearchParam = SearchParamType.String;
private static readonly Enum StringSearchParamEnum = StringSearchParam;

[Benchmark]
public string EnumToString()
=> SearchParamType.String.ToString();

[Benchmark]
public string? EnumGetName()
=> Enum.GetName(StringSearchParam);

[Benchmark]
public string EnumUtilityGetLiteral()
=> EnumUtility.GetLiteral(StringSearchParam);

[Benchmark]
public string EnumUtilityGetLiteralNonGeneric()
=> EnumUtility.GetLiteral(StringSearchParamEnum);

[Benchmark]
public SearchParamType EnumParse()
=> Enum.Parse<SearchParamType>("String");

[Benchmark]
public SearchParamType EnumParseIgnoreCase()
=> Enum.Parse<SearchParamType>("string", true);

[Benchmark]
public SearchParamType EnumUtilityParseLiteral()
=> EnumUtility.ParseLiteral<SearchParamType>("string")!.Value;

[Benchmark]
public Enum? EnumUtilityParseLiteralNonGeneric()
=> EnumUtility.ParseLiteral("string", typeof(SearchParamType));

[Benchmark]
public SearchParamType EnumUtilityParseLiteralIgnoreCase()
=> EnumUtility.ParseLiteral<SearchParamType>("string", true)!.Value;

[Benchmark]
public Enum? EnumUtilityParseLiteralIgnoreCaseNonGeneric()
=> EnumUtility.ParseLiteral("string", typeof(SearchParamType), true);

[Benchmark]
public string? EnumUtilityGetSystem()
=> EnumUtility.GetSystem(StringSearchParam);

[Benchmark]
public string? EnumUtilityGetSystemNonGeneric()
=> EnumUtility.GetSystem(StringSearchParamEnum);
}
}
#nullable restore
44 changes: 25 additions & 19 deletions src/Hl7.Fhir.Base/ElementModel/ElementNode.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*

/*
* Copyright (c) 2018, Firely (info@fire.ly) and contributors
* See the file CONTRIBUTORS for details.
*
Expand Down Expand Up @@ -45,7 +46,7 @@ public static ITypedElement ForPrimitive(object value)
public static bool TryConvertToElementValue(object value, out object primitiveValue)
{
primitiveValue = conv();
return primitiveValue != null;
return primitiveValue is not null;

object conv()
{
Expand Down Expand Up @@ -90,25 +91,34 @@ object conv()
/// <param name="values"></param>
/// <returns></returns>
public static IEnumerable<ITypedElement> CreateList(params object[] values) =>
values != null
? values.Select(value => value == null
? null
: value is ITypedElement element
? element
: ForPrimitive(value))
: EmptyList;
values switch
{
null => EmptyList,
[var one] => [toTT(one)],
_ => values.Select(toTT).ToList()
};

/// <summary>
/// Create a variable list of values using an enumeration
/// - so doesn't have to be converted to an array in memory (issue with larger dynamic lists)
/// </summary>
/// <param name="values"></param>
/// <returns></returns>
public static IEnumerable<ITypedElement> CreateList(IEnumerable<object> values) => values != null
? values.Select(value => value == null ? null : value is ITypedElement element ? element : ForPrimitive(value))
: EmptyList;
public static IEnumerable<ITypedElement> CreateList(IEnumerable<object> values) => values switch
{
null => EmptyList,
_ => values.Select(toTT).ToList()
};

public static readonly IEnumerable<ITypedElement> EmptyList = Enumerable.Empty<ITypedElement>();
private static ITypedElement toTT(object value) => value switch
{
null => null,
ITypedElement element => element,
_ => ForPrimitive(value)
};


public static readonly IEnumerable<ITypedElement> EmptyList = [];
public IEnumerable<ITypedElement> Children(string name = null) => ChildrenInternal(name);

internal ElementNode(string name, object value, string instanceType, IElementDefinitionSummary definition)
Expand All @@ -125,7 +135,7 @@ private IReadOnlyCollection<IElementDefinitionSummary> getChildDefinitions(IStru
{
LazyInitializer.EnsureInitialized(ref _childDefinitions, () => this.ChildDefinitions(provider));

return _childDefinitions;
return _childDefinitions!;
}

public ElementNode Add(IStructureDefinitionSummaryProvider provider, ElementNode child, string name = null)
Expand Down Expand Up @@ -226,11 +236,7 @@ public static ElementNode Root(IStructureDefinitionSummaryProvider provider, str
if (type == null) throw Error.ArgumentNull(nameof(type));

var sd = provider.Provide(type);
IElementDefinitionSummary definition = null;

// Should we throw if type is not found?
if (sd != null)
definition = ElementDefinitionSummary.ForRoot(sd);
var definition = sd is not null ? ElementDefinitionSummary.ForRoot(sd) : null;

return new ElementNode(name ?? type, value, type, definition);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Hl7.Fhir.Base/ElementModel/ElementNodeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ public static ScopedNode ToScopedNode(this ITypedElement node) =>
node as ScopedNode ?? new ScopedNode(node);
}
}

#nullable restore
70 changes: 70 additions & 0 deletions src/Hl7.Fhir.Base/ElementModel/IBaseElementNavigator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2023, Firely (info@fire.ly) and contributors
* See the file CONTRIBUTORS for details.
*
* This file is licensed under the BSD 3-Clause license
* available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
*/

using System;
using System.Collections.Generic;

#nullable enable

namespace Hl7.Fhir.ElementModel
{
/// <summary>
/// The base interface for <see cref="ITypedElement"/>."/>
/// </summary>
/// <typeparam name="TDerived"></typeparam>
[Obsolete("WARNING! Intended for internal API usage exclusively, this interface ideally should be kept internal. " +
"However, due to its derivation by the public interface ITypedElement, maintaining its internal status is impossible.")]
public interface IBaseElementNavigator<TDerived> where TDerived : IBaseElementNavigator<TDerived>
{
/// <summary>
/// Enumerate the child nodes present in the source representation (if any)
/// </summary>
/// <param name="name">Return only the children with the given name.</param>
/// <returns></returns>
IEnumerable<TDerived> Children(string? name = null);

/// <summary>
/// Name of the node, e.g. "active", "value".
/// </summary>
string Name { get; }

/// <summary>
/// Type of the node. If a FHIR type, this is just a simple string, otherwise a StructureDefinition url for a type defined as a logical model.
/// </summary>
string InstanceType { get; }

/// <summary>
/// The value of the node (if it represents a primitive FHIR value)
/// </summary>
/// <remarks>
/// FHIR primitives are mapped to underlying C# types as follows:
///
/// instant Hl7.Fhir.ElementModel.Types.DateTime
/// time Hl7.Fhir.ElementModel.Types.Time
/// date Hl7.Fhir.ElementModel.Types.Date
/// dateTime Hl7.Fhir.ElementModel.Types.DateTime
/// decimal decimal
/// boolean bool
/// integer int
/// unsignedInt int
/// positiveInt int
/// long/integer64 long (name will be finalized in R5)
/// string string
/// code string
/// id string
/// uri, oid, uuid,
/// canonical, url string
/// markdown string
/// base64Binary string (uuencoded)
/// xhtml string
/// </remarks>
object Value { get; }
}
}

#nullable restore
Loading

0 comments on commit 84b18cf

Please sign in to comment.