Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xharness] Add support for getting the default AssemblyName for projects. #9369

Merged
merged 1 commit into from
Aug 14, 2020
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
using System.IO;
using System.Runtime.CompilerServices;
Copy link
Member

Choose a reason for hiding this comment

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

needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's where ConditionalWeakTable is.

using System.Xml;

namespace Microsoft.DotNet.XHarness.iOS.Shared.Utilities {
public static class PListExtensions {
static ConditionalWeakTable<XmlDocument, string> doc_to_filename = new ConditionalWeakTable<XmlDocument, string> ();

public static string GetFilename (this XmlDocument doc)
{
doc_to_filename.TryGetValue (doc, out var rv);
return rv;
}

public static void LoadWithoutNetworkAccess (this XmlDocument doc, string filename)
{
using (var fs = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
Expand All @@ -14,6 +23,7 @@ public static void LoadWithoutNetworkAccess (this XmlDocument doc, string filena
doc.Load (reader);
}
}
doc_to_filename.Add (doc, filename);
}

public static void LoadXmlWithoutNetworkAccess (this XmlDocument doc, string xml)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ public static void SetAssemblyName (this XmlDocument csproj, string value)

public static string GetAssemblyName (this XmlDocument csproj)
{
return csproj.SelectSingleNode ("/*/*/*[local-name() = 'AssemblyName']").InnerText;
var assemblyNameNode = csproj.SelectSingleNode ("/*/*/*[local-name() = 'AssemblyName']");
if (assemblyNameNode != null)
return assemblyNameNode.InnerText;
return Path.GetFileNameWithoutExtension (csproj.GetFilename ());
}

public static void SetPlatformAssembly (this XmlDocument csproj, string value)
Expand Down