Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,7 @@ because xbuild doesn't support framework reference assemblies.
;@(_ShrunkFrameworkAssemblies)
;@(_AndroidNativeLibraryForFastDev)
;@(_DexFileForFastDevInput)
;@(_ApplicationSharedLibrary)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, my copilot actually has the exact same fix from overnight, but I like the test it wrote better than the one here.

I'll add some changes on top of this, thanks!

;$(_AndroidBuildPropertiesCache)
;$(_AdbPropertiesCache)
;$(_PackagedResources)
Expand Down
45 changes: 44 additions & 1 deletion tests/MSBuildDeviceIntegration/Tests/FastDevTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,49 @@ public void FastDevSimpleBuild ()
b.Dispose ();
}

[Test]
public void FastDeployUpdatesTypeMapAfterAssemblyEdit ()
{
var proj = new XamarinAndroidApplicationProject {
PackageName = "com.xamarin.fastdeploy_typemap",
};
proj.SetDefaultTargetDevice ();
proj.SetProperty ("_AndroidFastDevStrategy", "FastDeploy");
proj.MainActivity = proj.DefaultMainActivity
.Replace ("//${AFTER_ONCREATE}", "StartActivity (new Android.Content.Intent (this, typeof (SecondActivity)));")
.Replace ("//${AFTER_MAINACTIVITY}", """
[Activity (Label = "Fast Deploy Result")]
public sealed class SecondActivity : Activity
{
}
""");

using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Install (proj), "Initial install should have succeeded.");
AssertSecondActivityStarts ("initial-launch.log");

proj.MainActivity += "// Incremental C# edit.";
proj.Touch ("MainActivity.cs");
Assert.IsTrue (builder.Install (proj, doNotCleanupOnUpdate: true, saveProject: false), "Incremental install should have succeeded.");
AssertSecondActivityStarts ("incremental-launch.log");
Assert.IsTrue (builder.Uninstall (proj), "Uninstall should have succeeded.");

void AssertSecondActivityStarts (string logFileName)
{
ClearAdbLogcat ();
AdbStartActivity ($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity");
Assert.IsTrue (
WaitForActivityToStart (
proj.PackageName,
"SecondActivity",
Path.Combine (Root, builder.ProjectDirectory, logFileName),
ActivityStartTimeoutInSeconds
),
"SecondActivity should have started."
);
}
}

[Test]
public void TargetsSkipped ([Values(false, true)] bool useManagedResourceGenerator)
{
Expand Down Expand Up @@ -140,7 +183,7 @@ public void SkipFastDevAlreadyInstalledFile ()
proj.Touch ("MainActivity.cs");
// make sure that the fastdev log tells that the relevant dll is updated but NOT for others.
Assert.IsTrue (b.Install (proj, doNotCleanupOnUpdate: true, saveProject: false), "install should have succeeded.");
Assert.IsFalse (b.Output.IsApkInstalled, "app apk was installed");
Assert.IsTrue (b.Output.IsApkInstalled, "app apk was not installed");
Assert.IsTrue (b.LastBuildOutput.Any (l => l.Contains ("UnnamedProject.dll") && l.Contains ("NotifySync CopyFile")), "app dll not uploaded");

var assemblies = new[] {
Expand Down
Loading