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

[XamlC] use op_implicit where we should #580

Merged
merged 5 commits into from Dec 1, 2016

Conversation

Projects
None yet
3 participants
@StephaneDelcroix
Copy link
Member

commented Nov 30, 2016

Description of Change

Align XamlC with Xaml capabilities.
More conversions are possible, and coming, but this PR only address the regression

Bugs Fixed

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of master at time of PR
  • Changes adhere to coding standard
  • Consolidate commits as makes sense
@@ -851,6 +851,10 @@ static bool CanSetValue(FieldReference bpRef, INode node, IXmlLineInfo iXmlLineI
return false;

var bpTypeRef = bpRef.GetBindablePropertyType(iXmlLineInfo, module);
var implicitOperator = varValue.VariableType.GetImplicitOperatorTo(bpTypeRef, module);
if (implicitOperator != null)

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

using op_implicit on SetValue allows that to work on ABP or BP without setter defined

{
var implicitOperatorsOnFromType = fromType.GetMethods(md => md.IsPublic && md.IsStatic && md.IsSpecialName && md.Name == "op_Implicit", module);
var implicitOperatorsOnToType = toType.GetMethods(md => md.IsPublic && md.IsStatic && md.IsSpecialName && md.Name == "op_Implicit", module);
var implicitOperators = implicitOperatorsOnFromType.Concat(implicitOperatorsOnToType).ToList();

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

op_implicit can be defined on the source or the target. check for both

public SV_Foo BPFoo {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

throw NRE to make sure the values are set using SetValue and not the property accessor. We still have to declare the property so XamlC knows the type of the BP

//{
// var page = new SetValue(useCompiledXaml);
// Assert.AreEqual("Foo", ((SV_Foo)page.implicit1.GetValue(MockViewWithValues.BPFooProperty)).Value);
//}

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

not supported on Xaml-nonC right now

//{
// var page = new SetValue(useCompiledXaml);
// Assert.AreEqual("Foo", page.implicit3.Foo.Value);
//}

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

not supported on Xaml-nonC right now

it's a placeholder for when I'll come back to this to fix it, not a leftover

{
var layout = new XStatic(useCompiledXaml);
Assert.AreEqual("ic_close.png", layout.ToolbarItems[0].Icon.File);
}

This comment has been minimized.

Copy link
@StephaneDelcroix

StephaneDelcroix Nov 30, 2016

Author Member

this case is now already covered in the SetValue set of tests

@StephaneDelcroix StephaneDelcroix force-pushed the fix-bz48242 branch from 78e0e86 to af67077 Dec 1, 2016

@StephaneDelcroix StephaneDelcroix merged commit e413e0c into master Dec 1, 2016

@StephaneDelcroix StephaneDelcroix deleted the fix-bz48242 branch Dec 1, 2016

StephaneDelcroix added a commit that referenced this pull request Dec 1, 2016

[XamlC] use op_implicit where we should (#580)
* [XamlC] (passing) test for 48242

* [XamlC] (failing) test for 48242

* [XamlC] more op_implicit conversions

* additional test

* fix rebase

jonathanpeppers pushed a commit to Hitcents/Xamarin.Forms that referenced this pull request Jan 26, 2017

@samhouts samhouts modified the milestones: 2.3.4, 2.3.3 Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.