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

feature: allow WireUpControls to find View members #1217

Merged
merged 2 commits into from Jan 9, 2017

Conversation

Projects
None yet
3 participants
@Qonstrukt
Member

Qonstrukt commented Dec 12, 2016

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
This will allow WireUpControls() to wire up View properties, and not just subclasses of it.

What is the current behavior? (You can also link to an open issue here)
WireUpControls() doesn't currently wire up View properties, just subclasses.

What is the new behavior (if this is a feature change)?
WireUpControls() now also wires up View properties.

Does this PR introduce a breaking change?
It shouldn't, unless you were expecting null values on your View properties. If you were working around this with manual FindViewById calls you're assigning the same view twice to the same property, worst-case. (Considering you weren't using duplicate names for views or controls in the first place.)

Please check if the PR fulfills these requirements

Other information:

@ghuntley

This comment has been minimized.

Show comment
Hide comment
@ghuntley

ghuntley Jan 4, 2017

Member

Thanks for the PR @Qonstrukt. It's a 👍 from me. Can one of our @reactiveui/reviewers-android reviewers review as well. Looking to get this in ReactiveUI v7.1 in the next couple of days.

Member

ghuntley commented Jan 4, 2017

Thanks for the PR @Qonstrukt. It's a 👍 from me. Can one of our @reactiveui/reviewers-android reviewers review as well. Looking to get this in ReactiveUI v7.1 in the next couple of days.

@@ -78,7 +78,7 @@ public static T GetControl<T>(this Fragment This, [CallerMemberName]string prope
public static void WireUpControls(this ILayoutViewHost This)
{
var members = This.GetType().GetRuntimeProperties()
.Where(m => m.PropertyType.IsSubclassOf(typeof(View)));

This comment has been minimized.

@kentcb

kentcb Jan 7, 2017

Contributor

Can you please change all these to use IsAssignableFrom:

.Where(m => typeof(View).IsAssignableFrom(m.PropertyType)))
@kentcb

kentcb Jan 7, 2017

Contributor

Can you please change all these to use IsAssignableFrom:

.Where(m => typeof(View).IsAssignableFrom(m.PropertyType)))

This comment has been minimized.

@Qonstrukt

Qonstrukt Jan 7, 2017

Member

Sure, that should be no problem. I choose for this solution because of a post I saw with some good points on SO: http://stackoverflow.com/a/2742288.
But I don't think the false positives are a problem here because we're not using value-type comparisons.

@Qonstrukt

Qonstrukt Jan 7, 2017

Member

Sure, that should be no problem. I choose for this solution because of a post I saw with some good points on SO: http://stackoverflow.com/a/2742288.
But I don't think the false positives are a problem here because we're not using value-type comparisons.

@kentcb

This comment has been minimized.

Show comment
Hide comment
@kentcb

kentcb Jan 7, 2017

Contributor

lgtm. Thanks @Qonstrukt! 👍

Contributor

kentcb commented Jan 7, 2017

lgtm. Thanks @Qonstrukt! 👍

@ghuntley ghuntley changed the title from Allow WireUpControls to find View members to feature: allow WireUpControls to find View members Jan 9, 2017

@ghuntley ghuntley added this to the 7-vNext milestone Jan 9, 2017

@ghuntley ghuntley merged commit 276f963 into reactiveui:develop Jan 9, 2017

1 check passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details

Qonstrukt added a commit to Qonstrukt/ReactiveUI that referenced this pull request Jan 29, 2017

@Qonstrukt Qonstrukt deleted the Qonstrukt:wire-up-views branch Jan 29, 2017

@Qonstrukt Qonstrukt referenced this pull request Jan 29, 2017

Merged

feat: more flexible WireUpControls implementation #1250

1 of 3 tasks complete

ghuntley added a commit that referenced this pull request Jan 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment