Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2550 parser error ignore customization #2730

Merged
merged 21 commits into from
Mar 19, 2024

Conversation

Kasdejong
Copy link
Member

Description

  • Added support for fluent configuration (ignore error/enforce errors/select error ignore mask from preset deserializer mode) of the System.Text.Json deserializer by adding extension methods to the Json options.
  • Changed the internal behaviour of the json converter to maintain its own serialization engine as opposed to directly maintaining a low-level deserializer.
  • Added an interface for distinction between element model serialization engines and poco serialization engines.

Related issues

Closes [#2550].

Testing

Added tests to assert correct behaviour of the error-filtering predicates and their prevalence according to where in the chain they are called

@Kasdejong Kasdejong requested a review from mmsmits March 6, 2024 10:02
@mmsmits mmsmits requested a review from ewoutkramer March 6, 2024 10:39
Copy link
Member

@ewoutkramer ewoutkramer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No fundamental issues, just some remarks ;-)

@Kasdejong Kasdejong self-assigned this Mar 19, 2024
@Kasdejong Kasdejong removed their assignment Mar 19, 2024
Predicate<CodedException>? ignoreFilter = null)
internal void SetEnforcedErrors(IEnumerable<string> toEnforce)
{
Engine ??= (FhirSerializationEngineFactory.Strict(inspector, serializerSettings, deserializerSettings) as PocoSerializationEngine)!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(x as Y)! suggests you really want ((Y)x) here, which will never return null (and throw if the cast does not work).


internal void SetIgnoredErrors(IEnumerable<string> toIgnore)
{
Engine ??= (FhirSerializationEngineFactory.Strict(inspector, serializerSettings, deserializerSettings) as PocoSerializationEngine)!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this factory code should be in a small private function, instead of repeating it.

DisallowSchemaLocation = mode is Mode.Strict,
PermissiveParsing = mode is Mode.Permissive or Mode.Ostrich,
ValidateFhirXhtml = mode is Mode.Strict
DisallowSchemaLocation = mode is Mode.Strict, PermissiveParsing = mode is Mode.Permissive or Mode.Ostrich, ValidateFhirXhtml = mode is Mode.Strict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird reformat?

namespace Hl7.Fhir.Serialization;

public interface IFhirExtendedSerializationEngine : IFhirSerializationEngine
internal interface IFhirExtendedSerializationEngine : IFhirSerializationEngine
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this interface anymore?

@Kasdejong Kasdejong requested a review from ewoutkramer March 19, 2024 14:24
@ewoutkramer ewoutkramer enabled auto-merge March 19, 2024 14:32
@Kasdejong Kasdejong removed the request for review from mmsmits March 19, 2024 16:17
@Kasdejong Kasdejong dismissed mmsmits’s stale review March 19, 2024 16:20

Not needed anymore

@ewoutkramer ewoutkramer merged commit bd07ced into develop Mar 19, 2024
16 checks passed
@ewoutkramer ewoutkramer deleted the 2550-parser-error-ignore-customization branch March 19, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants