Skip to content

Commit

Permalink
Merge branch 'develop-6.0' into 2936-make-comparison-consistent
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
  • Loading branch information
ewoutkramer committed Jan 20, 2025
2 parents c40e360 + 755728c commit 8f0dba5
Show file tree
Hide file tree
Showing 723 changed files with 34,771 additions and 32,509 deletions.
829 changes: 733 additions & 96 deletions src/Hl7.Fhir.Base/CompatibilitySuppressions.xml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/Hl7.Fhir.Base/ElementModel/TypedElementParseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static class TypedElementParseExtensions

/// <inheritdoc cref="ParseBindable"/>
[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static Element? ParseBindableInternal(this ITypedElement instance)
internal static Element? ParseBindableInternal(this ITypedElement instance)
{
return instance.InstanceType switch
{
Expand Down Expand Up @@ -87,7 +87,7 @@ public static Quantity ParseQuantity(this ITypedElement instance)
#pragma warning restore CS0618 // Type or member is obsolete

[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static Quantity ParseQuantityInternal(this ITypedElement instance)
internal static Quantity ParseQuantityInternal(this ITypedElement instance)
{
var newQuantity = new Quantity
{
Expand All @@ -112,7 +112,7 @@ public static Quantity ParseQuantityInternal(this ITypedElement instance)
#pragma warning restore CS0618 // Type or member is obsolete

[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static T ParsePrimitiveInternal<T>(this ITypedElement instance) where T : PrimitiveType, new()
internal static T ParsePrimitiveInternal<T>(this ITypedElement instance) where T : PrimitiveType, new()
=> new() { ObjectValue = instance.Value };

#endregion
Expand All @@ -125,7 +125,7 @@ public static Coding ParseCoding(this ITypedElement instance)


[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static Coding ParseCodingInternal(this ITypedElement instance)
internal static Coding ParseCodingInternal(this ITypedElement instance)
{
return new Coding()
{
Expand All @@ -145,7 +145,7 @@ public static ResourceReference ParseResourceReference(this ITypedElement instan
#pragma warning restore CS0618 // Type or member is obsolete

[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static ResourceReference ParseResourceReferenceInternal(this ITypedElement instance)
internal static ResourceReference ParseResourceReferenceInternal(this ITypedElement instance)
{
return new ResourceReference()
{
Expand All @@ -162,7 +162,7 @@ public static CodeableConcept ParseCodeableConcept(this ITypedElement instance)
#pragma warning restore CS0618 // Type or member is obsolete

[Obsolete("WARNING! Intended for internal API usage exclusively")]
public static CodeableConcept ParseCodeableConceptInternal(this ITypedElement instance)
internal static CodeableConcept ParseCodeableConceptInternal(this ITypedElement instance)
{
return new CodeableConcept()
{
Expand Down
4 changes: 0 additions & 4 deletions src/Hl7.Fhir.Base/FhirPath/Parser/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ from fraction in Parse.Number
from _ in Parse.Char('$')
from name in Parse.String("this").XOr(Parse.String("index")).Or(Parse.String("total")).Text()
select name;

[Obsolete("This lexer is no longer used by the fhirpath parser as it processes the tokens correctly", false)]
public static readonly Parser<string> Quantity =
Parse.Regex(P.Quantity.QUANTITYREGEX);
}


Expand Down
6 changes: 0 additions & 6 deletions src/Hl7.Fhir.Base/Introspection/ClassMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,6 @@ private ClassMapping(string name, Type nativeType, FhirRelease release)
/// </summary>
public Type? EnumType { get; private init; }

/// <summary>
/// Indicates whether this class represents the nested complex type for a backbone element.
/// </summary>
[Obsolete("These types are now generally called Backbone types, so use IsBackboneType instead.")]
public bool IsNestedType { get => IsBackboneType; set => IsBackboneType = value; }

/// <summary>
/// Indicates whether this class represents the nested complex type for a backbone element.
/// </summary>
Expand Down
26 changes: 25 additions & 1 deletion src/Hl7.Fhir.Base/Model/Base.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,36 @@ public static IEnumerable<Base> Children(this Base instance)
foreach (var item in list)
yield return item;
break;
case("value", _) when instance is PrimitiveType:
case ("value", _) when instance is PrimitiveType:
yield break;
default:
yield return (Base)element.Value;
break;
}
}
}

public static T DeepCopy<T>(this T source) where T : Base => (T)source.DeepCopyInternal();

public static void CopyTo<T>(this T source, T target) where T : Base => source.CopyToInternal(target);

public static IEnumerable<T> DeepCopy<T>(this IEnumerable<T> source) where T : Base => source.DeepCopyInternal();

internal static IEnumerable<T> DeepCopyInternal<T>(this IEnumerable<T> source) where T : Base
{
return source.Select(item => item.DeepCopy()).ToList();
}

internal static void CopyToInternal(this Dictionary<string, object> source, Dictionary<string, object> target)
{
foreach ((string key, object value) in source)
{
target[key] = value switch
{
Base baseValue => baseValue.DeepCopy(),
IEnumerable<Base> baseList => baseList.DeepCopyInternal(),
_ => throw new InvalidOperationException($"Unexpected type in overflow: key {key} is of type {value.GetType()}, but either Base or IEnumerable<Base> was expected.")
};
}
}
}
16 changes: 8 additions & 8 deletions src/Hl7.Fhir.Base/Model/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ POSSIBILITY OF SUCH DAMAGE.

namespace Hl7.Fhir.Model;

public abstract partial class Base : IDeepCopyable, IAnnotatable,
public abstract partial class Base : IAnnotatable,
IValidatableObject, INotifyPropertyChanged
{
/// <summary>
Expand All @@ -64,13 +64,13 @@ public abstract partial class Base : IDeepCopyable, IAnnotatable,

private AnnotationList annotations => LazyInitializer.EnsureInitialized(ref _annotations, () => [])!;

public IEnumerable<object> Annotations(Type type)
{
if (type == typeof(IFhirValueProvider))
return [this];
else
return annotations.OfType(type);
}
public IEnumerable<object> Annotations(Type type)
{
if (type == typeof(IFhirValueProvider))
return [this];
else
return annotations.OfType(type);
}

public void AddAnnotation(object annotation) => annotations.AddAnnotation(annotation);

Expand Down
7 changes: 7 additions & 0 deletions src/Hl7.Fhir.Base/Model/CodeOfT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,11 @@ public override IEnumerable<ValidationResult> Validate(ValidationContext validat
var result = COVE.INVALID_CODED_VALUE(validationContext, ObjectValue, EnumUtility.GetName<T>()).AsResult(validationContext);
return baseResults.Append(result);
}

protected internal override Base DeepCopyInternal()
{
var instance = new Code<T>();
CopyToInternal(instance);
return instance;
}
}
21 changes: 21 additions & 0 deletions src/Hl7.Fhir.Base/Model/DynamicDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public class DynamicDataType : DataType, IDynamicType
public string? DynamicTypeName { get; set; }

public override string TypeName => DynamicTypeName ?? base.TypeName;

protected internal override Base DeepCopyInternal()
{
var instance = new DynamicDataType { DynamicTypeName = DynamicTypeName };
CopyToInternal(instance);
return instance;
}
}


Expand All @@ -39,6 +46,13 @@ public class DynamicResource : Resource, IDynamicType
public string? DynamicTypeName { get; set; }

public override string TypeName => DynamicTypeName ?? base.TypeName;

protected internal override Base DeepCopyInternal()
{
var instance = new DynamicResource { DynamicTypeName = DynamicTypeName };
CopyToInternal(instance);
return instance;
}
}


Expand All @@ -53,4 +67,11 @@ public class DynamicPrimitive : PrimitiveType, IDynamicType
public string? DynamicTypeName { get; set; }

public override string TypeName => DynamicTypeName ?? base.TypeName;

protected internal override Base DeepCopyInternal()
{
var instance = new DynamicPrimitive { DynamicTypeName = DynamicTypeName };
CopyToInternal(instance);
return instance;
}
}
43 changes: 22 additions & 21 deletions src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ public int? Pages
}
}

public override IDeepCopyable CopyTo(IDeepCopyable other)
protected internal override void CopyToInternal(Base other)
{
var dest = other as Attachment;

Expand All @@ -545,26 +545,27 @@ public override IDeepCopyable CopyTo(IDeepCopyable other)
throw new ArgumentException("Can only copy to an object of the same type", "other");
}

base.CopyTo(dest);
if(ContentTypeElement != null) dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy();
if(LanguageElement != null) dest.LanguageElement = (Hl7.Fhir.Model.Code)LanguageElement.DeepCopy();
if(DataElement != null) dest.DataElement = (Hl7.Fhir.Model.Base64Binary)DataElement.DeepCopy();
if(UrlElement != null) dest.UrlElement = (Hl7.Fhir.Model.PrimitiveType)UrlElement.DeepCopy();
if(SizeElement != null) dest.SizeElement = (Hl7.Fhir.Model.PrimitiveType)SizeElement.DeepCopy();
if(HashElement != null) dest.HashElement = (Hl7.Fhir.Model.Base64Binary)HashElement.DeepCopy();
if(TitleElement != null) dest.TitleElement = (Hl7.Fhir.Model.FhirString)TitleElement.DeepCopy();
if(CreationElement != null) dest.CreationElement = (Hl7.Fhir.Model.FhirDateTime)CreationElement.DeepCopy();
if(HeightElement != null) dest.HeightElement = (Hl7.Fhir.Model.PositiveInt)HeightElement.DeepCopy();
if(WidthElement != null) dest.WidthElement = (Hl7.Fhir.Model.PositiveInt)WidthElement.DeepCopy();
if(FramesElement != null) dest.FramesElement = (Hl7.Fhir.Model.PositiveInt)FramesElement.DeepCopy();
if(DurationElement != null) dest.DurationElement = (Hl7.Fhir.Model.FhirDecimal)DurationElement.DeepCopy();
if(PagesElement != null) dest.PagesElement = (Hl7.Fhir.Model.PositiveInt)PagesElement.DeepCopy();
return dest;
}

public override IDeepCopyable DeepCopy()
{
return CopyTo(new Attachment());
base.CopyToInternal(dest);
if(ContentTypeElement != null) dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopyInternal();
if(LanguageElement != null) dest.LanguageElement = (Hl7.Fhir.Model.Code)LanguageElement.DeepCopyInternal();
if(DataElement != null) dest.DataElement = (Hl7.Fhir.Model.Base64Binary)DataElement.DeepCopyInternal();
if(UrlElement != null) dest.UrlElement = (Hl7.Fhir.Model.PrimitiveType)UrlElement.DeepCopyInternal();
if(SizeElement != null) dest.SizeElement = (Hl7.Fhir.Model.PrimitiveType)SizeElement.DeepCopyInternal();
if(HashElement != null) dest.HashElement = (Hl7.Fhir.Model.Base64Binary)HashElement.DeepCopyInternal();
if(TitleElement != null) dest.TitleElement = (Hl7.Fhir.Model.FhirString)TitleElement.DeepCopyInternal();
if(CreationElement != null) dest.CreationElement = (Hl7.Fhir.Model.FhirDateTime)CreationElement.DeepCopyInternal();
if(HeightElement != null) dest.HeightElement = (Hl7.Fhir.Model.PositiveInt)HeightElement.DeepCopyInternal();
if(WidthElement != null) dest.WidthElement = (Hl7.Fhir.Model.PositiveInt)WidthElement.DeepCopyInternal();
if(FramesElement != null) dest.FramesElement = (Hl7.Fhir.Model.PositiveInt)FramesElement.DeepCopyInternal();
if(DurationElement != null) dest.DurationElement = (Hl7.Fhir.Model.FhirDecimal)DurationElement.DeepCopyInternal();
if(PagesElement != null) dest.PagesElement = (Hl7.Fhir.Model.PositiveInt)PagesElement.DeepCopyInternal();
}

protected internal override Base DeepCopyInternal()
{
var instance = new Attachment();
CopyToInternal(instance);
return instance;
}

public override bool CompareChildren(Base other, IEqualityComparer<Base> comparer)
Expand Down
7 changes: 3 additions & 4 deletions src/Hl7.Fhir.Base/Model/Generated/BackboneElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<Hl7.Fhir.Model.Extension> ModifierExtension

private List<Hl7.Fhir.Model.Extension> _ModifierExtension;

public override IDeepCopyable CopyTo(IDeepCopyable other)
protected internal override void CopyToInternal(Base other)
{
var dest = other as BackboneElement;

Expand All @@ -77,9 +77,8 @@ public override IDeepCopyable CopyTo(IDeepCopyable other)
throw new ArgumentException("Can only copy to an object of the same type", "other");
}

base.CopyTo(dest);
if(ModifierExtension.Any()) dest.ModifierExtension = new List<Hl7.Fhir.Model.Extension>(ModifierExtension.DeepCopy());
return dest;
base.CopyToInternal(dest);
if(ModifierExtension.Any()) dest.ModifierExtension = new List<Hl7.Fhir.Model.Extension>(ModifierExtension.DeepCopyInternal());
}

public override bool CompareChildren(Base other, IEqualityComparer<Base> comparer)
Expand Down
7 changes: 3 additions & 4 deletions src/Hl7.Fhir.Base/Model/Generated/BackboneType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<Hl7.Fhir.Model.Extension> ModifierExtension

private List<Hl7.Fhir.Model.Extension> _ModifierExtension;

public override IDeepCopyable CopyTo(IDeepCopyable other)
protected internal override void CopyToInternal(Base other)
{
var dest = other as BackboneType;

Expand All @@ -77,9 +77,8 @@ public override IDeepCopyable CopyTo(IDeepCopyable other)
throw new ArgumentException("Can only copy to an object of the same type", "other");
}

base.CopyTo(dest);
if(ModifierExtension.Any()) dest.ModifierExtension = new List<Hl7.Fhir.Model.Extension>(ModifierExtension.DeepCopy());
return dest;
base.CopyToInternal(dest);
if(ModifierExtension.Any()) dest.ModifierExtension = new List<Hl7.Fhir.Model.Extension>(ModifierExtension.DeepCopyInternal());
}

public override bool CompareChildren(Base other, IEqualityComparer<Base> comparer)
Expand Down
8 changes: 4 additions & 4 deletions src/Hl7.Fhir.Base/Model/Generated/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace Hl7.Fhir.Model
[FhirType("Base","http://hl7.org/fhir/StructureDefinition/Base")]
public abstract partial class Base
{
public virtual IDeepCopyable CopyTo(IDeepCopyable other)
protected internal virtual void CopyToInternal(Base other)
{
var dest = other as Base;

Expand All @@ -66,11 +66,11 @@ public virtual IDeepCopyable CopyTo(IDeepCopyable other)
if (_annotations is not null)
dest.annotations.AddRange(annotations);

return dest;
if (Overflow.Any())
Overflow.CopyToInternal(dest.Overflow);
}

public virtual IDeepCopyable DeepCopy() =>
CopyTo((IDeepCopyable)Activator.CreateInstance(GetType())!);
protected internal abstract Base DeepCopyInternal();

}

Expand Down
7 changes: 7 additions & 0 deletions src/Hl7.Fhir.Base/Model/Generated/Base64Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ public byte[] Value
set { ObjectValue = value; OnPropertyChanged("Value"); }
}

protected internal override Base DeepCopyInternal()
{
var instance = new Base64Binary();
CopyToInternal(instance);
return instance;
}

}

}
Expand Down
19 changes: 10 additions & 9 deletions src/Hl7.Fhir.Base/Model/Generated/Binary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public byte[] Data
}
}

