Skip to content

Test-Json: Use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) #18141

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

Merged

Conversation

gregsdennis
Copy link
Contributor

@gregsdennis gregsdennis commented Sep 21, 2022

PR Summary

Updates the Test-Json cmdlet to use JsonSchema.Net instead of NJsonSchema in order to:

  • use System.Text.Json instead of Newtonsoft
  • support the latest JSON Schema drafts (up to 2020-12)

(continuation of #18023 - see here for additional comments)

PR Context

Resolves #18009

NJsonSchema only supports up to draft 7, which at this point is several years old and two versions behind. Additionally, it relies on Newtonsoft.Json.

This change is a merely drop-in replacement of the implementation that provides validation.

The cmdlet API doesn't change, however the cmdlet will no longer support draft 4 schemas. Draft 4 is a decade old at this point and the JSON Schema team (myself included) is encouraging tooling to only support draft 6/7 (6 is a subset of 7) and later. (In the future, support for these should be dropped as newer versions are released.) I'm not sure if this is considered a breaking change for this repo.

To assist users in their migration away from draft 4, the alterschema draft migration tool has been created.

I expect the existing test coverage is adequate to cover this change.

PR Checklist

@ghost ghost assigned iSazonov Sep 21, 2022
@gregsdennis gregsdennis changed the title Update test json to use jsonschema.net Update test json to use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) Sep 21, 2022
@gregsdennis gregsdennis changed the title Update test json to use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) Update Test-Json to use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) Sep 21, 2022
@gregsdennis gregsdennis changed the title Update Test-Json to use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) Test-Json: Use JsonSchema.Net (System.Text.Json) instead of NJsonSchema (Newtonsoft.Json) Sep 21, 2022
@iSazonov iSazonov added CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log labels Sep 21, 2022
Copy link
Member

@SteveL-MSFT SteveL-MSFT left a comment

Choose a reason for hiding this comment

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

One change requested to put error string in resx otherwise LGTM

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept labels Oct 3, 2022
@gregsdennis gregsdennis force-pushed the update-test-json-to-use-jsonschema.net branch from 6aba9c3 to df01974 Compare October 5, 2022 20:22
@gregsdennis
Copy link
Contributor Author

I'm not sure what the issue is with the various builds. I can't run the macos one, and I've never been able to get the files.wxs file regenerated right (it breaks every time I have to rebase).

As an aside, why is this file even included in the repo if it's generated at build time anyway?

@iSazonov
Copy link
Collaborator

iSazonov commented Oct 7, 2022

@gregsdennis I can not reproduce the issue locally and I hope anybody from MSFT team will help to resolve the CI issue.

@ghost ghost added the Review - Needed The PR is being reviewed label Oct 14, 2022
@ghost
Copy link

ghost commented Oct 14, 2022

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@gregsdennis
Copy link
Contributor Author

@SteveL-MSFT I could use some help getting the wxs file fixed. It has never generated right for me. This happens every time I have to rebase.

@gregsdennis
Copy link
Contributor Author

@SteveL-MSFT I cannot keep updating this branch because I can't generate the .wxs file. Please assist.

I'm not sure why this PR has languished this long. It seems like a straightforward change.

@gregsdennis
Copy link
Contributor Author

Can anyone help with this? Is there any reason why it hasn't been pulled in?

@gregsdennis
Copy link
Contributor Author

@SteveL-MSFT tagging again for an update.

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Feb 6, 2023

@gregsdennis sorry for the delay, I'm re-reviewing it today

@ghost ghost removed the Review - Needed The PR is being reviewed label Feb 6, 2023
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label May 2, 2023
Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

LGTM. @gregsdennis Thanks for your contribution, and I really appreciate your patience!

@iSazonov
Copy link
Collaborator

iSazonov commented May 2, 2023

@gregsdennis Please look test fails.

@pull-request-quantifier-deprecated

This PR has 212 quantified lines of changes. In general, a change size of upto 200 lines is ideal for the best PR experience!


Quantification details

Label      : Large
Size       : +119 -93
Percentile : 61.2%

Total files changed: 8

Change summary by file extension:
.csproj : +1 -5
.cs : +56 -31
.resx : +5 -2
.ps1 : +47 -49
.json : +10 -6

Change counts above are quantified counts, based on the PullRequestQuantifier customizations.

Why proper sizing of changes matters

Optimal pull request sizes drive a better predictable PR flow as they strike a
balance between between PR complexity and PR review overhead. PRs within the
optimal size (typical small, or medium sized PRs) mean:

  • Fast and predictable releases to production:
    • Optimal size changes are more likely to be reviewed faster with fewer
      iterations.
    • Similarity in low PR complexity drives similar review times.
  • Review quality is likely higher as complexity is lower:
    • Bugs are more likely to be detected.
    • Code inconsistencies are more likely to be detected.
  • Knowledge sharing is improved within the participants:
    • Small portions can be assimilated better.
  • Better engineering practices are exercised:
    • Solving big problems by dividing them in well contained, smaller problems.
    • Exercising separation of concerns within the code changes.

What can I do to optimize my changes

  • Use the PullRequestQuantifier to quantify your PR accurately
    • Create a context profile for your repo using the context generator
    • Exclude files that are not necessary to be reviewed or do not increase the review complexity. Example: Autogenerated code, docs, project IDE setting files, binaries, etc. Check out the Excluded section from your prquantifier.yaml context profile.
    • Understand your typical change complexity, drive towards the desired complexity by adjusting the label mapping in your prquantifier.yaml context profile.
    • Only use the labels that matter to you, see context specification to customize your prquantifier.yaml context profile.
  • Change your engineering behaviors
    • For PRs that fall outside of the desired spectrum, review the details and check if:
      • Your PR could be split in smaller, self-contained PRs instead
      • Your PR only solves one particular issue. (For example, don't refactor and code new features in the same PR).

How to interpret the change counts in git diff output

  • One line was added: +1 -0
  • One line was deleted: +0 -1
  • One line was modified: +1 -1 (git diff doesn't know about modified, it will
    interpret that line like one addition plus one deletion)
  • Change percentiles: Change characteristics (addition, deletion, modification)
    of this PR in relation to all other PRs within the repository.


Was this comment helpful? 👍  :ok_hand:  :thumbsdown: (Email)
Customize PullRequestQuantifier for this repository.

@iSazonov iSazonov requested review from SteveL-MSFT and daxian-dbw May 3, 2023 07:52
@iSazonov
Copy link
Collaborator

iSazonov commented May 3, 2023

@SteveL-MSFT @daxian-dbw Please update your review (large rebase was).

Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

New changes after my last review looks good to me.

@iSazonov iSazonov merged commit 1b248ef into PowerShell:master May 4, 2023
@iSazonov
Copy link
Collaborator

iSazonov commented May 4, 2023

@gregsdennis Thanks for your contribution!

@ghost
Copy link

ghost commented Jun 29, 2023

🎉v7.4.0-preview.4 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Large PowerShell-Docs needed The PR was reviewed and a PowerShell Docs update is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting later versions of JSON Schema
6 participants