From 6d5ad14c3921e76b12cc22068718b472bc10cf0b Mon Sep 17 00:00:00 2001 From: mmsmits Date: Tue, 8 Oct 2024 10:56:55 +0200 Subject: [PATCH 1/8] Remove all non-inheritable extensions from the base profile before snapshotting --- .../Snapshot/SnapshotGeneratorExtensions.cs | 44 ++++++++++++++++++- .../Snapshot/SnapshotGenerator.cs | 3 +- .../Snapshot/SnapshotGeneratorExtensions.cs | 44 ++++++++++++++++++- .../Snapshot/SnapshotGeneratorTest.cs | 6 +-- .../Snapshot/SnapshotGeneratorTest.cs | 31 +++++++++++++ 5 files changed, 120 insertions(+), 8 deletions(-) diff --git a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs index b1b8688e5c..278a121572 100644 --- a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -7,9 +7,8 @@ */ using Hl7.Fhir.Model; -using Hl7.Fhir.Support; +using Hl7.Fhir.Rest; using Hl7.Fhir.Utility; -using System; using System.Collections.Generic; using System.Linq; @@ -74,6 +73,47 @@ public static void RemoveAllConstrainedByDiffExtensions(this IEnumerable e } } + + internal static void RemoveAllNonInheritableExtensions(this Element element) + { + if (element == null) { throw Error.ArgumentNull(nameof(element)); } + element.RemoveNonInheritableExtensions(); + foreach (var child in element.Children.OfType()) + { + child.RemoveAllNonInheritableExtensions(); + } + } + + internal static void RemoveNonInheritableExtensions(this IExtendable element) + { + if (element == null) { throw Error.ArgumentNull(nameof(element)); } + foreach (var ext in _nonInheritableExtensions) + { + element.RemoveExtension(ext); + } + } + + private static readonly List _nonInheritableExtensions = [ + ResourceIdentity.CORE_BASE_URL + "elementdefinition-isCommonBinding", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm-no-warnings", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-hierarchy", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-interface", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-normative-version", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-applicable-version", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-category", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-codegen-super", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-security-category", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-standards-status", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-summary", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-wg", + ResourceIdentity.CORE_BASE_URL + "replaces", + ResourceIdentity.CORE_BASE_URL + "resource-approvalDate", + ResourceIdentity.CORE_BASE_URL + "resource-effectivePeriod", + ResourceIdentity.CORE_BASE_URL + "resource-lastReviewDate", + CONSTRAINED_BY_DIFF_EXT //this is our own extension to define differences compared to the base, this can't be inherited from the base profile + ]; + // ========== For internal use only ========== // [WMR 20170209] OBSOLETE #if false diff --git a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs index 662f8531ea..01b7264441 100644 --- a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs +++ b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs @@ -399,7 +399,8 @@ private async Tasks.Task> generate(StructureDefinition s // [WMR 20170208] Moved to *AFTER* ensureBaseComponents - emits annotations... // [WMR 20160915] Derived profiles should never inherit the ChangedByDiff extension from the base structure - snapshot.Element.RemoveAllConstrainedByDiffExtensions(); + // Also remove core extensions that are not supposed to be inherited by derived profiles + snapshot.RemoveAllNonInheritableExtensions(); snapshot.Element.RemoveAllConstrainedByDiffAnnotations(); // Notify observers diff --git a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs index 2c13de5f28..9663245562 100644 --- a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -7,9 +7,8 @@ */ using Hl7.Fhir.Model; -using Hl7.Fhir.Support; +using Hl7.Fhir.Rest; using Hl7.Fhir.Utility; -using System; using System.Collections.Generic; using System.Linq; @@ -73,6 +72,47 @@ public static void RemoveAllConstrainedByDiffExtensions(this IEnumerable e } } + internal static void RemoveAllNonInheritableExtensions(this Element element) + { + if (element == null) { throw Error.ArgumentNull(nameof(element)); } + element.RemoveNonInheritableExtensions(); + foreach (var child in element.Children.OfType()) + { + child.RemoveAllNonInheritableExtensions(); + } + } + + internal static void RemoveNonInheritableExtensions(this IExtendable element) + { + if (element == null) { throw Error.ArgumentNull(nameof(element)); } + foreach (var ext in _nonInheritableExtensions) + { + element.RemoveExtension(ext); + } + } + + private static readonly List _nonInheritableExtensions = [ + ResourceIdentity.CORE_BASE_URL + "elementdefinition-isCommonBinding", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm-no-warnings", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-hierarchy", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-interface", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-normative-version", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-applicable-version", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-category", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-codegen-super", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-security-category", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-standards-status", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-summary", + ResourceIdentity.CORE_BASE_URL + "structuredefinition-wg", + ResourceIdentity.CORE_BASE_URL + "replaces", + ResourceIdentity.CORE_BASE_URL + "resource-approvalDate", + ResourceIdentity.CORE_BASE_URL + "resource-effectivePeriod", + ResourceIdentity.CORE_BASE_URL + "resource-lastReviewDate", + CONSTRAINED_BY_DIFF_EXT //this is our own extension to define differences compared to the base, this can't be inherited from the base profile + ]; + + // ========== For internal use only ========== // [WMR 20170209] OBSOLETE #if false diff --git a/src/Hl7.Fhir.Specification.STU3.Tests/Snapshot/SnapshotGeneratorTest.cs b/src/Hl7.Fhir.Specification.STU3.Tests/Snapshot/SnapshotGeneratorTest.cs index 04c280575f..ba3bc9c1e3 100644 --- a/src/Hl7.Fhir.Specification.STU3.Tests/Snapshot/SnapshotGeneratorTest.cs +++ b/src/Hl7.Fhir.Specification.STU3.Tests/Snapshot/SnapshotGeneratorTest.cs @@ -21,8 +21,8 @@ using Hl7.Fhir.Support; using Hl7.Fhir.Utility; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; using NSubstitute; +using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; @@ -2433,8 +2433,8 @@ private static bool isAlmostExactly(ElementDefinition elem, ElementDefinition ba } // Also ignore any Changed extensions on base and diff - elemClone.RemoveAllConstrainedByDiffExtensions(); - baseClone.RemoveAllConstrainedByDiffExtensions(); + elemClone.RemoveAllNonInheritableExtensions(); + baseClone.RemoveAllNonInheritableExtensions(); elemClone.RemoveAllConstrainedByDiffAnnotations(); baseClone.RemoveAllConstrainedByDiffAnnotations(); diff --git a/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs b/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs index 48fb3b9acd..8ff23d24b7 100644 --- a/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs +++ b/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs @@ -10060,6 +10060,37 @@ private StructureDefinition createVeryNestedExtension() } + [TestMethod] + public void RemoveNonInhertitableSnapshotsTest() + { + var profile = new StructureDefinition + { + Url = "http://fire.ly/StructureDefinition/example", + Snapshot = new() + { + Element = new() { + new("Example") + { + Binding = new() + { + Strength = BindingStrength.Required, + ValueSet = "http://fire.ly/ValueSet/example" + } + }, + } + } + }; + + profile.Snapshot.Element[0].AddExtension(ResourceIdentity.CORE_BASE_URL + "structuredefinition-hierarchy", new FhirString("foo")); + profile.Snapshot.Element[0].Binding.AddExtension(ResourceIdentity.CORE_BASE_URL + "elementdefinition-isCommonBinding", new FhirBoolean(true)); + + profile.Snapshot.RemoveAllNonInheritableExtensions(); + + profile.Snapshot.Element[0].Extension.Should().BeEmpty(); + profile.Snapshot.Element[0].Binding.Extension.Should().BeEmpty(); + } + + [TestMethod] public async Tasks.Task TestNewR5Elements() { From 71bfd261c7c19cde347aadbf65561956570d7dd3 Mon Sep 17 00:00:00 2001 From: mmsmits Date: Mon, 21 Oct 2024 16:15:56 +0200 Subject: [PATCH 2/8] moved SnapshotGeneration extensions to Base --- .../Snapshot/SnapshotGeneratorExtensions.cs | 0 .../Snapshot/SnapshotGeneratorExtensions.cs | 158 ------------------ 2 files changed, 158 deletions(-) rename src/{Hl7.Fhir.Conformance => Hl7.Fhir.Base}/Specification/Snapshot/SnapshotGeneratorExtensions.cs (100%) delete mode 100644 src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs diff --git a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs similarity index 100% rename from src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGeneratorExtensions.cs rename to src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs diff --git a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs deleted file mode 100644 index 9663245562..0000000000 --- a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2017, 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 Hl7.Fhir.Model; -using Hl7.Fhir.Rest; -using Hl7.Fhir.Utility; -using System.Collections.Generic; -using System.Linq; - -namespace Hl7.Fhir.Specification.Snapshot -{ - // [WMR 20170209] cf. ConstrainedByDifferentialAnnotation - // This extension indicates snapshot elements with associated differential constraints in the profile. - // Note: extensions are persisted to XML/JSON, whereas annotations are ephemeral (in-memory only) - - /// Helper methods for the class to generate and inspect custom extensions. - public static class SnapshotGeneratorExtensions - { - /// The canonical url of the extension definition that marks snapshot elements with associated differential constraints. - // public static readonly string CHANGED_BY_DIFF_EXT = "http://hl7.org/fhir/StructureDefinition/changedByDifferential"; - public static readonly string CONSTRAINED_BY_DIFF_EXT = "http://hl7.org/fhir/StructureDefinition/constrainedByDifferentialExtension"; - - /// - /// Decorate the specified snapshot element definition with a special extension - /// to indicate that the element is constrained by the differential. - /// - /// An instance. - /// An optional boolean value (default true). - /// Sets the extension to store the boolean flag. - internal static void SetConstrainedByDiffExtension(this IExtendable element, bool value = true) - { - if (element == null) { throw Error.ArgumentNull(nameof(element)); } - element.SetBoolExtension(CONSTRAINED_BY_DIFF_EXT, value); - } - - /// Determines if the snapshot element was decorated with an extension indicating the element is constrained by the differential. - /// An instance. - /// A boolean value, or null. - /// Gets the boolean flag from the extension, if it exists. - public static bool? GetConstrainedByDiffExtension(this IExtendable element) => element.GetBoolExtension(CONSTRAINED_BY_DIFF_EXT); - - /// Removes the extension from the specified element definition. - public static void RemoveConstrainedByDiffExtension(this IExtendable element) - { - if (element == null) { throw Error.ArgumentNull(nameof(element)); } - element.RemoveExtension(CONSTRAINED_BY_DIFF_EXT); - } - - /// Recursively removes all instances of the extension from the specified element definition and all it's child objects. - public static void RemoveAllConstrainedByDiffExtensions(this Element element) - { - if (element == null) { throw Error.ArgumentNull(nameof(element)); } - element.RemoveConstrainedByDiffExtension(); - foreach (var child in element.Children.OfType()) - { - child.RemoveAllConstrainedByDiffExtensions(); - } - } - - /// Recursively removes all instances of the extension from all the elements and their respective child objects. - public static void RemoveAllConstrainedByDiffExtensions(this IEnumerable elements) where T : Element - { - if (elements == null) { throw Error.ArgumentNull(nameof(elements)); } - foreach (var elem in elements) - { - elem.RemoveAllConstrainedByDiffExtensions(); - } - } - - internal static void RemoveAllNonInheritableExtensions(this Element element) - { - if (element == null) { throw Error.ArgumentNull(nameof(element)); } - element.RemoveNonInheritableExtensions(); - foreach (var child in element.Children.OfType()) - { - child.RemoveAllNonInheritableExtensions(); - } - } - - internal static void RemoveNonInheritableExtensions(this IExtendable element) - { - if (element == null) { throw Error.ArgumentNull(nameof(element)); } - foreach (var ext in _nonInheritableExtensions) - { - element.RemoveExtension(ext); - } - } - - private static readonly List _nonInheritableExtensions = [ - ResourceIdentity.CORE_BASE_URL + "elementdefinition-isCommonBinding", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-fmm-no-warnings", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-hierarchy", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-interface", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-normative-version", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-applicable-version", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-category", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-codegen-super", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-security-category", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-standards-status", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-summary", - ResourceIdentity.CORE_BASE_URL + "structuredefinition-wg", - ResourceIdentity.CORE_BASE_URL + "replaces", - ResourceIdentity.CORE_BASE_URL + "resource-approvalDate", - ResourceIdentity.CORE_BASE_URL + "resource-effectivePeriod", - ResourceIdentity.CORE_BASE_URL + "resource-lastReviewDate", - CONSTRAINED_BY_DIFF_EXT //this is our own extension to define differences compared to the base, this can't be inherited from the base profile - ]; - - - // ========== For internal use only ========== - // [WMR 20170209] OBSOLETE -#if false - - /// Removes a specific extension from the snapshot element definition and it's descendant elements, recursively. - /// An instance. - /// The canonical url of the extension. - static void ClearAllExtensions(this ElementDefinition elemDef, string uri) - { - if (elemDef != null) - { - ClearExtensions(elemDef, uri); - } - } - - static void ClearExtensions(this IEnumerable elements, string uri) where T : Base - { - if (elements != null) - { - foreach (var child in elements) - { - ClearExtensions(child, uri); - } - } - } - - static void ClearExtensions(this T element, string uri) where T : Base - { - if (element != null) - { - ClearExtension(element as IExtendable, uri); - ClearExtensions(element.Children, uri); - } - } - - static void ClearExtension(this IExtendable extendable, string uri) - { - extendable?.RemoveExtension(uri); - } -#endif - - } -} From 7244bd9c03236adbe19d040c63250d4fd19a88a4 Mon Sep 17 00:00:00 2001 From: mmsmits Date: Mon, 21 Oct 2024 16:20:08 +0200 Subject: [PATCH 3/8] removed cref --- .../Specification/Snapshot/SnapshotGeneratorExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs index 278a121572..a62df65207 100644 --- a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -18,7 +18,7 @@ namespace Hl7.Fhir.Specification.Snapshot // This extension indicates snapshot elements with associated differential constraints in the profile. // Note: extensions are persisted to XML/JSON, whereas annotations are ephemeral (in-memory only) - /// Helper methods for the class to generate and inspect custom extensions. + /// Helper methods for the SnapshotGenerator class to generate and inspect custom extensions. public static class SnapshotGeneratorExtensions { /// The canonical url of the extension definition that marks snapshot elements with associated differential constraints. From 3eee26962a86863d9bbeda25ed4d1a8bd99c69ca Mon Sep 17 00:00:00 2001 From: mmsmits Date: Mon, 21 Oct 2024 16:33:34 +0200 Subject: [PATCH 4/8] added new suppression files --- .../CompatibilitySuppressions.xml | 18 ++++++++++++++++++ .../CompatibilitySuppressions.xml | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/Hl7.Fhir.Conformance/CompatibilitySuppressions.xml create mode 100644 src/Hl7.Fhir.STU3/CompatibilitySuppressions.xml diff --git a/src/Hl7.Fhir.Conformance/CompatibilitySuppressions.xml b/src/Hl7.Fhir.Conformance/CompatibilitySuppressions.xml new file mode 100644 index 0000000000..50df2e8381 --- /dev/null +++ b/src/Hl7.Fhir.Conformance/CompatibilitySuppressions.xml @@ -0,0 +1,18 @@ + + + + + CP0001 + T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions + lib/net8.0/Hl7.Fhir.Conformance.dll + lib/net8.0/Hl7.Fhir.Conformance.dll + true + + + CP0001 + T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions + lib/netstandard2.0/Hl7.Fhir.Conformance.dll + lib/netstandard2.0/Hl7.Fhir.Conformance.dll + true + + \ No newline at end of file diff --git a/src/Hl7.Fhir.STU3/CompatibilitySuppressions.xml b/src/Hl7.Fhir.STU3/CompatibilitySuppressions.xml new file mode 100644 index 0000000000..4c6b9c5302 --- /dev/null +++ b/src/Hl7.Fhir.STU3/CompatibilitySuppressions.xml @@ -0,0 +1,18 @@ + + + + + CP0001 + T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions + lib/net8.0/Hl7.Fhir.STU3.dll + lib/net8.0/Hl7.Fhir.STU3.dll + true + + + CP0001 + T:Hl7.Fhir.Specification.Snapshot.SnapshotGeneratorExtensions + lib/netstandard2.0/Hl7.Fhir.STU3.dll + lib/netstandard2.0/Hl7.Fhir.STU3.dll + true + + \ No newline at end of file From 806545ed35c6634c6a3032f5c08d4f057fe11082 Mon Sep 17 00:00:00 2001 From: mmsmits Date: Mon, 21 Oct 2024 16:50:20 +0200 Subject: [PATCH 5/8] Also for Conformance --- .../Specification/Snapshot/SnapshotGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs index 3ab2d39af4..dddbc136ac 100644 --- a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs +++ b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs @@ -465,7 +465,7 @@ private async Tasks.Task> generate(StructureDefinition s // [WMR 20170208] Moved to *AFTER* ensureBaseComponents - emits annotations... // [WMR 20160915] Derived profiles should never inherit the ChangedByDiff extension from the base structure - snapshot.Element.RemoveAllConstrainedByDiffExtensions(); + snapshot.RemoveAllNonInheritableExtensions(); snapshot.Element.RemoveAllConstrainedByDiffAnnotations(); // Notify observers From cbcd50e4cc3c8c305c2aea54177e50616ba2e43d Mon Sep 17 00:00:00 2001 From: mmsmits Date: Mon, 21 Oct 2024 16:54:48 +0200 Subject: [PATCH 6/8] marked `RemoveAllConstrainedByDiffExtensions` as obsolete --- .../Specification/Snapshot/SnapshotGeneratorExtensions.cs | 3 +++ .../Specification/Snapshot/SnapshotGenerator.cs | 2 +- src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs | 2 +- .../Snapshot/SnapshotGeneratorTest.cs | 4 ++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs index a62df65207..42224c17ff 100644 --- a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -9,6 +9,7 @@ using Hl7.Fhir.Model; using Hl7.Fhir.Rest; using Hl7.Fhir.Utility; +using System; using System.Collections.Generic; using System.Linq; @@ -53,6 +54,7 @@ public static void RemoveConstrainedByDiffExtension(this IExtendable element) } /// Recursively removes all instances of the extension from the specified element definition and all it's child objects. + [Obsolete("Use RemoveAllConstrainedByDiffExtensions(this Element element) instead.")] public static void RemoveAllConstrainedByDiffExtensions(this Element element) { if (element == null) { throw Error.ArgumentNull(nameof(element)); } @@ -64,6 +66,7 @@ public static void RemoveAllConstrainedByDiffExtensions(this Element element) } /// Recursively removes all instances of the extension from all the elements and their respective child objects. + [Obsolete("Use RemoveAllConstrainedByDiffExtensions(this Element element) instead.")] public static void RemoveAllConstrainedByDiffExtensions(this IEnumerable elements) where T : Element { if (elements == null) { throw Error.ArgumentNull(nameof(elements)); } diff --git a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs index dddbc136ac..f7fc7fca0a 100644 --- a/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs +++ b/src/Hl7.Fhir.Conformance/Specification/Snapshot/SnapshotGenerator.cs @@ -1487,7 +1487,7 @@ private static bool copyChildren(ElementDefinitionNavigator nav, ElementDefiniti var elem = elems[pos]; // [WMR 20160826] Never inherit Changed extension from base profile! - elem.RemoveAllConstrainedByDiffExtensions(); + elem.RemoveAllNonInheritableExtensions(); elem.RemoveAllConstrainedByDiffAnnotations(); // [WMR 20160902] Initialize empty ElementDefinition.Base components if necessary diff --git a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs index 01b7264441..5e61f26684 100644 --- a/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs +++ b/src/Hl7.Fhir.STU3/Specification/Snapshot/SnapshotGenerator.cs @@ -1310,7 +1310,7 @@ private static bool copyChildren(ElementDefinitionNavigator nav, ElementDefiniti var elem = elems[pos]; // [WMR 20160826] Never inherit Changed extension from base profile! - elem.RemoveAllConstrainedByDiffExtensions(); + elem.RemoveAllNonInheritableExtensions(); elem.RemoveAllConstrainedByDiffAnnotations(); // [WMR 20160902] Initialize empty ElementDefinition.Base components if necessary diff --git a/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs b/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs index 8ff23d24b7..6b55878261 100644 --- a/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs +++ b/src/Hl7.Fhir.Specification.Shared.Tests/Snapshot/SnapshotGeneratorTest.cs @@ -2561,8 +2561,8 @@ private static bool isAlmostExactly(ElementDefinition elem, ElementDefinition ba } // Also ignore any Changed extensions on base and diff - elemClone.RemoveAllConstrainedByDiffExtensions(); - baseClone.RemoveAllConstrainedByDiffExtensions(); + elemClone.RemoveAllNonInheritableExtensions(); + baseClone.RemoveAllNonInheritableExtensions(); elemClone.RemoveAllConstrainedByDiffAnnotations(); baseClone.RemoveAllConstrainedByDiffAnnotations(); From 016e7b0ee90c05b5ec9b900044a5fbbcab26dfbb Mon Sep 17 00:00:00 2001 From: Marten Smits Date: Tue, 22 Oct 2024 16:57:01 +0200 Subject: [PATCH 7/8] Update src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs Co-authored-by: Ewout Kramer --- .../Specification/Snapshot/SnapshotGeneratorExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs index 42224c17ff..d406b1aa04 100644 --- a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -54,7 +54,7 @@ public static void RemoveConstrainedByDiffExtension(this IExtendable element) } /// Recursively removes all instances of the extension from the specified element definition and all it's child objects. - [Obsolete("Use RemoveAllConstrainedByDiffExtensions(this Element element) instead.")] + [Obsolete("Use RemoveAllNonInheritableExtensions(this Element element) instead.")] public static void RemoveAllConstrainedByDiffExtensions(this Element element) { if (element == null) { throw Error.ArgumentNull(nameof(element)); } From 40f323bc2467331b24c23b33b56007878ef80cfa Mon Sep 17 00:00:00 2001 From: Marten Smits Date: Tue, 22 Oct 2024 16:57:24 +0200 Subject: [PATCH 8/8] Update src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs Co-authored-by: Ewout Kramer --- .../Specification/Snapshot/SnapshotGeneratorExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs index d406b1aa04..3cd2cb0abb 100644 --- a/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs +++ b/src/Hl7.Fhir.Base/Specification/Snapshot/SnapshotGeneratorExtensions.cs @@ -66,7 +66,7 @@ public static void RemoveAllConstrainedByDiffExtensions(this Element element) } /// Recursively removes all instances of the extension from all the elements and their respective child objects. - [Obsolete("Use RemoveAllConstrainedByDiffExtensions(this Element element) instead.")] + [Obsolete("Use RemoveAllNonInheritableExtensions(this IEnumerable elements) instead.")] public static void RemoveAllConstrainedByDiffExtensions(this IEnumerable elements) where T : Element { if (elements == null) { throw Error.ArgumentNull(nameof(elements)); }