Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected bool LogAapt2EventsFromOutput (string singleLine, MessageImportance me
return true;

var match = AndroidRunToolTask.AndroidErrorRegex.Match (singleLine.Trim ());
string file = string.Empty;
string file = "";

if (match.Success) {
file = match.Groups ["file"].Value;
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/Aapt2Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ string [] GenerateCommandLineCommands (string ManifestFile, string? currentAbi,
}

if (hasAssetsErrors) {
return Array.Empty<string> ();
return [];
}

if (!ProguardRuleOutput.IsNullOrEmpty ()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public override bool RunTask ()
ReadSymbols = ReadSymbols,
};

Dictionary<AndroidTargetArch, Dictionary<string, ITaskItem>> perArchAssemblies = MonoAndroidHelper.GetPerArchAssemblies (ResolvedAssemblies, Array.Empty<string> (), validate: false);
Dictionary<AndroidTargetArch, Dictionary<string, ITaskItem>> perArchAssemblies = MonoAndroidHelper.GetPerArchAssemblies (ResolvedAssemblies, [], validate: false);

AssemblyPipeline? pipeline = null;
var currentArch = AndroidTargetArch.None;
Expand Down
2 changes: 1 addition & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/BuildAppBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ internal override CommandLineBuilder GetCommandLineBuilder ()
cmd.AppendSwitchIfNotNull ("--modules ", string.Join (",", modules));
cmd.AppendSwitchIfNotNull ("--output ", Output);
cmd.AppendSwitchIfNotNull ("--config ", temp);
foreach (var file in MetaDataFiles ?? Array.Empty<ITaskItem> ()) {
foreach (var file in MetaDataFiles ?? []) {
cmd.AppendSwitch ($"--metadata-file={file.ItemSpec}");
}
return cmd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public override bool RunTask ()
jarFiles = jarFiles.Concat (JavaLibraries);
else if (JavaLibraries != null)
jarFiles = JavaLibraries;
var jarFilePaths = (LibraryProjectJars ?? Array.Empty<ITaskItem> ()).Concat (jarFiles ?? Array.Empty<ITaskItem> ()).Select (j => j.ItemSpec);
var jarFilePaths = (LibraryProjectJars ?? []).Concat (jarFiles ?? []).Select (j => j.ItemSpec);

// Remove duplicate identical jars by name, size and content, and reject any jars that conflicts by name (i.e. different content).
var jars = MonoAndroidHelper.DistinctFilesByContent (jarFilePaths).ToArray ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class CollectNativeFilesForArchive : AndroidTask
public string AndroidBinUtilsDirectory { get; set; } = "";

[Required]
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = [];

[Required]
public string IntermediateOutputPath { get; set; } = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class CollectRuntimeConfigFilesForArchive : AndroidTask
public string AndroidBinUtilsDirectory { get; set; } = "";

[Required]
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = [];

[Required]
public string IntermediateOutputPath { get; set; } = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class GenerateJavaCallableWrappers : AndroidTask
public override string TaskPrefix => "JCW";

[Required]
public string CodeGenerationTarget { get; set; } = string.Empty;
public string CodeGenerationTarget { get; set; } = "";

[Required]
public string OutputDirectory { get; set; } = string.Empty;
public string OutputDirectory { get; set; } = "";

[Required]
public string PackageNamingPolicy { get; set; } = string.Empty;
public string PackageNamingPolicy { get; set; } = "";

[Required]
public ITaskItem [] ResolvedAssemblies { get; set; } = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ sealed class CSharpBindingGenerator : BindingGenerator
{
const string BindingPartialClassBackingFieldName = "__layout_binding";

string codebehindDir = string.Empty;
string codebehindDir = "";
protected override string LineCommentString => "//";
protected override string DocCommentString => "///";
public override string LanguageName => "C#";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public override bool RunTask ()
ResourceDirectory = Path.GetFullPath (ResourceDirectory);

// Create our capitalization maps so we can support mixed case resources
foreach (var item in Resources ?? Array.Empty<ITaskItem>()) {
foreach (var item in Resources ?? []) {
var path = Path.GetFullPath (item.ItemSpec);
if (!path.StartsWith (ResourceDirectory, StringComparison.OrdinalIgnoreCase)) {
Log.LogDebugMessage ($"Skipping {item}. Path is not include the '{ResourceDirectory}'");
Expand All @@ -55,7 +55,7 @@ public override bool RunTask ()

AddRename (name.Replace ('/', Path.DirectorySeparatorChar), logical_name.Replace ('/', Path.DirectorySeparatorChar));
}
foreach (var additionalDir in AdditionalResourceDirectories ?? Array.Empty<ITaskItem>()) {
foreach (var additionalDir in AdditionalResourceDirectories ?? []) {
var dir = Path.Combine (ProjectDir, Path.GetDirectoryName (additionalDir.ItemSpec));
var file = Path.Combine (dir, "__res_name_case_map.txt");
if (!File.Exists (file)) {
Expand All @@ -72,7 +72,7 @@ public override bool RunTask ()
}
}
var resmap = ".net/__res_name_case_map.txt";
foreach (var aar in AarLibraries ?? Array.Empty<string>()) {
foreach (var aar in AarLibraries ?? []) {
Log.LogDebugMessage ($"Processing Aar file {aar}");
if (!File.Exists (aar)) {
Log.LogDebugMessage ($"Skipping non-existent aar: {aar}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public override bool RunTask ()

// Let VB put this in the default namespace
if (isVB)
Namespace = string.Empty;
Namespace = "";

List<string> aliases = new List<string> ();
// Create static resource overwrite methods for each Resource class in libraries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ bool Run (DirectoryAssemblyResolver res)
var parser = new RtxtParser ();
var resources = parser.Parse (RTxtFile.ItemSpec, Log, resource_fixup);
foreach (var r in resources) {
// Skip resources with null ResourceTypeName or Identifier
if (r.ResourceTypeName == null || r.Identifier == null)
continue;

switch (r.Type) {
case RType.Integer:
case RType.Integer_Styleable:
Expand All @@ -185,6 +189,8 @@ bool Run (DirectoryAssemblyResolver res)
CreateIntProperty (cache, r.ResourceTypeName, r.Identifier, r.Id, resourceDesigner, module);
break;
case RType.Array:
if (r.Ids == null)
break;
if (IsApplication && constDesigner != null)
CreateIntArrayField (cache, r.ResourceTypeName, r.Identifier, r.Ids, constDesigner, module);
CreateIntArrayProperty (cache, r.ResourceTypeName, r.Identifier, r.Ids, resourceDesigner, module);
Expand Down
8 changes: 4 additions & 4 deletions src/Xamarin.Android.Build.Tasks/Tasks/GetAotArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class GetAotArguments : AsyncTask
public string TargetName { get; set; } = "";

[Required]
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = [];

/// <summary>
/// Will be blank in .NET 6+
Expand All @@ -55,12 +55,12 @@ public abstract class GetAotArguments : AsyncTask

public string AndroidSequencePointsMode { get; set; } = "";

public ITaskItem [] Profiles { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem [] Profiles { get; set; } = [];

public int ZipAlignmentPages { get; set; } = AndroidZipAlign.DefaultZipAlignment64Bit;

[Required, Output]
public ITaskItem [] ResolvedAssemblies { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem [] ResolvedAssemblies { get; set; } = [];

[Output]
public string? Triple { get; set; }
Expand Down Expand Up @@ -262,7 +262,7 @@ string GetLdFlags (NdkTools ndk, AndroidTargetArch arch, int level, string toolP
var ldFlags = new StringBuilder ();
var libs = new List<string> ();
if (UseAndroidNdk && EnableLLVM) {
string androidLibPath = string.Empty;
string androidLibPath = "";
try {
androidLibPath = ndk.GetDirectoryPath (NdkToolchainDir.PlatformLib, arch, level);
} catch (InvalidOperationException ex) {
Expand Down
14 changes: 7 additions & 7 deletions src/Xamarin.Android.Build.Tasks/Tasks/Gradle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ public class Gradle : AndroidToolTask
public override string TaskPrefix => "GRDL";

[Required]
public string Command { get; set; } = string.Empty;
public string Command { get; set; } = "";

public string Arguments { get; set; } = string.Empty;
public string Arguments { get; set; } = "";

public string ModuleName { get; set; } = string.Empty;
public string ModuleName { get; set; } = "";

public string OutputPath { get; set; } = string.Empty;
public string OutputPath { get; set; } = "";

public string BuildDirInitScriptPath { get; set; } = string.Empty;
public string BuildDirInitScriptPath { get; set; } = "";

public string AndroidSdkDirectory { get; set; } = string.Empty;
public string AndroidSdkDirectory { get; set; } = "";

public string JavaSdkDirectory { get; set; } = string.Empty;
public string JavaSdkDirectory { get; set; } = "";


protected override string ToolName => OS.IsWindows ? "gradlew.bat" : "gradlew";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class PrepareSatelliteAssemblies : AndroidTask
public override string TaskPrefix => "PSA";

[Required]
public string[] BuildTargetAbis { get; set; } = Array.Empty<string> ();
public string[] BuildTargetAbis { get; set; } = [];

[Required]
public ITaskItem[] ReferenceSatellitePaths { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] ReferenceSatellitePaths { get; set; } = [];

[Required]
public ITaskItem[] IntermediateSatelliteAssemblies { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] IntermediateSatelliteAssemblies { get; set; } = [];

[Output]
public ITaskItem[]? ProcessedSatelliteAssemblies { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions src/Xamarin.Android.Build.Tasks/Tasks/ProcessAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public class ProcessAssemblies : AndroidTask
public override string TaskPrefix => "PRAS";

[Required]
public string [] RuntimeIdentifiers { get; set; } = Array.Empty<string>();
public string [] RuntimeIdentifiers { get; set; } = [];

public bool DesignTimeBuild { get; set; }

public bool AndroidIncludeDebugSymbols { get; set; }

public bool PublishTrimmed { get; set; }

public ITaskItem [] InputAssemblies { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem [] InputAssemblies { get; set; } = [];

public ITaskItem [] InputJavaLibraries { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem [] InputJavaLibraries { get; set; } = [];

public string AndroidRuntime { get; set; } = String.Empty;
public string LocalClrDirectory { get; set; } = String.Empty;
public string AndroidRuntime { get; set; } = "";
public string LocalClrDirectory { get; set; } = "";

[Output]
public ITaskItem []? OutputAssemblies { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public class ProcessRuntimePackLibraryDirectories : AndroidTask
};

[Required]
public ITaskItem[] ResolvedFilesToPublish { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] ResolvedFilesToPublish { get; set; } = [];

[Output]
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = [];

[Output]
public ITaskItem[] NativeLibrariesToRemove { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] NativeLibrariesToRemove { get; set; } = [];

public override bool RunTask ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ void Extract (
string resDir = Path.Combine (importsDir, "res");
string resDirArchive = Path.Combine (resDir, "..", "res.zip");
string assetsDir = Path.Combine (importsDir, "assets");
string nuGetPackageId = assemblyItem.GetMetadata (NuGetPackageId) ?? string.Empty;
string nuGetPackageVersion = assemblyItem.GetMetadata (NuGetPackageVersion) ?? string.Empty;
string nuGetPackageId = assemblyItem.GetMetadata (NuGetPackageId) ?? "";
string nuGetPackageVersion = assemblyItem.GetMetadata (NuGetPackageVersion) ?? "";
extractedDirectories.Add (new TaskItem (outDirForDll, new Dictionary<string, string> {
[OriginalFile] = assemblyPath,
[NuGetPackageId] = nuGetPackageId,
Expand Down Expand Up @@ -377,7 +377,7 @@ void Extract (
}
}
}
foreach (var aarFile in AarLibraries ?? Array.Empty<ITaskItem> ()) {
foreach (var aarFile in AarLibraries ?? []) {
if (!File.Exists (aarFile.ItemSpec))
continue;
string aarIdentityName = Path.GetFileName (aarFile.ItemSpec);
Expand All @@ -389,8 +389,8 @@ void Extract (
string rTxt = Path.Combine (importsDir, "R.txt");
string assetsDir = Path.Combine (importsDir, "assets");
string proguardFile = Path.Combine (importsDir, "proguard.txt");
string nuGetPackageId = aarFile.GetMetadata (NuGetPackageId) ?? string.Empty;
string nuGetPackageVersion = aarFile.GetMetadata (NuGetPackageVersion) ?? string.Empty;
string nuGetPackageId = aarFile.GetMetadata (NuGetPackageId) ?? "";
string nuGetPackageVersion = aarFile.GetMetadata (NuGetPackageVersion) ?? "";
extractedDirectories.Add (new TaskItem (outDirForDll, new Dictionary<string, string> {
[OriginalFile] = aarFile.ItemSpec,
[NuGetPackageId] = nuGetPackageId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class WrapAssembliesAsSharedLibraries : AndroidTask
public string AndroidBinUtilsDirectory { get; set; } = "";

[Required]
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem[] RuntimePackLibraryDirectories { get; set; } = [];

public bool IncludeDebugSymbols { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable disable
#nullable enable

using System.Reflection.Metadata;

Expand All @@ -13,24 +13,24 @@ namespace Xamarin.Android.Tasks
/// Or better yet, used via the extension method:
/// CustomAttributeValue<object> decoded = attribute.GetCustomAttributeArguments ();
/// </summary>
public class DummyCustomAttributeProvider : ICustomAttributeTypeProvider<object>
public class DummyCustomAttributeProvider : ICustomAttributeTypeProvider<object?>
{
public static readonly DummyCustomAttributeProvider Instance = new DummyCustomAttributeProvider ();

public object GetPrimitiveType (PrimitiveTypeCode typeCode) => null;
public object? GetPrimitiveType (PrimitiveTypeCode typeCode) => null;

public object GetSystemType () => null;
public object? GetSystemType () => null;

public object GetSZArrayType (object elementType) => null;
public object? GetSZArrayType (object? elementType) => null;

public object GetTypeFromDefinition (MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind) => null;
public object? GetTypeFromDefinition (MetadataReader reader, TypeDefinitionHandle handle, byte rawTypeKind) => null;

public object GetTypeFromReference (MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind) => null;
public object? GetTypeFromReference (MetadataReader reader, TypeReferenceHandle handle, byte rawTypeKind) => null;

public object GetTypeFromSerializedName (string name) => null;
public object? GetTypeFromSerializedName (string name) => null;

public PrimitiveTypeCode GetUnderlyingEnumType (object type) => default (PrimitiveTypeCode);
public PrimitiveTypeCode GetUnderlyingEnumType (object? type) => default (PrimitiveTypeCode);

public bool IsSystemType (object type) => false;
public bool IsSystemType (object? type) => false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EnvironmentFilesParser

public bool AreBrokenExceptionTransitionsEnabled (ITaskItem[] environments)
{
foreach (ITaskItem env in environments ?? Array.Empty<ITaskItem> ()) {
foreach (ITaskItem env in environments ?? []) {
foreach (string line in File.ReadLines (env.ItemSpec)) {
if (IsBrokenExceptionTransitionsLine (line.Trim ())) {
return true;
Expand All @@ -34,7 +34,7 @@ public bool AreBrokenExceptionTransitionsEnabled (ITaskItem[] environments)

public void Parse (ITaskItem[]? environments, SequencePointsMode sequencePointsMode, TaskLoggingHelper log)
{
foreach (ITaskItem env in environments ?? Array.Empty<ITaskItem> ()) {
foreach (ITaskItem env in environments ?? []) {
foreach (string line in File.ReadLines (env.ItemSpec)) {
var lineToWrite = line.Trim ();
if (lineToWrite.StartsWith ("MONO_LOG_LEVEL=", StringComparison.Ordinal))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public IList<R> Parse (string resourceDirectory, IEnumerable<string> additionalR
ProcessResourceFile (file, resources);
}
}
foreach (var dir in additionalResourceDirectories ?? Array.Empty<string>()) {
foreach (var dir in additionalResourceDirectories ?? []) {
Log.LogDebugMessage ($"Processing Directory {dir}");
if (Directory.Exists (dir)) {
foreach (var file in Directory.EnumerateFiles (dir, "*.*", SearchOption.AllDirectories)) {
Expand All @@ -75,7 +75,7 @@ public IList<R> Parse (string resourceDirectory, IEnumerable<string> additionalR
Log.LogDebugMessage ($"Skipping non-existent directory: {dir}");
}
}
foreach (var aar in aarLibraries ?? Array.Empty<string>()) {
foreach (var aar in aarLibraries ?? []) {
Log.LogDebugMessage ($"Processing Aar file {aar}");
if (!File.Exists (aar)) {
Log.LogDebugMessage ($"Skipping non-existent aar: {aar}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public bool GenerateCode (CallableWrapperType generator, TypeDefinition type, st
endLineNumber: 0,
endColumnNumber: 0,
message: xae.MessageWithoutCode,
messageArgs: Array.Empty<object> ()
messageArgs: []
);
} catch (DirectoryNotFoundException ex) {
ok = false;
Expand Down
Loading
Loading