Navigation Menu

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] Compiled converters #358

Merged
merged 1 commit into from Sep 26, 2016
Merged

[XamlC] Compiled converters #358

merged 1 commit into from Sep 26, 2016

Conversation

StephaneDelcroix
Copy link
Member

@StephaneDelcroix StephaneDelcroix commented Sep 15, 2016

Description of Change

Do not use the TypeConverter at runtime. Instead output the resulting code directly

so, this Xaml:

<Foo RectangleBP="4,8,16,32" BackgroundColor="Pink"/>

is compiled to this IL

IL_006d:  ldloc.1 
IL_006e:  ldsfld class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty Xamarin.Forms.Xaml.UnitTests.CompiledTypeConverter::RectangleBPProperty
IL_0073:  ldc.r8 4.
IL_007c:  ldc.r8 8.
IL_0085:  ldc.r8 16.
IL_008e:  ldc.r8 32.
IL_0097:  newobj instance void valuetype [Xamarin.Forms.Core]Xamarin.Forms.Rectangle::'.ctor'(float64, float64, float64, float64)
IL_009c:  box [Xamarin.Forms.Core]Xamarin.Forms.Rectangle
IL_00a1:  callvirt instance void class [Xamarin.Forms.Core]Xamarin.Forms.BindableObject::SetValue(class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty, object)
IL_00a6:  ldloc.1 
IL_00a7:  ldsfld class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty [Xamarin.Forms.Core]Xamarin.Forms.VisualElement::BackgroundColorProperty
IL_00ac:  ldsfld valuetype [Xamarin.Forms.Core]Xamarin.Forms.Color [Xamarin.Forms.Core]Xamarin.Forms.Color::Pink
IL_00b1:  box [Xamarin.Forms.Core]Xamarin.Forms.Color
IL_00b6:  callvirt instance void class [Xamarin.Forms.Core]Xamarin.Forms.BindableObject::SetValue(class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty, object)

instead of this one without the patch

IL_0076:  ldloc 1
IL_007a:  ldsfld class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty Xamarin.Forms.Xaml.UnitTests.CompiledTypeConverter::RectangleBPProperty
IL_007f:  newobj instance void class [Xamarin.Forms.Core]Xamarin.Forms.RectangleTypeConverter::'.ctor'()
IL_0084:  ldstr "4,8,16,32"
IL_0089:  callvirt instance object class [Xamarin.Forms.Core]Xamarin.Forms.RectangleTypeConverter::ConvertFromInvariantString(string)
IL_008e:  callvirt instance void class [Xamarin.Forms.Core]Xamarin.Forms.BindableObject::SetValue(class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty, object)
IL_0093:  ldloc 1

IL_0097:  ldsfld class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty [Xamarin.Forms.Core]Xamarin.Forms.VisualElement::BackgroundColorProperty
IL_009c:  newobj instance void class [Xamarin.Forms.Core]Xamarin.Forms.ColorTypeConverter::'.ctor'()
IL_00a1:  ldstr "Pink"
IL_00a6:  callvirt instance object class [Xamarin.Forms.Core]Xamarin.Forms.ColorTypeConverter::ConvertFromInvariantString(string)
IL_00ab:  callvirt instance void class [Xamarin.Forms.Core]Xamarin.Forms.BindableObject::SetValue(class [Xamarin.Forms.Core]Xamarin.Forms.BindableProperty, object)

Bugs Fixed

None, but this should provide a measurable speed gain, and huge reduction of the amount of IL generated, in most case, especially when compiling Styles or anything that depends on an IExtendedTypeConverter

API Changes

Behavioral Changes

if any, you know how to reach me

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

@jassmith jassmith merged commit 55f0665 into master Sep 26, 2016
@StephaneDelcroix StephaneDelcroix deleted the xamlc-compiledconverters branch January 31, 2017 20:05
@samhouts samhouts added this to the 2.3.4 milestone Jun 27, 2018
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.

None yet

4 participants