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
5 changes: 0 additions & 5 deletions src/System.Management.Automation/CoreCLR/CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ internal static bool HasAmsi()
return IsWindows;
}

internal static bool UsesCodeSignedAssemblies()
{
return !Platform.IsCore;
}

// This is mainly with respect to the auto-mounting of
// disconnected network drives on Windows
internal static bool HasDriveAutoMounting()
Expand Down
22 changes: 2 additions & 20 deletions src/System.Management.Automation/engine/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,25 +1263,8 @@ public struct WIN32_FIND_DATA
public static extern bool FindClose(IntPtr hFindFile);
}

// Porting note: PublicKeyToken must be null if code signed
// assemblies aren't supported
private static string strongNamePublicKeyToken
{
get
{
if (Platform.UsesCodeSignedAssemblies())
{
return "31bf3856ad364e35";
}
else
{
return "null";
}
}
}

internal static readonly string PowerShellAssemblyStrongNameFormat =
"{0}, Version=3.0.0.0, Culture=neutral, PublicKeyToken={1}";
"{0}, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";

internal static readonly HashSet<string> PowerShellAssemblies =
new HashSet<string>(StringComparer.OrdinalIgnoreCase)
Expand Down Expand Up @@ -1338,8 +1321,7 @@ internal static string GetPowerShellAssemblyStrongName(string assemblyName)

if ((fixedName != null) && PowerShellAssemblies.Contains(fixedName))
{
return string.Format(CultureInfo.InvariantCulture, PowerShellAssemblyStrongNameFormat,
fixedName, strongNamePublicKeyToken);
return string.Format(CultureInfo.InvariantCulture, PowerShellAssemblyStrongNameFormat, fixedName);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,21 +1018,9 @@ internal static void ReadRegistryInfo(out Version assemblyVersion, out string pu
byte[] publicTokens = currentAssembly.GetName().GetPublicKeyToken();
if (publicTokens.Length == 0)
{
if (Platform.UsesCodeSignedAssemblies())
{
throw PSTraceSource.NewArgumentException("PublicKeyToken", MshSnapinInfo.PublicKeyTokenAccessFailed);
}
else
{
// Platform note: set this to null when code signed assemblies are
// unsupported (rather than blank)
publicKeyToken = "null";
}
}
else
{
publicKeyToken = ConvertByteArrayToString(publicTokens);
throw PSTraceSource.NewArgumentException("PublicKeyToken", MshSnapinInfo.PublicKeyTokenAccessFailed);
}
publicKeyToken = ConvertByteArrayToString(publicTokens);
// save some cpu cycles by hardcoding the culture to neutral
// assembly should never be targeted to a particular culture
culture = "neutral";
Expand Down Expand Up @@ -1083,12 +1071,6 @@ static internal PSSnapInInfo ReadCoreEngineSnapIn()
"Help.format.ps1xml","HelpV3.format.ps1xml","PowerShellCore.format.ps1xml","PowerShellTrace.format.ps1xml",
"Registry.format.ps1xml"});

// If code signing is not supported, the token must be set to "null"
if (!Platform.UsesCodeSignedAssemblies())
{
publicKeyToken = "null";
}

string strongName = string.Format(CultureInfo.InvariantCulture, "{0}, Version={1}, Culture={2}, PublicKeyToken={3}, ProcessorArchitecture={4}",
CoreSnapin.AssemblyName, assemblyVersion, culture, publicKeyToken, architecture);

Expand Down
6 changes: 0 additions & 6 deletions test/csharp/test_CorePsPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ public static void TestHasAmsi()
Assert.False(Platform.HasAmsi());
}

[Fact]
public static void TestUsesCodeSignedAssemblies()
{
Assert.False(Platform.UsesCodeSignedAssemblies());
}

[Fact]
public static void TestHasDriveAutoMounting()
{
Expand Down
2 changes: 1 addition & 1 deletion test/csharp/test_MshSnapinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void TestReadRegistryInfo()
public void TestReadCoreEngineSnapIn()
{
PSSnapInInfo pSSnapInInfo = PSSnapInReader.ReadCoreEngineSnapIn();
Assert.Contains("PublicKeyToken=null", pSSnapInInfo.AssemblyName);
Assert.Contains("PublicKeyToken=31bf3856ad364e35", pSSnapInInfo.AssemblyName);
}
}
}