Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
156 changes: 155 additions & 1 deletion src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
Expand Down Expand Up @@ -113,6 +113,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.DeserializerModes</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>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.FhirJsonBuilderExtensions</Target>
Expand Down Expand Up @@ -169,6 +176,20 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.PrimitiveParseHandler</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>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.SerializationEngineExtensions</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>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.SerializerSettings</Target>
Expand Down Expand Up @@ -344,6 +365,13 @@
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.DeserializerModes</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.FhirJsonBuilderExtensions</Target>
Expand Down Expand Up @@ -400,6 +428,20 @@
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.PrimitiveParseHandler</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.SerializationEngineExtensions</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Hl7.Fhir.Serialization.SerializerSettings</Target>
Expand Down Expand Up @@ -477,6 +519,13 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Serialization.BaseFhirParser.Settings</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>F:Hl7.Fhir.Serialization.FhirJsonException.INCORRECT_BASE64_DATA_CODE</Target>
Expand Down Expand Up @@ -2024,6 +2073,41 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.#ctor(Hl7.Fhir.Introspection.ModelInspector,Hl7.Fhir.Serialization.ParserSettings)</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.BaseFhirParser.Parse(Hl7.Fhir.ElementModel.ISourceNode,System.Type)</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.BaseFhirParser.Parse(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.Serialization.BaseFhirParser.Parse``1(Hl7.Fhir.ElementModel.ISourceNode)</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.BaseFhirParser.Parse``1(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.Serialization.BaseFhirXmlPocoSerializer.#ctor(Hl7.Fhir.Specification.FhirRelease)</Target>
Expand Down Expand Up @@ -2052,6 +2136,20 @@
<Right>lib/net8.0/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.DataAnnotationDeserialzationValidator.#ctor(Hl7.Fhir.Validation.NarrativeValidationKind)</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.DataAnnotationDeserialzationValidator.get_NarrativeValidation</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.DataAnnotationDeserialzationValidator.ValidateInstance(System.Object,Hl7.Fhir.Serialization.InstanceDeserializationContext@,Hl7.Fhir.Validation.CodedValidationException[]@)</Target>
Expand Down Expand Up @@ -2451,6 +2549,13 @@
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Serialization.BaseFhirParser.Settings</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Hl7.Fhir.Serialization.FhirJsonException.INCORRECT_BASE64_DATA_CODE</Target>
Expand Down Expand Up @@ -3998,6 +4103,41 @@
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.#ctor(Hl7.Fhir.Introspection.ModelInspector,Hl7.Fhir.Serialization.ParserSettings)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.Parse(Hl7.Fhir.ElementModel.ISourceNode,System.Type)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.Parse(Hl7.Fhir.ElementModel.ITypedElement)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.Parse``1(Hl7.Fhir.ElementModel.ISourceNode)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirParser.Parse``1(Hl7.Fhir.ElementModel.ITypedElement)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.BaseFhirXmlPocoSerializer.#ctor(Hl7.Fhir.Specification.FhirRelease)</Target>
Expand Down Expand Up @@ -4026,6 +4166,20 @@
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.DataAnnotationDeserialzationValidator.#ctor(Hl7.Fhir.Validation.NarrativeValidationKind)</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.DataAnnotationDeserialzationValidator.get_NarrativeValidation</Target>
<Left>lib/netstandard2.1/Hl7.Fhir.Base.dll</Left>
<Right>lib/netstandard2.1/Hl7.Fhir.Base.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Hl7.Fhir.Serialization.DataAnnotationDeserialzationValidator.ValidateInstance(System.Object,Hl7.Fhir.Serialization.InstanceDeserializationContext@,Hl7.Fhir.Validation.CodedValidationException[]@)</Target>
Expand Down
101 changes: 50 additions & 51 deletions src/Hl7.Fhir.Base/ElementModel/PocoBuilderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,70 @@
* available at https://github.com/FirelyTeam/firely-net-sdk/blob/master/LICENSE
*/


#nullable enable

using Hl7.Fhir.Utility;
using System;

namespace Hl7.Fhir.Serialization
namespace Hl7.Fhir.Serialization;

