Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
5ac5033
Added merging of element id to SnapshotGenerator ElementDefnMerger + …
Rob5045 Oct 7, 2024
6d5ad14
Remove all non-inheritable extensions from the base profile before sn…
mmsmits Oct 8, 2024
f22faf9
Merge branch 'develop' into bugfix/2799-test-for-ultra-nested-extensions
mmsmits Oct 8, 2024
44922aa
Code cleanup for ElementDefinitionPropertyElementIdTest
Rob5045 Oct 9, 2024
66c5d47
Merge branch 'develop' into bugfix/issue-2839
Rob5045 Oct 9, 2024
f960da8
Code cleanup for STU3
Rob5045 Oct 11, 2024
6da124f
Merge branch 'develop' into feature/1814-remove-all-non-inheritable-e…
mmsmits Oct 21, 2024
4b13468
Merge branch 'develop' into bugfix/issue-2839
ewoutkramer Oct 21, 2024
71bfd26
moved SnapshotGeneration extensions to Base
mmsmits Oct 21, 2024
33f2e70
Merge branch 'develop' into feature/1814-remove-all-non-inheritable-e…
mmsmits Oct 21, 2024
7244bd9
removed cref
mmsmits Oct 21, 2024
604abd7
Merge remote-tracking branch 'origin/feature/1814-remove-all-non-inhe…
mmsmits Oct 21, 2024
3eee269
added new suppression files
mmsmits Oct 21, 2024
806545e
Also for Conformance
mmsmits Oct 21, 2024
cbcd50e
marked `RemoveAllConstrainedByDiffExtensions` as obsolete
mmsmits Oct 21, 2024
962f408
Merge pull request #2884 from FirelyTeam/bugfix/issue-2839
ewoutkramer Oct 22, 2024
016e7b0
Update src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExte…
mmsmits Oct 22, 2024
40f323b
Update src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExte…
mmsmits Oct 22, 2024
3d2a6ed
Merge branch 'develop' into feature/1814-remove-all-non-inheritable-e…
mmsmits Oct 22, 2024
77caa2f
Cherry-picked new signature for WithResourceOverrides method on Evalu…
Kasdejong Oct 22, 2024
9c4714e
compat suppressions
Kasdejong Oct 22, 2024
6e61c6b
Slight refactoring to increase consistency for this unit test
Kasdejong Oct 22, 2024
f3b4806
Merge branch 'develop' into feature/use-proper-snapshot-generation-se…
ewoutkramer Oct 22, 2024
a4230b7
Merge pull request #2943 from FirelyTeam/feature/use-proper-snapshot-…
ewoutkramer Oct 22, 2024
16c9577
Merge branch 'develop' into feature/1814-remove-all-non-inheritable-e…
ewoutkramer Oct 23, 2024
bbf6526
Merge pull request #2886 from FirelyTeam/feature/1814-remove-all-non-…
mmsmits Oct 23, 2024
b3ee5bf
Update release-notes.md
Kasdejong Oct 23, 2024
1e70cf4
Merge pull request #2949 from FirelyTeam/updated-release-notes
mmsmits Oct 23, 2024
f90a4a3
fix: changed stu3 datatype to FhirUri
mmsmits Oct 25, 2024
42cbbe6
added roundtrip tests for Datatypes
mmsmits Oct 25, 2024
9541914
breaking change: change Attachment.Url from FhirUrl to FhirUri
mmsmits Oct 25, 2024
d3924e2
add compatibility suppression file
mmsmits Oct 25, 2024
a061001
improved unit test and documented exceptions.
mmsmits Oct 28, 2024
436c856
add release notes
mmsmits Oct 28, 2024
6f9495a
Merge pull request #2952 from FirelyTeam/bugfix/fix-wrong-attachment-…
mmsmits Oct 28, 2024
8f9ad4e
Bump NSubstitute from 5.1.0 to 5.3.0
dependabot[bot] Oct 28, 2024
5dbd1e5
Merge pull request #2955 from FirelyTeam/dependabot/nuget/NSubstitute…
mmsmits Oct 29, 2024
94aa648
Bump MSTest.TestAdapter from 3.3.1 to 3.6.2
dependabot[bot] Nov 4, 2024
4ff06a1
Bump Newtonsoft.Json and Microsoft.NET.Test.Sdk
dependabot[bot] Nov 4, 2024
ecbc18b
Bump xunit from 2.8.0 to 2.9.2
dependabot[bot] Nov 4, 2024
a9f5a91
Bump MSTest.TestFramework from 3.3.1 to 3.6.2
dependabot[bot] Nov 4, 2024
8740a65
Merge pull request #2957 from FirelyTeam/dependabot/nuget/multi-ec0af…
mmsmits Nov 8, 2024
01d8480
Merge branch 'develop' into dependabot/nuget/MSTest.TestFramework-3.6.2
mmsmits Nov 8, 2024
46954f5
Merge branch 'develop' into dependabot/nuget/xunit-2.9.2
mmsmits Nov 8, 2024
b6d76e2
Merge branch 'develop' into dependabot/nuget/MSTest.TestAdapter-3.6.2
mmsmits Nov 8, 2024
3dddec4
Merge pull request #2958 from FirelyTeam/dependabot/nuget/xunit-2.9.2
mmsmits Nov 8, 2024
16e4fef
Merge branch 'develop' into dependabot/nuget/MSTest.TestFramework-3.6.2
mmsmits Nov 8, 2024
ae15b88
Merge pull request #2959 from FirelyTeam/dependabot/nuget/MSTest.Test…
mmsmits Nov 8, 2024
09e4364
Merge branch 'develop' into dependabot/nuget/MSTest.TestAdapter-3.6.2
mmsmits Nov 8, 2024
969602d
Merge pull request #2956 from FirelyTeam/dependabot/nuget/MSTest.Test…
mmsmits Nov 8, 2024
ad75b5e
bump version to 5.11.0
mmsmits Nov 8, 2024
c43fe9e
Start development phase 5.11.1
mmsmits Nov 8, 2024
513225e
remove compressions
mmsmits Nov 8, 2024
77563ce
remove compatibility suppression files
mmsmits Nov 8, 2024
f589293
Now dotnet is just messing with me
mmsmits Nov 8, 2024
3ec42dd
Merge pull request #2961 from FirelyTeam/release/5.11.0
mmsmits Nov 11, 2024
deb6569
Bump FluentAssertions from 6.12.1 to 6.12.2
dependabot[bot] Nov 11, 2024
a174f01
Merge pull request #2962 from FirelyTeam/dependabot/nuget/FluentAsser…
mmsmits Nov 12, 2024
5ee7e33
add an inferSystem parameter to the validate code operation
mmsmits Nov 18, 2024
d86884c
remove constant
mmsmits Nov 18, 2024
76238c7
added compatibilitySuppressions
mmsmits Nov 18, 2024
7521d01
Bump System.Threading.Tasks.Dataflow from 8.0.1 to 9.0.0
dependabot[bot] Nov 18, 2024
fe422e0
Bump System.Text.Json and System.Buffers
dependabot[bot] Nov 18, 2024
23111a4
Merge branch 'develop' into bugfix/2854-fix-validate-code
mmsmits Nov 19, 2024
92b4ff1
Merge pull request #2970 from FirelyTeam/dependabot/nuget/System.Thre…
mmsmits Nov 19, 2024
1dac1bf
Merge branch 'develop' into dependabot/nuget/multi-999ddd5915
mmsmits Nov 19, 2024
1b825d2
Merge pull request #2971 from FirelyTeam/dependabot/nuget/multi-999dd…
mmsmits Nov 19, 2024
75e520c
make RemoveAllNonInheritableExtensions public
mmsmits Nov 19, 2024
5946ff6
Revert "Merge pull request #2943 from FirelyTeam/feature/use-proper-s…
mmsmits Nov 20, 2024
08c5f1f
Revert "Merge pull request #2803 from FirelyTeam/fix/snapshotsource-r…
mmsmits Nov 20, 2024
a22e019
moved snapshot generation settings to base
mmsmits Nov 20, 2024
01a8aed
add compatibility suppressions
mmsmits Nov 20, 2024
16a2c29
Merge pull request #2975 from FirelyTeam/fix/reset-snapshot-generatio…
mmsmits Nov 20, 2024
40167ed
Merge branch 'develop' into feature/2965-make-removeallnoninheritable…
ewoutkramer Nov 20, 2024
cf1e39a
Merge pull request #2972 from FirelyTeam/feature/2965-make-removealln…
mmsmits Nov 20, 2024
413a374
Merge commit 'cf1e39a0405acac1a1382982dd9bf954d2d17d93' into bugfix/2…
mmsmits Nov 21, 2024
cb9cd6a
add unit tests
mmsmits Nov 21, 2024
40ae960
Merge pull request #2968 from FirelyTeam/bugfix/2854-fix-validate-code
mmsmits Nov 22, 2024
589c588
Bump Newtonsoft.Json and Microsoft.NET.Test.Sdk
dependabot[bot] Nov 25, 2024
ae63632
Merge pull request #2979 from FirelyTeam/dependabot/nuget/multi-b0b8d…
mmsmits Nov 26, 2024
80919c3
start development phase 5.11.2
mmsmits Nov 26, 2024
ed0ef29
Merge remote-tracking branch 'origin/develop' into release/5.11.1
mmsmits Nov 26, 2024
a59f771
remove compatibility suppressions
mmsmits Nov 26, 2024
ab1ff18
Merge pull request #2980 from FirelyTeam/release/5.11.1
mmsmits Nov 27, 2024
2cedb06
Bump FluentAssertions from 6.12.2 to 7.0.0
dependabot[bot] Dec 2, 2024
90c0b04
Merge pull request #2984 from FirelyTeam/dependabot/nuget/FluentAsser…
mmsmits Dec 3, 2024
a26298c
Merge remote-tracking branch 'origin/develop' into develop-6.0
Kasdejong Dec 5, 2024
eebe980
accidentally duplicated this
Kasdejong Dec 5, 2024
d6a7cc6
compatibility suppressions
Kasdejong Dec 5, 2024
647c92a
Merge branch 'develop-6.0' into feature/forward-sdk5-changes
Kasdejong Dec 9, 2024
2771d28
Merge branch 'develop-6.0' into feature/forward-sdk5-changes
Kasdejong Dec 9, 2024
2d4ed4f
compat suppressions
Kasdejong Dec 9, 2024
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
5 changes: 3 additions & 2 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## Intro:
## Breaking changes:

