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

Map range attribute to value range annotation #1673

Merged
merged 3 commits into from
May 28, 2020

Conversation

citizenmatt
Copy link
Member

@citizenmatt citizenmatt commented May 27, 2020

ReSharper/Rider 2020.1 introduced integer value dataflow analysis, which can track the value of integers through a piece of code. The ValueRange attribute can provide a hint that an integer value is only between a min and max value.

int-dataflow-blog@2x-1

Unity's Range attribute can be applied to fields, and the Inspector will ensure that the value of the field is kept between the given min and max value.

This PR will map Unity's Range attribute to ReSharper's ValueRange annotation, using the Range's min/max values as the hint to ReSharper's dataflow analysis. Note that ReSharper's analysis only works with integer values, so Range attributes on float values are ignored.

@citizenmatt citizenmatt added this to the Rider 2020.2 milestone May 27, 2020
@citizenmatt citizenmatt self-assigned this May 27, 2020
@citizenmatt citizenmatt marked this pull request as ready for review May 27, 2020 20:39
@citizenmatt citizenmatt merged commit fe3cecc into net202 May 28, 2020
@citizenmatt citizenmatt deleted the feature/range-attribute branch May 28, 2020 17:31
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.

1 participant