From 4b9a9cd3a11e188e286e6f4ccd28be52f84d7e89 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 22 Apr 2019 11:51:44 +0300 Subject: [PATCH] Fixed step into --- src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs | 10 +++++----- .../XamlIl/AvaloniaXamlIlRuntimeCompiler.cs | 4 ++-- .../XamlIl/Runtime/XamlIlRuntimeHelpers.cs | 5 +---- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs index 5b0322a342..2dfac41523 100644 --- a/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs +++ b/src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs @@ -74,9 +74,9 @@ namespace Avalonia.Build.Tasks .First(c => c.Parameters.Count == 1)); var runtimeHelpers = typeSystem.GetType("Avalonia.Markup.Xaml.XamlIl.Runtime.XamlIlRuntimeHelpers"); - var getRootServiceProvider = asm.MainModule.ImportReference( - typeSystem.GetTypeReference(runtimeHelpers).Resolve().Methods - .First(x => x.Name == "GetRootServiceProviderV1")); + var rootServiceProviderField = asm.MainModule.ImportReference( + typeSystem.GetTypeReference(runtimeHelpers).Resolve().Fields + .First(x => x.Name == "RootServiceProviderV1")); var loaderDispatcherDef = new TypeDefinition("CompiledAvaloniaXaml", "!XamlLoader", TypeAttributes.Class, asm.MainModule.TypeSystem.Object); @@ -162,7 +162,7 @@ namespace Avalonia.Build.Tasks MethodAttributes.Static | MethodAttributes.Private, asm.MainModule.TypeSystem.Void); trampoline.Parameters.Add(new ParameterDefinition(classTypeDefinition)); classTypeDefinition.Methods.Add(trampoline); - trampoline.Body.Instructions.Add(Instruction.Create(OpCodes.Call, getRootServiceProvider)); + trampoline.Body.Instructions.Add(Instruction.Create(OpCodes.Ldsfld, rootServiceProviderField)); trampoline.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg_0)); trampoline.Body.Instructions.Add(Instruction.Create(OpCodes.Call, compiledPopulateMethod)); trampoline.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); @@ -247,7 +247,7 @@ namespace Avalonia.Build.Tasks i.Add(Instruction.Create(OpCodes.Newobj, parameterlessConstructor)); else { - i.Add(Instruction.Create(OpCodes.Call, getRootServiceProvider)); + i.Add(Instruction.Create(OpCodes.Ldsfld, rootServiceProviderField)); i.Add(Instruction.Create(OpCodes.Call, compiledBuildMethod)); } diff --git a/src/Markup/Avalonia.Markup.Xaml/XamlIl/AvaloniaXamlIlRuntimeCompiler.cs b/src/Markup/Avalonia.Markup.Xaml/XamlIl/AvaloniaXamlIlRuntimeCompiler.cs index 24f8acc26c..c0df0f03cf 100644 --- a/src/Markup/Avalonia.Markup.Xaml/XamlIl/AvaloniaXamlIlRuntimeCompiler.cs +++ b/src/Markup/Avalonia.Markup.Xaml/XamlIl/AvaloniaXamlIlRuntimeCompiler.cs @@ -142,7 +142,7 @@ namespace Avalonia.Markup.Xaml.XamlIl var createCb = Expression.Lambda>( Expression.Convert(Expression.Call( created.GetMethod(AvaloniaXamlIlCompiler.BuildName), isp), typeof(object)), isp).Compile(); - return createCb(XamlIlRuntimeHelpers.GetRootServiceProviderV1()); + return createCb(XamlIlRuntimeHelpers.RootServiceProviderV1); } else { @@ -152,7 +152,7 @@ namespace Avalonia.Markup.Xaml.XamlIl var populateCb = Expression.Lambda>( Expression.Call(populate, isp, Expression.Convert(epar, populate.GetParameters()[1].ParameterType)), isp, epar).Compile(); - populateCb(XamlIlRuntimeHelpers.GetRootServiceProviderV1(), rootInstance); + populateCb(XamlIlRuntimeHelpers.RootServiceProviderV1, rootInstance); return rootInstance; } } diff --git a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs index 2b4bff2059..433c641717 100644 --- a/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs +++ b/src/Markup/Avalonia.Markup.Xaml/XamlIl/Runtime/XamlIlRuntimeHelpers.cs @@ -125,10 +125,7 @@ namespace Avalonia.Markup.Xaml.XamlIl.Runtime } } - public static IServiceProvider GetRootServiceProviderV1() - { - return new RootServiceProvider(); - } + public static readonly IServiceProvider RootServiceProviderV1 = new RootServiceProvider(); class RootServiceProvider : IServiceProvider, IAvaloniaXamlIlParentStackProvider {