Skip to content

Commit

Permalink
Merge branch '3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarinho committed Jun 29, 2018
2 parents 955a4aa + 3090843 commit ffa53d3
Show file tree
Hide file tree
Showing 84 changed files with 1,615 additions and 2,690 deletions.
27 changes: 11 additions & 16 deletions .nuspec/Xamarin.Forms.targets
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlGTask" AssemblyFile="$(MSBuildThisFileDirectory)Xamarin.Forms.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.CssGTask" AssemblyFile="$(MSBuildThisFileDirectory)Xamarin.Forms.Build.Tasks.dll"/>
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.CssGTask" AssemblyFile="$(MSBuildThisFileDirectory)Xamarin.Forms.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlCTask" AssemblyFile="$(MSBuildThisFileDirectory)Xamarin.Forms.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.GetTasksAbi" AssemblyFile="$(MSBuildThisFileDirectory)Xamarin.Forms.Build.Tasks.dll" />

<PropertyGroup>
<SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
Expand All @@ -26,25 +25,12 @@
<IsXBuild Condition="'$(MSBuildRuntimeType)' == ''">true</IsXBuild>
<IsXBuild Condition="'$(MSBuildRuntimeType)' != ''">false</IsXBuild>
</PropertyGroup>

<Target Name="_ValidateXFTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform" Condition="'$(XFDisableTargetsValidation)' != 'True'">
<Error
Text="Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s)."
Code="XF001"
Condition="'$(_XFTargetsImportedAgain)' == 'True'" />

<GetTasksAbi>
<Output TaskParameter="AbiVersion" PropertyName="_XFTasksAbi" />
</GetTasksAbi >

<PropertyGroup>
<_XFTasksExpectedAbi>5</_XFTasksExpectedAbi>
</PropertyGroup>

<Error
Text="Xamarin.Forms tasks do not match targets. Please ensure that all projects reference the same version of Xamarin.Forms, and if the error persists, please restart the IDE."
Code="XF002"
Condition="'$(_XFTasksAbi)' != '$(_XFTasksExpectedAbi)'" />
</Target>

<Target Name="_ValidateMSBuild" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
Expand All @@ -54,6 +40,15 @@
Condition="'$(IsXBuild)' == 'true'" />
</Target>

<Target Name="_ValidateNETFrameworkVersion"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' AND '$(TargetFrameworkVersion.Substring(1))' &lt; '4.7' ">
<Error
Text="XF requires .NETFramework >= v4.7. You have '$(TargetFrameworkVersion)'"
Code="XF004"
/>
</Target>

<!-- XamlG -->
<Target Name="UpdateDesignTimeXaml" DependsOnTargets="XamlG"/>

Expand Down
1 change: 1 addition & 0 deletions GitInfo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.0
74 changes: 31 additions & 43 deletions Xamarin.Forms.Build.Tasks/DebugXamlCTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;

using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Mdb;
using Mono.Cecil.Pdb;
using Mono.Cecil.Rocks;

using Xamarin.Forms.Xaml;
using static Microsoft.Build.Framework.MessageImportance;

