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 msbuild/Xamarin.MacDev.Tasks/Tasks/ACTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public override bool Execute ()
Log.LogError (MSBStrings.E0093, Path.GetFullPath (partialAppManifestPath));

try {
var manifestOutput = PDictionary.FromFile (manifest.ItemSpec)!;
var manifestOutput = PDictionary.OpenFile (manifest.ItemSpec);

LogWarningsAndErrors (manifestOutput, catalogs [0]);

Expand Down
6 changes: 3 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override bool Execute ()

var archiveDir = CreateArchiveDirectory ();
try {
var plist = PDictionary.FromFile (PlatformFrameworkHelper.GetAppManifestPath (Platform, AppBundleDir.ItemSpec));
var plist = PDictionary.OpenFile (PlatformFrameworkHelper.GetAppManifestPath (Platform, AppBundleDir.ItemSpec));
var productsDir = Path.Combine (archiveDir, "Products");

// Archive the OnDemandResources...
Expand Down Expand Up @@ -293,7 +293,7 @@ protected string CreateArchiveDirectory ()

void ArchiveAppExtension (ITaskItem appex, string archiveDir)
{
var plist = PDictionary.FromFile (Path.Combine (appex.ItemSpec, "Info.plist")!)!;
var plist = PDictionary.OpenFile (Path.Combine (appex.ItemSpec, "Info.plist"));

if (IsWatchAppExtension (appex, plist, out var watchAppBundleDir)) {
var wk = Path.Combine (watchAppBundleDir, "_WatchKitStub", "WK");
Expand Down Expand Up @@ -384,7 +384,7 @@ static bool IsWatchAppExtension (ITaskItem appex, PDictionary plist, [NotNullWhe
if (!File.Exists (Path.Combine (bundle, "Info.plist")))
continue;

plist = PDictionary.FromFile (Path.Combine (bundle, "Info.plist"))!;
plist = PDictionary.OpenFile (Path.Combine (bundle, "Info.plist"));

if (!plist.TryGetValue<PString> ("CFBundleIdentifier", out var bundleIdentifier))
continue;
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ IEnumerable<ITaskItem> GetCodesignedFiles (ITaskItem item)
var manifestPath = Path.Combine (item.ItemSpec, "Info.plist");

if (File.Exists (manifestPath)) {
var bundleExecutable = PDictionary.FromFile (manifestPath).GetCFBundleExecutable ();
var bundleExecutable = PDictionary.OpenFile (manifestPath).GetCFBundleExecutable ();

if (!string.IsNullOrEmpty (bundleExecutable))
executableName = bundleExecutable;
Expand Down
4 changes: 2 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public override bool Execute ()
plist = new PDictionary ();
} else if (File.Exists (appManifest)) {
try {
plist = PDictionary.FromFile (appManifest)!;
plist = PDictionary.OpenFile (appManifest);
} catch (Exception ex) {
LogAppManifestError (MSBStrings.E0010, appManifest, ex.Message);
return false;
Expand Down Expand Up @@ -397,7 +397,7 @@ public static void MergePartialPLists (Task task, PDictionary plist, IEnumerable
var overwrite = !string.Equals (template.GetMetadata ("Overwrite"), "false", StringComparison.OrdinalIgnoreCase);

try {
partial = PDictionary.FromFile (template.ItemSpec)!;
partial = PDictionary.OpenFile (template.ItemSpec);
} catch (Exception ex) {
task.Log.LogError (MSBStrings.E0107, template.ItemSpec, ex.Message);
continue;
Expand Down
6 changes: 3 additions & 3 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileEntitlements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public override bool Execute ()
}
if (injectDefaultEntitlements) {
try {
var defaultEntitlements = PDictionary.FromFile (DefaultEntitlementsPath)!;
var defaultEntitlements = PDictionary.OpenFile (DefaultEntitlementsPath);
templates.Add (defaultEntitlements);
Log.LogMessage (MessageImportance.Low, $"Loading default entitlements from: {DefaultEntitlementsPath}");
} catch (Exception ex) {
Expand All @@ -541,7 +541,7 @@ public override bool Execute ()
Log.LogError (MSBStrings.E0112, Entitlements);
return false;
}
var projectEntitlements = PDictionary.FromFile (Entitlements)!;
var projectEntitlements = PDictionary.OpenFile (Entitlements);
templates.Add (projectEntitlements);
Log.LogMessage (MessageImportance.Low, $"Loading user requested entitlements from: {Entitlements}");
} catch (Exception ex) {
Expand Down Expand Up @@ -609,7 +609,7 @@ bool SaveArchivedExpandedEntitlements (PDictionary archived)
var path = Path.Combine (EntitlementBundlePath, "archived-expanded-entitlements.xcent");

if (File.Exists (path)) {
var plist = PDictionary.FromFile (path)!;
var plist = PDictionary.OpenFile (path);
var src = archived.ToXml ();
var dest = plist.ToXml ();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override bool Execute ()
var path = ITunesMetadata [0].GetMetadata ("FullPath");

try {
metadata = PDictionary.FromFile (path)!;
metadata = PDictionary.OpenFile (path);
} catch (Exception ex) {
Log.LogError (null, null, null, path, 0, 0, 0, 0, MSBStrings.E0010, path, ex.Message);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override bool Execute ()

if (File.Exists (ProductDefinition)) {
try {
plist = PDictionary.FromFile (ProductDefinition)!;
plist = PDictionary.OpenFile (ProductDefinition);
} catch (Exception ex) {
LogProductDefinitionError (MSBStrings.E0010, ProductDefinition, ex.Message);
return false;
Expand Down Expand Up @@ -95,17 +95,12 @@ public override bool Execute ()
PDictionary plist;

try {
plist = PDictionary.FromFile (AppManifest)!;
plist = PDictionary.OpenFile (AppManifest);
} catch (Exception ex) {
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0010, AppManifest, ex.Message);
return null;
}

if (plist is null) {
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0122, AppManifest);
return null;
}

return plist.GetMinimumSystemVersion ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override bool Execute ()

foreach (var dir in Directory.EnumerateDirectories (onDemandResourcesDir)) {
var path = Path.Combine (dir, "Info.plist");
PDictionary info;
PDictionary? info;

if (!File.Exists (path))
continue;
Expand All @@ -80,11 +80,8 @@ public override bool Execute ()
updateOnDemandResources = updateOnDemandResources || mtime > onDemandResourcesStamp;
updateManifest = updateManifest || mtime > manifestStamp;

try {
info = PDictionary.FromFile (path)!;
} catch {
if (!PDictionary.TryOpenFile (path, out info))
continue;
}

var bundleIdentifier = info.GetCFBundleIdentifier ();
var primaryContentHash = new PDictionary ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override bool Execute ()

if (File.Exists (path)) {
try {
plist = PDictionary.FromFile (path)!;
plist = PDictionary.OpenFile (path);
} catch (Exception ex) {
Log.LogError (MSBStrings.E0024, Path.GetFileName (AppBundleDir), ex.Message);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,12 @@ public class CreateInstallerPackage : XamarinTask, ICancelableTask {
PDictionary plist;

try {
plist = PDictionary.FromFile (AppManifest)!;
plist = PDictionary.OpenFile (AppManifest);
} catch (Exception ex) {
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0010, AppManifest, ex.Message);
return null;
}

if (plist is null) {
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0122, AppManifest);
return null;
}

return plist.GetCFBundleShortVersionString ();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public bool HasEntitlements {
hasEntitlements = false;
} else {
// Check the file to see if there are any entitlements inside
var entitlements = PDictionary.FromFile (CodesignEntitlements!.ItemSpec)!;
var entitlements = PDictionary.OpenFile (CodesignEntitlements!.ItemSpec);
hasEntitlements = entitlements.Count > 0;
}
}
Expand Down
15 changes: 6 additions & 9 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/FilterStaticFrameworks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,14 @@ static string GetFrameworkExecutablePath (string frameworkPath, ApplePlatform pl
var infoPlistPath = GetFrameworkInfoPlistPath (frameworkPath, platform);

if (File.Exists (infoPlistPath)) {
try {
var plist = PDictionary.FromFile (infoPlistPath);
if (plist is not null) {
var bundleExecutable = plist.GetCFBundleExecutable ();
if (!string.IsNullOrEmpty (bundleExecutable)) {
return Path.Combine (frameworkPath, bundleExecutable);
}
if (PDictionary.TryOpenFile (infoPlistPath, out var plist)) {
var bundleExecutable = plist.GetCFBundleExecutable ();
if (!string.IsNullOrEmpty (bundleExecutable)) {
return Path.Combine (frameworkPath, bundleExecutable);
}
} catch (Exception ex) {
} else {
// Log exceptions from malformed plist files and fall back to default behavior
log?.LogMessage (MessageImportance.Low, $"Failed to parse Info.plist for framework '{frameworkPath}': {ex.Message}");
log?.LogMessage (MessageImportance.Low, $"Failed to parse Info.plist for framework '{frameworkPath}'");
}
Comment thread
rolfbjarne marked this conversation as resolved.
Resolved
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override bool Execute ()

// filter to values we find in the app manifest, if it exists
if (File.Exists (AppBundleManifestPath)) {
var appManifest = PDictionary.FromFile (AppBundleManifestPath)!;
var appManifest = PDictionary.OpenFile (AppBundleManifestPath);

var uiDeviceFamily = appManifest.GetUIDeviceFamily ();
// an iPhone app can run on an iPad, but an iPad app cannot run on an iPhone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public IPhoneDeviceType DeviceType {
switch (Platform) {
case ApplePlatform.iOS:
case ApplePlatform.TVOS:
var plist = PDictionary.FromFile (AppManifestPath);
var plist = PDictionary.OpenFile (AppManifestPath);
return plist.GetUIDeviceFamily ();
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidPlatform, Platform));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override bool Execute ()
PDictionary plist;

try {
plist = PDictionary.FromFile (AppManifest)!;
plist = PDictionary.OpenFile (AppManifest);
} catch (Exception ex) {
Log.LogError (MSBStrings.E0055, ex.Message);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override bool Execute ()
}

try {
value = dict = PDictionary.FromFile (PropertyListFile);
value = dict = PDictionary.OpenFile (PropertyListFile);
} catch (Exception ex) {
Log.LogError (MSBStrings.E0010, PropertyListFile, ex.Message);
return false;
Expand Down
12 changes: 5 additions & 7 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/IBTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,11 @@ static bool LogExists (string path)
if (!File.Exists (path))
return false;

try {
PDictionary.FromFile (path);
if (PDictionary.TryOpenFile (path, out _))
return true;
} catch {
File.Delete (path);
return false;
}

File.Delete (path);
return false;
}

static bool InterfaceDefinitionChanged (ITaskItem interfaceDefinition, ITaskItem log)
Expand Down Expand Up @@ -226,7 +224,7 @@ bool CompileInterfaceDefinitions (IEnumerable<ITaskItem> interfaceDefinitions, s
}

try {
var dict = PDictionary.FromFile (manifest.ItemSpec)!;
var dict = PDictionary.OpenFile (manifest.ItemSpec);

LogWarningsAndErrors (dict, item);
} catch (Exception ex) {
Expand Down
17 changes: 7 additions & 10 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/LinkNativeCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,14 @@ string ConvertEntitlementsToDerEntitlements (string entitlements)

static bool EntitlementsRequireLinkerFlags (string path)
{
try {
var plist = PDictionary.FromFile (path)!;

// FIXME: most keys do not require linking in the entitlements file, so we
// could probably add some smarter logic here to iterate over all of the
// keys in order to determine whether or not we really need to link with
// the entitlements or not.
return plist.Count != 0;
} catch {
if (!PDictionary.TryOpenFile (path, out var plist))
return false;
}

// FIXME: most keys do not require linking in the entitlements file, so we
// could probably add some smarter logic here to iterate over all of the
// keys in order to determine whether or not we really need to link with
// the entitlements or not.
return plist.Count != 0;
}

// We should avoid copying files from the output path because those already exist on the Mac
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/ReadAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override bool Execute ()

if (!string.IsNullOrEmpty (AppManifest?.ItemSpec)) {
try {
plist = PDictionary.FromFile (AppManifest!.ItemSpec);
plist = PDictionary.OpenFile (AppManifest!.ItemSpec);
} catch (Exception ex) {
Log.LogError (null, null, null, AppManifest!.ItemSpec, 0, 0, 0, 0, MSBStrings.E0010, AppManifest.ItemSpec, ex.Message);
return false;
Expand Down
8 changes: 4 additions & 4 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/ValidateAppBundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void ValidateAppExtension (string path, string mainBundleIdentifier, string main
return;
}

var plist = PDictionary.FromFile (info)!;
var plist = PDictionary.OpenFile (info);

var bundleIdentifier = plist.GetCFBundleIdentifier ();
if (string.IsNullOrEmpty (bundleIdentifier)) {
Expand Down Expand Up @@ -129,7 +129,7 @@ void ValidateWatchApp (string path, string mainBundleIdentifier, string mainShor
return;
}

var plist = PDictionary.FromFile (info)!;
var plist = PDictionary.OpenFile (info);
var bundleIdentifier = plist.GetCFBundleIdentifier ();
if (string.IsNullOrEmpty (bundleIdentifier)) {
Log.LogError (7015, info, MSBStrings.E7015, name);
Expand Down Expand Up @@ -202,7 +202,7 @@ void ValidateWatchExtension (string path, string watchAppBundleIdentifier, strin
return;
}

var plist = PDictionary.FromFile (info)!;
var plist = PDictionary.OpenFile (info);

var bundleIdentifier = plist.GetCFBundleIdentifier ();
if (string.IsNullOrEmpty (bundleIdentifier)) {
Expand Down Expand Up @@ -290,7 +290,7 @@ public override bool Execute ()
return false;
}

var plist = PDictionary.FromFile (mainInfoPath)!;
var plist = PDictionary.OpenFile (mainInfoPath);

var bundleIdentifier = plist.GetCFBundleIdentifier ();
if (string.IsNullOrEmpty (bundleIdentifier)) {
Expand Down
2 changes: 1 addition & 1 deletion msbuild/Xamarin.MacDev.Tasks/Tasks/WriteAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override bool Execute ()

var firstManifest = AppManifests! [0].ItemSpec;
try {
plist = PDictionary.FromFile (firstManifest)!;
plist = PDictionary.OpenFile (firstManifest);
} catch (Exception ex) {
Log.LogError (null, null, null, firstManifest, 0, 0, 0, 0, MSBStrings.E0010, ex.Message);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override bool Execute ()
if (ShouldExecuteRemotely ())
return ExecuteRemotely ();

var template = PDictionary.FromFile (TemplatePath!.ItemSpec)!;
var template = PDictionary.OpenFile (TemplatePath!.ItemSpec);
var resources = template.GetArray ("resources");

foreach (var resource in resources.OfType<PDictionary> ()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ protected int Compile (ITaskItem [] items, string output, ITaskItem manifest)
// Note: If the log file exists and is parseable, log those warnings/errors as well...
if (File.Exists (manifest.ItemSpec)) {
try {
var plist = PDictionary.FromFile (manifest.ItemSpec)!;
var plist = PDictionary.OpenFile (manifest.ItemSpec);

LogWarningsAndErrors (plist, items [0]);
} catch (Exception ex) {
Expand Down
2 changes: 1 addition & 1 deletion tests/dotnet/UnitTests/MauiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void BuildMauiAppImpl (ApplePlatform platform, string runtimeIdentifiers, bool d
var rv = DotNet.AssertBuild (project_path, properties);
AssertThatLinkerExecuted (rv);
var infoPlistPath = GetInfoPListPath (platform, appPath);
var infoPlist = PDictionary.FromFile (infoPlistPath)!;
var infoPlist = PDictionary.OpenFile (infoPlistPath);
Assert.AreEqual ("com.xamarin.mymauiapp", infoPlist.GetString ("CFBundleIdentifier").Value, "CFBundleIdentifier");
Assert.AreEqual ("MyMauiApp", infoPlist.GetString ("CFBundleDisplayName").Value, "CFBundleDisplayName");
Assert.AreEqual ("1", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion");
Expand Down
Loading
Loading