Skip to content

[MLA-825] Add default values for SideChannel IncomingMessages methods #3751

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
merged 6 commits into from
Apr 8, 2020

Conversation

chriselion
Copy link
Contributor

@chriselion chriselion commented Apr 7, 2020

Proposed change(s)

To assist with backwards compatibility across side channels, this adds a default value when reading from IncomingMessages. This will let us add data to the messages in the future, but still allow reading from older versions.

Note that this only falls back to the default if it's at the end of the buffer. Trying to read an int when there's only 1 byte left will still raise/throw, but I think this is the correct behavior in that case.

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

https://jira.unity3d.com/browse/MLA-825

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

/// <returns></returns>
public string ReadString()
public string ReadString(string defaultValue = default)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we default to "" instead?

/// <returns></returns>
public IList<float> ReadFloatList()
public IList<float> ReadFloatList(IList<float> defaultValue = default)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if there's a better default here.

Copy link
Contributor

@surfnerd surfnerd left a comment

Choose a reason for hiding this comment

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

LGTM

Co-Authored-By: Chris Goy <goyenator@gmail.com>
Co-Authored-By: Chris Goy <christopherg@unity3d.com>
@chriselion chriselion merged commit 7a02ae7 into master Apr 8, 2020
@delete-merged-branch delete-merged-branch bot deleted the MLA-825-side-channel-default branch April 8, 2020 22:22
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants