Skip to content

Commit 74c4fe7

Browse files
authored
[msbuild] Enable nullability and unify base and derived class for the GetFiles task. (#17814)
1 parent bfd87e4 commit 74c4fe7

File tree

2 files changed

+25
-34
lines changed

2 files changed

+25
-34
lines changed

msbuild/Xamarin.MacDev.Tasks/Tasks/GetFiles.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

msbuild/Xamarin.MacDev.Tasks/Tasks/GetFilesTaskBase.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
using System;
22
using System.IO;
33
using System.Collections.Generic;
4+
using System.Linq;
45

56
using Microsoft.Build.Framework;
67
using Microsoft.Build.Utilities;
78

89
using Xamarin.MacDev.Tasks;
910
using Xamarin.Localization.MSBuild;
11+
using Xamarin.Messaging.Build.Client;
12+
13+
#nullable enable
1014

1115
namespace Xamarin.MacDev.Tasks {
12-
public abstract class GetFilesTaskBase : XamarinTask {
16+
public abstract class GetFiles : XamarinTask, ITaskCallback, ICancelableTask {
1317
[Required]
14-
public string Path { get; set; }
18+
public string Path { get; set; } = string.Empty;
1519

16-
public string Pattern { get; set; }
20+
public string Pattern { get; set; } = string.Empty;
1721

18-
public string Option { get; set; }
22+
public string Option { get; set; } = string.Empty;
1923

20-
public string Exclude { get; set; }
24+
public string Exclude { get; set; } = string.Empty;
2125

2226
[Output]
23-
public ITaskItem [] Files { get; set; }
27+
public ITaskItem [] Files { get; set; } = Array.Empty<ITaskItem> ();
2428

2529
public override bool Execute ()
2630
{
31+
if (ShouldExecuteRemotely ())
32+
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
33+
2734
var path = Path.Replace ('\\', '/').TrimEnd ('/');
2835
var exclude = new HashSet<string> ();
2936
var items = new List<ITaskItem> ();
@@ -66,5 +73,17 @@ public override bool Execute ()
6673

6774
return !Log.HasLoggedErrors;
6875
}
76+
77+
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
78+
79+
public bool ShouldCopyToBuildServer (ITaskItem item) => false;
80+
81+
public bool ShouldCreateOutputFile (ITaskItem item) => false;
82+
83+
public void Cancel ()
84+
{
85+
if (ShouldExecuteRemotely ())
86+
BuildConnection.CancelAsync (BuildEngine4).Wait ();
87+
}
6988
}
7089
}

0 commit comments

Comments
 (0)