/// <summary>Configuration settings for the PocoBuilder class.</summary>
public class PocoBuilderSettings
{
/// <summary>Configuration settings for the PocoBuilder class.</summary>
public class PocoBuilderSettings
{
/// <summary>
/// Do not throw when encountering values not parseable as a member of an enumeration in a Poco.
/// </summary>
public bool AllowUnrecognizedEnums { get; set; } // = false
/// <summary>
/// Do not throw when encountering values not parseable as a member of an enumeration in a Poco.
/// </summary>
public bool AllowUnrecognizedEnums { get; set; } // = false

/// <summary>
/// Do not throw when the data has an element that does not map to a property in the Poco.
/// </summary>
public bool IgnoreUnknownMembers { get; set; } // = false
/// <summary>
/// Do not throw when the data has an element that does not map to a property in the Poco.
/// </summary>
public bool IgnoreUnknownMembers { get; set; } // = false

/// <summary>
/// Allow to parse a FHIR dateTime values into an element of type date.
/// </summary>
/// <remarks>
/// Needed for backward compatibility with old parser for resources which were saved and considered valid in the past.
/// </remarks>>
[Obsolete("Needed for backward compatibility with old parser for resources which were saved and considered valid in the past. " +
"Should not be used in new code.")]
public bool TruncateDateTimeToDate { get; set; }
/// <summary>
/// Allow to parse a FHIR dateTime values into an element of type date.
/// </summary>
/// <remarks>
/// Needed for backward compatibility with old parser for resources which were saved and considered valid in the past.
/// </remarks>>
[Obsolete("Needed for backward compatibility with old parser for resources which were saved and considered valid in the past. " +
"Should not be used in new code.")]
public bool TruncateDateTimeToDate { get; set; }

/// <summary>
/// A Handler to permit intercepting Exceptions during parsing
/// </summary>
public ExceptionNotificationHandler ExceptionHandler { get; set; }
/// <summary>
/// A Handler to permit intercepting Exceptions during parsing
/// </summary>
public ExceptionNotificationHandler? ExceptionHandler { get; set; }

/// <summary>Default constructor. Creates a new <see cref="PocoBuilderSettings"/> instance with default property values.</summary>
public PocoBuilderSettings() { }
/// <summary>Default constructor. Creates a new <see cref="PocoBuilderSettings"/> instance with default property values.</summary>
public PocoBuilderSettings() { }

/// <summary>Clone constructor. Generates a new <see cref="PocoBuilderSettings"/> instance initialized from the state of the specified instance.</summary>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public PocoBuilderSettings(PocoBuilderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));
other.CopyTo(this);
}
/// <summary>Clone constructor. Generates a new <see cref="PocoBuilderSettings"/> instance initialized from the state of the specified instance.</summary>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public PocoBuilderSettings(PocoBuilderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));
other.CopyTo(this);
}

/// <summary>Copy all configuration settings to another instance.</summary>
/// <param name="other">Another <see cref="PocoBuilderSettings"/> instance.</param>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public void CopyTo(PocoBuilderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));
/// <summary>Copy all configuration settings to another instance.</summary>
/// <param name="other">Another <see cref="PocoBuilderSettings"/> instance.</param>
/// <exception cref="ArgumentNullException">The specified argument is <c>null</c>.</exception>
public void CopyTo(PocoBuilderSettings other)
{
if (other == null) throw Error.ArgumentNull(nameof(other));

other.AllowUnrecognizedEnums = AllowUnrecognizedEnums;
other.IgnoreUnknownMembers = IgnoreUnknownMembers;
other.AllowUnrecognizedEnums = AllowUnrecognizedEnums;
other.IgnoreUnknownMembers = IgnoreUnknownMembers;
#pragma warning disable CS0618 // Type or member is obsolete
other.TruncateDateTimeToDate = TruncateDateTimeToDate;
other.TruncateDateTimeToDate = TruncateDateTimeToDate;
#pragma warning restore CS0618 // Type or member is obsolete
other.ExceptionHandler = ExceptionHandler;
}
other.ExceptionHandler = ExceptionHandler;
}

/// <summary>Creates a new <see cref="PocoBuilderSettings"/> object that is a copy of the current instance.</summary>
public PocoBuilderSettings Clone() => new PocoBuilderSettings(this);
/// <summary>Creates a new <see cref="PocoBuilderSettings"/> object that is a copy of the current instance.</summary>
public PocoBuilderSettings Clone() => new(this);

/// <summary>Creates a new <see cref="PocoBuilderSettings"/> instance with default property values.</summary>
public static PocoBuilderSettings CreateDefault() => new PocoBuilderSettings();
}
/// <summary>Creates a new <see cref="PocoBuilderSettings"/> instance with default property values.</summary>
public static PocoBuilderSettings CreateDefault() => new PocoBuilderSettings();
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ public static BaseFhirClient WithOstrichModeSerializer(this BaseFhirClient clien

public static BaseFhirClient WithCustomIgnoreListSerializer(this BaseFhirClient client, string[] ignoreList)
{
client.Settings.SerializationEngine = FhirSerializationEngineFactory.Custom(client.Inspector, ignoreList.IsInList());
var xmlSettings = new FhirXmlPocoDeserializerSettings().Ignoring(ignoreList);
var jsonSettings = new FhirJsonConverterOptions().Ignoring(ignoreList);

client.Settings.SerializationEngine = FhirSerializationEngineFactory.Custom(client.Inspector, jsonSettings, xmlSettings);

return client;
}

Expand Down
Loading