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

Blacklist setLifecycleOwner method in databinding field parsing, fixes #412 #418

Merged
merged 3 commits into from
Apr 8, 2018

Conversation

ngsilverman
Copy link
Contributor

ViewDataBinding subclasses can now override the setLifecycleOwner method causing it to be erroneously detected as a model field. This fix introduces a field blacklist to ignore this method and possibly others in the future.

To reproduce the issue and create a test for it I had to update the Android plugin version which forced me to also update Gradle, the target SDK, and the paging library. I removed the buildToolsVersion declarations to remove a warning (the build tools version is now provided by the Android plugin from what I understand).

@ngsilverman ngsilverman requested a review from elihart April 8, 2018 00:02
setMainThreadExecutor(UiThreadExecutor)
setBackgroundThreadExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
setNotifyExecutor(UiThreadExecutor)
setFetchExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

val dataBindingClassElement: Element?
get() = getElementByName(dataBindingClassName, elementUtils, typeUtils)
private val dataBindingClassElement: TypeElement?
get() = getElementByName(dataBindingClassName, elementUtils, typeUtils) as TypeElement?
Copy link
Contributor

@elihart elihart Apr 8, 2018

Choose a reason for hiding this comment

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

should this be as? TypeElement instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@elihart I'm thinking: if getElementByName doesn't return a TypeElement or null then something unexpected is happening since we're passing it a ClassName. In fact maybe it would make more sense to change the return type of getElementByName(ClassName name, Elements elements, Types types). Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the return type to TypeElement and everything still builds and all tests are passing so seems reasonable.

…#412

ViewDataBinding subclasses can now override the setLifecycleOwner
method causing it to be erroneously detected as a model property.
@ngsilverman ngsilverman force-pushed the nsilverman-databinding-method-blacklist branch from d0b0dc5 to c8c51ff Compare April 8, 2018 00:39
Copy link
Contributor

@elihart elihart left a comment

Choose a reason for hiding this comment

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

Great! thanks

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.

2 participants