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

FIX: MakeEscapedJsonString now null-checks inputs #2018

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

stuartbrown-unity
Copy link

@stuartbrown-unity stuartbrown-unity commented Sep 30, 2024

Description

Most device decriptor fields are null-checked in ComparePropertyToDeviceDescriptor, however the addition of MakeEscapedJsonString meant that 'capabilities' was not being checked anymore, and so could throw a null-ref exception if a device didn't fill this field.

Changes made

This change adds a null/empty string check to MakeEscapedJsonString to mirror the old behaviour.
Additionally this'll also now mean any devices with an empty non-null string can skip a minor StringBuilder allocation.

Testing

Local testing with gamepads to see that the resulting comparisons in ComparePropertyToDeviceDescriptor still work correctly. This was tested between null, empty, and valid json string inputs.

A new unit test has been added too to exercise the null-input path.
Unit tests were also ran.

Risk

Minor difference in construction of a default JsonString (with a non-null text field).

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

…bypass an allocation.

This matches older behaviour on null-checking descriptor fields which is needed for certain device implementations.
@unity-cla-assistant
Copy link

unity-cla-assistant commented Sep 30, 2024

CLA assistant check
All committers have signed the CLA.

@stuartbrown-unity stuartbrown-unity changed the title FIX: MakeEscapedJsonString now null-checks inputs, as some devices need this FIX: MakeEscapedJsonString now null-checks inputs Sep 30, 2024
@stuartbrown-unity stuartbrown-unity marked this pull request as ready for review September 30, 2024 11:41
@AlexTyrer AlexTyrer self-requested a review September 30, 2024 11:56
Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

LGTM, if there is an associated public issue tracker please link it to the CHANGELOG row (See other examples). Additional feedback from you @AlexTyrer ?

@ekcoh ekcoh requested a review from Pauliusd01 October 10, 2024 13:15
@ekcoh
Copy link
Collaborator

ekcoh commented Oct 10, 2024

Seems like branch has some conflicts that need to be resolved.

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

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

Conflicts on branch

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