diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2016-10-12 09:11:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 09:11:29 +0200 |
commit | 0a9f7bbc5598906feb59bae714d5bbc6d37919e2 (patch) | |
tree | 282c665c2cd4b855c737d9f5bcac98897e43e53d | |
parent | 46b57aaa0e9e902537c1cc8c99e4c7bd07c70657 (diff) | |
download | xamarin-forms-0a9f7bbc5598906feb59bae714d5bbc6d37919e2.tar.gz xamarin-forms-0a9f7bbc5598906feb59bae714d5bbc6d37919e2.tar.bz2 xamarin-forms-0a9f7bbc5598906feb59bae714d5bbc6d37919e2.zip |
[XamlG] Fully qualify method names (#417)
4 files changed, 49 insertions, 10 deletions
diff --git a/Xamarin.Forms.Build.Tasks/XamlGTask.cs b/Xamarin.Forms.Build.Tasks/XamlGTask.cs index 79a49c46..a0813a5c 100644 --- a/Xamarin.Forms.Build.Tasks/XamlGTask.cs +++ b/Xamarin.Forms.Build.Tasks/XamlGTask.cs @@ -113,10 +113,6 @@ namespace Xamarin.Forms.Build.Tasks var declNs = new CodeNamespace(rootNs); ccu.Namespaces.Add(declNs); - declNs.Imports.Add(new CodeNamespaceImport("System")); - declNs.Imports.Add(new CodeNamespaceImport("Xamarin.Forms")); - declNs.Imports.Add(new CodeNamespaceImport("Xamarin.Forms.Xaml")); - var declType = new CodeTypeDeclaration(rootType); declType.IsPartial = true; declType.BaseTypes.Add(baseType); @@ -136,8 +132,8 @@ namespace Xamarin.Forms.Build.Tasks declType.Members.Add(initcomp); initcomp.Statements.Add(new CodeMethodInvokeExpression( - new CodeThisReferenceExpression(), - "LoadFromXaml", new CodeTypeOfExpression(declType.Name))); + new CodeTypeReferenceExpression(new CodeTypeReference("global::Xamarin.Forms.Xaml.Extensions")), + "LoadFromXaml", new CodeThisReferenceExpression(), new CodeTypeOfExpression(declType.Name))); foreach (var entry in namesAndTypes) { @@ -160,8 +156,9 @@ namespace Xamarin.Forms.Build.Tasks var find_invoke = new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( - new CodeThisReferenceExpression(), - "FindByName", type), new CodePrimitiveExpression(name)); + new CodeTypeReferenceExpression(new CodeTypeReference("global::Xamarin.Forms.NameScopeExtensions")), + "FindByName", type), + new CodeThisReferenceExpression(), new CodePrimitiveExpression(name)); //CodeCastExpression cast = new CodeCastExpression (type, find_invoke); diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml new file mode 100644 index 00000000..283ec9b9 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Foo.Xamarin.Bar.Bz43301"> + <ContentPage.Content> + </ContentPage.Content> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml.cs new file mode 100644 index 00000000..e57f42d1 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43301.xaml.cs @@ -0,0 +1,31 @@ +using Xamarin.Forms; +using NUnit.Framework; + +namespace Foo.Xamarin.Bar +{ + public partial class Bz43301 : ContentPage + { + public Bz43301() + { + InitializeComponent(); + } + + public Bz43301(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + [TestFixture] + class Tests + { + [TestCase(true)] + [TestCase(false)] + //No need for any actual [Test]. If this compiles, the bug is fixed. + public void DoesCompile(bool useCompiledXaml) + { + var layout = new Bz43301(useCompiledXaml); + Assert.Pass(); + } + } + } +}
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index dc7f7ea1..a5ebbd92 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -368,9 +368,12 @@ <Compile Include="XStaticException.xaml.cs"> <DependentUpon>XStaticException.xaml</DependentUpon> </Compile> - <Compile Include="CompiledTypeConverter.xaml.cs" > + <Compile Include="CompiledTypeConverter.xaml.cs"> <DependentUpon>CompiledTypeConverter.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Bz43301.xaml.cs"> + <DependentUpon>Bz43301.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -656,7 +659,10 @@ <EmbeddedResource Include="XStaticException.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> - <EmbeddedResource Include="CompiledTypeConverter.xaml" > + <EmbeddedResource Include="CompiledTypeConverter.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> + <EmbeddedResource Include="Issues\Bz43301.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> </ItemGroup> |