Hotfix: Fixed an incorrect string concatenation and subsequent argument exception when the Id of a contained resource was not set.
- EvaluationContext.WithResourceOverrides() introduced in 5.10 is refactored to now be an extension method instead of a static construction method. It should now be called on an instance of EvaluationContext, and will mutate and return that instance.
- We changed the datatype of the Attachment.Url from FhirUrl to FhirUri. The type of this element was changed with the introduction of R4. (FhirUrl doesn't exist in STU3). When we moved Attachment to base, we wrongfully put FhirUrl here, which is the more specific datatype of the two. We have corrected this.
30 changes: 8 additions & 22 deletions src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,6 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.FhirPath.FhirEvaluationContext.WithResourceOverrides(Hl7.Fhir.ElementModel.ITypedElement,Hl7.Fhir.ElementModel.ITypedElement)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Introspection.ClassMapping.get_DefinitionPath</Target>
Expand Down Expand Up @@ -372,20 +365,6 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Rest.ContentType.BuildContentType(Hl7.Fhir.Rest.ResourceFormat,System.String)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Rest.ContentType.BuildMediaType(Hl7.Fhir.Rest.ResourceFormat,System.String)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirJsonPocoSerializer.Serialize(System.Collections.Generic.IReadOnlyDictionary{System.String,System.Object},System.Text.Json.Utf8JsonWriter)</Target>
Expand Down Expand Up @@ -456,6 +435,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions.RemoveAllNonInheritableExtensions(Hl7.Fhir.Model.Element)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Utility.AnnotatableExtensions.RemoveAnnotations``1(Hl7.Fhir.Utility.IAnnotatable)</Target>
Expand Down Expand Up @@ -570,7 +556,7 @@
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.FhirPath.EvaluationContext.WithResourceOverrides(Hl7.Fhir.ElementModel.ITypedElement,Hl7.Fhir.ElementModel.ITypedElement)</Target>
<Target>M:Hl7.FhirPath.EvaluationContextExtensions.WithResourceOverrides``1(``0,Hl7.Fhir.ElementModel.ITypedElement,Hl7.Fhir.ElementModel.ITypedElement)</Target>
<Left>lib/net8.0/Hl7.Fhir.Base.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
Expand Down
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/Hl7.Fhir.Base.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public string Url
if (value == null)
UrlElement = null;
else
UrlElement = new Hl7.Fhir.Model.FhirUrl(value);
UrlElement = new Hl7.Fhir.Model.FhirUri(value);
OnPropertyChanged("Url");
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/Hl7.Fhir.Base/Model/ParametersExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Hl7.Fhir.Model
public static class ParametersExtensions
{
private const string CODEATTRIBUTE = "code";
private const string URLATTRIBUTE = "url";
private const string SYSTEMATTRIBUTE = "system";
private const string CONTEXTATTRIBUTE = "context";

Expand Down Expand Up @@ -39,12 +40,13 @@ internal static void CheckForValidityOfValidateCodeParams(this Parameters parame
{
parameters.NoDuplicates();

//If a code is provided, a system or a context must be provided (http://hl7.org/fhir/valueset-operation-validate-code.html)
if (parameters.Parameter.Any(p => p.Name == CODEATTRIBUTE) && !(parameters.Parameter.Any(p => p.Name == SYSTEMATTRIBUTE) ||
//This error was changed from system to url. See: https://chat.fhir.org/#narrow/channel/179202-terminology/topic/Required.20.24validate-code.20parameters/near/482250225
//If a code is provided, a url or a context must be provided (http://hl7.org/fhir/valueset-operation-validate-code.html)
if (parameters.Parameter.Any(p => p.Name == CODEATTRIBUTE) && !(parameters.Parameter.Any(p => p.Name == URLATTRIBUTE) ||
parameters.Parameter.Any(p => p.Name == CONTEXTATTRIBUTE)))
{
//422 Unproccesable Entity
throw new FhirOperationException($"If a code is provided, a system or a context must be provided", (HttpStatusCode)422);
throw new FhirOperationException($"If a code is provided, a url or a context must be provided", (HttpStatusCode)422);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ public static void RemoveAllConstrainedByDiffExtensions<T>(this IEnumerable<T> e
}
}


/// <summary>
/// This extension removes all non-inheritable extensions from the specified element definition and all it's child objects.
/// Non-inheritable extensions are extensions that should not be inherited by derived profiles.
/// </summary>
/// <param name="element"></param>
internal static void RemoveAllNonInheritableExtensions(this Element element)
{
if (element == null) { throw Error.ArgumentNull(nameof(element)); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class ValidateCodeParameters
private readonly string _dateAttribute = "date";
private readonly string _abstractAttribute = "abstract";
private readonly string _displayLanguageAttribute = "displayLanguage";
private readonly string _inferSystemAttribute = "inferSystem";

public ValidateCodeParameters(Parameters parameters)
{
Expand All @@ -41,6 +42,7 @@ public ValidateCodeParameters(Parameters parameters)
Date = parameters.GetSingleValue<FhirDateTime>(_dateAttribute);
Abstract = parameters.GetSingleValue<FhirBoolean>(_abstractAttribute);
DisplayLanguage = parameters.GetSingleValue<Code>(_displayLanguageAttribute);
InferSystem = parameters.GetSingleValue<FhirBoolean>(_inferSystemAttribute);
}


Expand All @@ -58,14 +60,15 @@ public ValidateCodeParameters WithValueSet(string url, string context = null, Re
return this;
}

public ValidateCodeParameters WithCode(string code = null, string system = null, string systemVersion = null, string display = null, string displayLanguage = null, string context = null)
public ValidateCodeParameters WithCode(string code = null, string system = null, string systemVersion = null, string display = null, string displayLanguage = null, string context = null, bool? inferSystem = null)
{
if (!string.IsNullOrWhiteSpace(code)) Code = new Code(code);
if (!string.IsNullOrWhiteSpace(system)) System = new FhirUri(system);
if (!string.IsNullOrWhiteSpace(systemVersion)) SystemVersion = new FhirString(systemVersion);
if (!string.IsNullOrWhiteSpace(display)) Display = new FhirString(display);
if (!string.IsNullOrWhiteSpace(displayLanguage)) DisplayLanguage = new Code(displayLanguage);
if (!string.IsNullOrWhiteSpace(context)) Context = new FhirUri(context);
if (inferSystem is { }) InferSystem = new FhirBoolean(inferSystem);
return this;
}

Expand Down Expand Up @@ -151,6 +154,8 @@ public ValidateCodeParameters WithAbstract(bool? @abstract)
/// </summary>
public Code DisplayLanguage { get; private set; }

public FhirBoolean InferSystem { get; private set; }

/// <summary>
///
/// </summary>
Expand All @@ -160,8 +165,8 @@ public Parameters Build()
var result = new Parameters();

if (Url is { }) result.Add(_urlAttribute, Url);
if (Context is { }) result.Add(_contextAttribute, Context);
if (ValueSet is { }) result.Add(_valueSetAttribute, ValueSet);
if (Context is { }) result.Add(_contextAttribute, Context);
if (ValueSetVersion is { }) result.Add(_valueSetVersionAttribute, ValueSetVersion);
if (Code is { }) result.Add(_codeAttribute, Code);
if (System is { }) result.Add(_systemAttribute, System);
Expand All @@ -171,8 +176,8 @@ public Parameters Build()
if (CodeableConcept is { }) result.Add(_codeableConceptAttribute, CodeableConcept);
if (Date is { }) result.Add(_dateAttribute, Date);
if (Abstract is { }) result.Add(_abstractAttribute, Abstract);
if (DisplayLanguage is { }) result.Add(_displayAttribute, DisplayLanguage);

if (DisplayLanguage is { }) result.Add(_displayLanguageAttribute, DisplayLanguage);
if (InferSystem is { }) result.Add(_inferSystemAttribute, InferSystem);
return result;
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/Hl7.Fhir.Conformance/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
<Right>lib/net8.0/Hl7.Fhir.Conformance.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions</Target>
<Left>lib/net8.0/Hl7.Fhir.Conformance.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.Conformance.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Model.CapabilityStatement.ImplementationComponent.get_DescriptionElement</Target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2224,17 +2224,9 @@ private async Tasks.Task<bool> ensureSnapshot(StructureDefinition sd, string pro

try
{
var shouldGenerate = _settings.RegenerationBehaviour switch
{
RegenerationSettings.TRY_USE_EXISTING => !sd.HasSnapshot,
RegenerationSettings.REGENERATE_ONCE => !sd.HasSnapshot || !sd.Snapshot.IsCreatedBySnapshotGenerator(),
#pragma warning disable CS0618 // Type or member is obsolete
RegenerationSettings.FORCE_REGENERATE => true, // possible infinite recursion
#pragma warning restore CS0618 // Type or member is obsolete
_ => throw new InvalidOperationException($"Invalid RegenerationSettings value {_settings.RegenerationBehaviour}")
};

if (_settings.GenerateSnapshotForExternalProfiles && shouldGenerate)
if (_settings.GenerateSnapshotForExternalProfiles
&& (!sd.HasSnapshot || (_settings.ForceRegenerateSnapshots && !sd.Snapshot.IsCreatedBySnapshotGenerator()))
)
{
// Automatically expand external profiles on demand
// Debug.Print($"[{nameof(SnapshotGenerator)}.{nameof(ensureSnapshot)}] Recursively generate snapshot for type profile with url: '{sd.Url}' ...");
Expand Down Expand Up @@ -2316,18 +2308,9 @@ private async Tasks.Task<ElementDefinition> getSnapshotRootElement(StructureDefi
var cachedRoot = sd.GetSnapshotRootElementAnnotation();
if (cachedRoot != null) { return cachedRoot; }
#endif
var hasValidRoot = _settings.RegenerationBehaviour switch
{
RegenerationSettings.TRY_USE_EXISTING => sd.HasSnapshot,
RegenerationSettings.REGENERATE_ONCE => sd.HasSnapshot && sd.Snapshot.IsCreatedBySnapshotGenerator(),
#pragma warning disable CS0618 // Type or member is obsolete
RegenerationSettings.FORCE_REGENERATE => false,
#pragma warning restore CS0618 // Type or member is obsolete
_ => throw new InvalidOperationException($"Invalid RegenerationSettings value {_settings.RegenerationBehaviour}")
};


// 2. Return root element definition from existing (pre-generated) snapshot, if it exists
if (hasValidRoot)
if (sd.HasSnapshot && (sd.Snapshot.IsCreatedBySnapshotGenerator() || !_settings.ForceRegenerateSnapshots))
{
// Debug.Print($"[{nameof(SnapshotGenerator)}.{nameof(getSnapshotRootElement)}] {nameof(profileUri)} = '{profileUri}' - use existing root element definition from snapshot: #{sd.Snapshot.Element[0].GetHashCode()}");
// No need to save root ElemDef annotation, as the snapshot has already been fully expanded
Expand Down
7 changes: 0 additions & 7 deletions src/Hl7.Fhir.STU3/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
<Right>lib/net8.0/Hl7.Fhir.STU3.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions</Target>
<Left>lib/net8.0/Hl7.Fhir.STU3.dll</Left>
<Right>lib/net8.0/Hl7.Fhir.STU3.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Model.ExplanationOfBenefit.ActInvoiceGroupCode.ActInvoiceInterGroupCode</Target>
Expand Down
27 changes: 5 additions & 22 deletions src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1941,17 +1941,9 @@ private async Tasks.Task<bool> ensureSnapshot(StructureDefinition sd, string pro

try
{
var shouldGenerate = _settings.RegenerationBehaviour switch
{
RegenerationSettings.TRY_USE_EXISTING => !sd.HasSnapshot,
RegenerationSettings.REGENERATE_ONCE => !sd.HasSnapshot || !sd.Snapshot.IsCreatedBySnapshotGenerator(),
#pragma warning disable CS0618 // Type or member is obsolete
RegenerationSettings.FORCE_REGENERATE => true,
#pragma warning restore CS0618 // Type or member is obsolete
_ => throw new InvalidOperationException($"Invalid RegenerationSettings value {_settings.RegenerationBehaviour}")
};

if (_settings.GenerateSnapshotForExternalProfiles && shouldGenerate)
if (_settings.GenerateSnapshotForExternalProfiles
&& (!sd.HasSnapshot || (_settings.ForceRegenerateSnapshots && !sd.Snapshot.IsCreatedBySnapshotGenerator()))
)
{
// Automatically expand external profiles on demand
// Debug.Print($"[{nameof(SnapshotGenerator)}.{nameof(ensureSnapshot)}] Recursively generate snapshot for type profile with url: '{sd.Url}' ...");
Expand Down Expand Up @@ -2033,18 +2025,9 @@ private async Tasks.Task<ElementDefinition> getSnapshotRootElement(StructureDefi
var cachedRoot = sd.GetSnapshotRootElementAnnotation();
if (cachedRoot != null) { return cachedRoot; }
#endif
var hasValidRoot = _settings.RegenerationBehaviour switch
{
RegenerationSettings.TRY_USE_EXISTING => sd.HasSnapshot,
RegenerationSettings.REGENERATE_ONCE => sd.HasSnapshot && sd.Snapshot.IsCreatedBySnapshotGenerator(),
#pragma warning disable CS0618 // Type or member is obsolete
RegenerationSettings.FORCE_REGENERATE => false,
#pragma warning restore CS0618 // Type or member is obsolete
_ => throw new InvalidOperationException($"Invalid RegenerationSettings value {_settings.RegenerationBehaviour}")
};


// 2. Return root element definition from existing (pre-generated) snapshot, if it exists
if (hasValidRoot)
if (sd.HasSnapshot && (sd.Snapshot.IsCreatedBySnapshotGenerator() || !_settings.ForceRegenerateSnapshots))
{
// Debug.Print($"[{nameof(SnapshotGenerator)}.{nameof(getSnapshotRootElement)}] {nameof(profileUri)} = '{profileUri}' - use existing root element definition from snapshot: #{sd.Snapshot.Element[0].GetHashCode()}");
// No need to save root ElemDef annotation, as the snapshot has already been fully expanded
Expand Down
Loading