public override IDeepCopyable CopyTo(IDeepCopyable other)
protected internal override void CopyToInternal(Base other)
{
var dest = other as Binary;

Expand All @@ -189,17 +189,18 @@ public override IDeepCopyable CopyTo(IDeepCopyable other)
throw new ArgumentException("Can only copy to an object of the same type", "other");
}

base.CopyTo(dest);
if(ContentTypeElement != null) dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopy();
if(SecurityContext != null) dest.SecurityContext = (Hl7.Fhir.Model.ResourceReference)SecurityContext.DeepCopy();
if(ContentElement != null) dest.ContentElement = (Hl7.Fhir.Model.Base64Binary)ContentElement.DeepCopy();
if(DataElement != null) dest.DataElement = (Hl7.Fhir.Model.Base64Binary)DataElement.DeepCopy();
return dest;
base.CopyToInternal(dest);
if(ContentTypeElement != null) dest.ContentTypeElement = (Hl7.Fhir.Model.Code)ContentTypeElement.DeepCopyInternal();
if(SecurityContext != null) dest.SecurityContext = (Hl7.Fhir.Model.ResourceReference)SecurityContext.DeepCopyInternal();
if(ContentElement != null) dest.ContentElement = (Hl7.Fhir.Model.Base64Binary)ContentElement.DeepCopyInternal();
if(DataElement != null) dest.DataElement = (Hl7.Fhir.Model.Base64Binary)DataElement.DeepCopyInternal();
}

public override IDeepCopyable DeepCopy()
protected internal override Base DeepCopyInternal()
{
return CopyTo(new Binary());
var instance = new Binary();
CopyToInternal(instance);
return instance;
}

public override bool CompareChildren(Base other, IEqualityComparer<Base> comparer)
Expand Down
Loading

0 comments on commit 8f0dba5

Please sign in to comment.