namespace Xamarin.Forms.Build.Tasks
{
Expand All @@ -18,28 +16,21 @@ public class DebugXamlCTask : XamlTask
public override bool Execute(out IList<Exception> thrownExceptions)
{
thrownExceptions = null;
Logger = Logger ?? new Logger(null);
Logger.LogLine(MessageImportance.Normal, "Preparing debug code for xamlc, assembly: {0}", Assembly);
LoggingHelper.LogMessage(Normal, $"{new string(' ', 0)}Preparing debug code for xamlc, assembly: {Assembly}");

var resolver = new DefaultAssemblyResolver();
if (!string.IsNullOrEmpty(DependencyPaths))
{
foreach (var dep in DependencyPaths.Split(';'))
{
Logger.LogLine(MessageImportance.Low, "Adding searchpath {0}", dep);
if (!string.IsNullOrEmpty(DependencyPaths)) {
foreach (var dep in DependencyPaths.Split(';')) {
LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Adding searchpath {dep}");
resolver.AddSearchDirectory(dep);
}
}
if (!string.IsNullOrEmpty(ReferencePath))
{
if (!string.IsNullOrEmpty(ReferencePath)) {
var paths = ReferencePath.Replace("//", "/").Split(';');
foreach (var p in paths)
{
foreach (var p in paths) {
var searchpath = Path.GetDirectoryName(p);
Logger.LogLine(MessageImportance.Low, "Adding searchpath {0}", searchpath);
LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Adding searchpath {searchpath}");
resolver.AddSearchDirectory(searchpath);
// LogLine (3, "Referencing {0}", p);
// resolver.AddAssembly (p);
}
}

Expand All @@ -51,41 +42,39 @@ public override bool Execute(out IList<Exception> thrownExceptions)
AssemblyResolver = resolver
})) {
foreach (var module in assemblyDefinition.Modules) {
Logger.LogLine(MessageImportance.Low, " Module: {0}", module.Name);
LoggingHelper.LogMessage(Low, $"{new string(' ', 2)}Module: {module.Name}");
foreach (var resource in module.Resources.OfType<EmbeddedResource>()) {
Logger.LogString(MessageImportance.Low, " Resource: {0}... ", resource.Name);
string classname;
if (!resource.IsXaml(module, out classname)) {
Logger.LogLine(MessageImportance.Low, "skipped.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 4)}Resource: {resource.Name}");
if (!resource.IsXaml(module, out var classname)) {
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}skipped.");
continue;
} else
Logger.LogLine(MessageImportance.Low, "");
}
TypeDefinition typeDef = module.GetType(classname);
if (typeDef == null) {
Logger.LogLine(MessageImportance.Low, "no type found... skipped.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}no type found... skipped.");
continue;
}

var initComp = typeDef.Methods.FirstOrDefault(md => md.Name == "InitializeComponent");
if (initComp == null) {
Logger.LogLine(MessageImportance.Low, "no InitializeComponent found... skipped.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}no InitializeComponent found... skipped.");
continue;
}
var initCompRuntime = typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime");
if (initCompRuntime == null) {
Logger.LogString(MessageImportance.Low, " Creating empty {0}.__InitComponentRuntime ...", typeDef.Name);
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Creating empty {typeDef.Name}.__InitComponentRuntime");
initCompRuntime = new MethodDefinition("__InitComponentRuntime", initComp.Attributes, initComp.ReturnType);
initCompRuntime.Body.InitLocals = true;
Logger.LogLine(MessageImportance.Low, "done.");
Logger.LogString(MessageImportance.Low, " Copying body of InitializeComponent to __InitComponentRuntime ...", typeDef.Name);
LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Copying body of InitializeComponent to __InitComponentRuntime");
initCompRuntime.Body = new MethodBody(initCompRuntime);
var iCRIl = initCompRuntime.Body.GetILProcessor();
foreach (var instr in initComp.Body.Instructions)
iCRIl.Append(instr);
initComp.Body.Instructions.Clear();
initComp.Body.GetILProcessor().Emit(OpCodes.Ret);
typeDef.Methods.Add(initCompRuntime);
Logger.LogLine(MessageImportance.Low, "done.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done.");
}

// IL_0000: ldarg.0
Expand All @@ -103,23 +92,23 @@ public override bool Execute(out IList<Exception> thrownExceptions)
// IL_0019: callvirt instance void class Xamarin.Forms.Xaml.XamlcTests.MyPage::__InitComponentRuntime()
// IL_001e: ret

var altCtor =
typeDef.Methods.Where(
md => md.IsConstructor && md.Parameters.Count == 1 && md.Parameters[0].ParameterType == module.TypeSystem.Boolean)
.FirstOrDefault();
var altCtor = typeDef.Methods.FirstOrDefault(md => md.IsConstructor
&& md.Parameters.Count == 1
&& md.Parameters[0].ParameterType == module.TypeSystem.Boolean);
if (altCtor != null)
Logger.LogString(MessageImportance.Low, " Replacing body of {0}.{0} (bool {1}) ... ", typeDef.Name, altCtor.Parameters[0].Name);
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing body of {typeDef.Name}.{typeDef.Name} (bool {altCtor.Parameters[0].Name})");
else {
Logger.LogString(MessageImportance.Low, " Adding {0}.{0} (bool useCompiledXaml) ... ", typeDef.Name);
LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Adding {typeDef.Name}.{typeDef.Name} (bool useCompiledXaml)");
altCtor = new MethodDefinition(".ctor",
MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName |
MethodAttributes.RTSpecialName, module.TypeSystem.Void);
altCtor.Parameters.Add(new ParameterDefinition("useCompiledXaml", ParameterAttributes.None,
module.TypeSystem.Boolean));
}

var body = new MethodBody(altCtor);
body.InitLocals = true;
var body = new MethodBody(altCtor) {
InitLocals = true
};
var il = body.GetILProcessor();
var br2 = Instruction.Create(OpCodes.Ldarg_0);
var ret = Instruction.Create(OpCodes.Ret);
Expand All @@ -142,17 +131,16 @@ public override bool Execute(out IList<Exception> thrownExceptions)
altCtor.Body = body;
if (!typeDef.Methods.Contains(altCtor))
typeDef.Methods.Add(altCtor);
Logger.LogLine(MessageImportance.Low, "done.");
LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done.");
}

Logger.LogLine(MessageImportance.Low, "");
}
Logger.LogString(MessageImportance.Normal, "Writing the assembly... ");
LoggingHelper.LogMessage(Normal, $"{new string(' ', 0)}Writing the assembly.");
assemblyDefinition.Write(new WriterParameters {
WriteSymbols = debug
});
}
Logger.LogLine(MessageImportance.Normal, "done.");
LoggingHelper.LogMessage(Normal, $"{new string(' ', 2)}done.");

return true;
}
Expand Down
14 changes: 0 additions & 14 deletions Xamarin.Forms.Build.Tasks/GetTasksAbi.cs

This file was deleted.

79 changes: 0 additions & 79 deletions Xamarin.Forms.Build.Tasks/Logger.cs

This file was deleted.

20 changes: 16 additions & 4 deletions Xamarin.Forms.Build.Tasks/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
using System.Reflection;
using System.Runtime.CompilerServices;


[assembly: AssemblyTitle("Xamarin.Forms.Build.Tasks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyFileVersion(
ThisAssembly.Git.BaseVersion.Major + "."
+ ThisAssembly.Git.BaseVersion.Minor + "."
+ ThisAssembly.Git.BaseVersion.Patch + "."
+ ThisAssembly.Git.Commits)]

[assembly: AssemblyInformationalVersion(
ThisAssembly.Git.BaseVersion.Major + "."
+ ThisAssembly.Git.BaseVersion.Minor + "."
+ ThisAssembly.Git.BaseVersion.Patch + "."
+ ThisAssembly.Git.Commits + "-"
+ ThisAssembly.Git.Branch + "+"
+ ThisAssembly.Git.Commit)]

[assembly: InternalsVisibleTo("xamlg")]
[assembly: InternalsVisibleTo("xamlc")]
[assembly: InternalsVisibleTo("Xamarin.Forms.Xaml.UnitTests")]
#if DEBUG
[assembly:InternalsVisibleTo("Xamarin.Forms.Xaml.UnitTests")]
#endif
Loading

0 comments on commit ffa53d3

Please sign in to comment.