Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Resource Manager fix for F# File Resources (Bugzilla 53515) #825

Merged
merged 3 commits into from
Apr 12, 2017

Conversation

SpiegelSoft
Copy link
Contributor

@SpiegelSoft SpiegelSoft commented Mar 20, 2017

Description of Change

In F#, loading images from files causes a null reference exception.

Bugs Fixed

https://bugzilla.xamarin.com/show_bug.cgi?id=53515

API Changes

None

Behavioral Changes

None

PR Checklist

@dnfclas
Copy link

dnfclas commented Mar 20, 2017

This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request.
Thanks,
.NET Foundation Pull Request Bot

if (prop != null)
return (int)prop.GetValue(type);
object value = type.GetFields().FirstOrDefault(p => p.Name == propertyName)?.GetValue(type)
?? type.GetProperties().FirstOrDefault(p => p.Name == propertyName)?.GetValue(type);
Copy link
Member

Choose a reason for hiding this comment

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

we prefer tabs over spaces. otherwise 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Weird -- I changed the Visual Studio option, but it seems Visual Studio loves its spaces.

Now that I think of it, memberName is probably a better argument name than propertyName.

Also, I'll be honest -- I wasn't able to get the solution running on my environment, so this request is a best guess rather than fully tested code. I believe it will solve my immediate issue though.

Copy link
Member

@StephaneDelcroix StephaneDelcroix Mar 21, 2017

Choose a reason for hiding this comment

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

-- I wasn't able to get the solution running on my environment

ouch...

I'm building a nuget of this PR and will send it to you by email so you can test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@rmarinho
Copy link
Member

@SpiegelSoft can you rebase this please ? thanks

@SpiegelSoft
Copy link
Contributor Author

Done.

Copy link
Member

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

Could you change that one, then retest, and I'll merge

return (int)prop.GetValue(type);
object value = type.GetFields().FirstOrDefault(p => p.Name == memberName)?.GetValue(type)
?? type.GetProperties().FirstOrDefault(p => p.Name == memberName)?.GetValue(type);
if (value != null)
Copy link
Member

Choose a reason for hiding this comment

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

could you add a check to make sure the cast operation won't fail ? like:

if (value!=null && value is int)

@SpiegelSoft
Copy link
Contributor Author

In fact, if the value is an int, the null check is redundant.

Done.

Copy link
Member

@StephaneDelcroix StephaneDelcroix left a comment

Choose a reason for hiding this comment

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

you shouldn't have merged the master in this PR, it makes everything messy. you should instead have rebased it on top of master.

The changes are ok, so 👍 once the PR is neat

@SpiegelSoft
Copy link
Contributor Author

SpiegelSoft commented Apr 7, 2017 via email

@StephaneDelcroix
Copy link
Member

@SpiegelSoft the easiest thing to do if you're not comfortable with git rebase -i would be to create a new branch, and only cherry-pick the commit that matters.

(if you want to keep the same pr, you'll need to rename this branch to something else, and then recreate the new one with the same name)

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.

5 participants