mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 12:45:47 +00:00
Add back ADSI and WMI type accelerators (#7085)
This commit is contained in:
1 parent
d76cdc3c5c
commit
6c9eea6390
6 files changed
+29
-35
No files matched your search
@@ -12,7 +12,10 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
<!-- the following package(s) are from https://github.com/dotnet/corefx -->
|
||||
<PackageReference Include="Microsoft.Win32.Registry.AccessControl" Version="4.5.0" />
|
||||
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
|
||||
<PackageReference Include="System.DirectoryServices" Version="4.5.0" />
|
||||
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.5.0" />
|
||||
<PackageReference Include="System.Management" Version="4.5.0" />
|
||||
<PackageReference Include="System.Security.AccessControl" Version="4.5.0" />
|
||||
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.5.0" />
|
||||
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
|
||||
@@ -88,8 +91,6 @@
|
||||
<Compile Remove="engine\ComInterop\VariantArgBuilder.cs" />
|
||||
<Compile Remove="engine\ComInterop\VariantArray.cs" />
|
||||
<Compile Remove="engine\ComInterop\VariantBuilder.cs" />
|
||||
<Compile Remove="engine\ExtraAdapter.cs" />
|
||||
<Compile Remove="engine\ManagementObjectAdapter.cs" />
|
||||
<Compile Remove="engine\PSMI\PSNegotiationData.cs" />
|
||||
<Compile Remove="engine\PSMI\PSPowerShellPipeline.cs" />
|
||||
<Compile Remove="engine\PSMI\Serialization\InternalMISerializer.cs" />
|
||||
@@ -129,6 +130,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(IsWindows)' != 'true' ">
|
||||
<Compile Remove="engine\ExtraAdapter.cs" />
|
||||
<Compile Remove="engine\ManagementObjectAdapter.cs" />
|
||||
<Compile Remove="engine\remoting\commands\ReceivePSSession.cs" />
|
||||
<Compile Remove="engine\remoting\commands\DisconnectPSSession.cs" />
|
||||
<Compile Remove="engine\remoting\commands\ConnectPSSession.cs" />
|
||||
|
||||
@@ -30,7 +30,10 @@ namespace System.Management.Automation
|
||||
|
||||
#region member
|
||||
|
||||
internal override bool SiteBinderCanOptimize { get { return false; } }
|
||||
internal override bool CanSiteBinderOptimize(MemberTypes typeToOperateOn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns null if memberName is not a member in the adapter or
|
||||
|
||||
@@ -22,10 +22,9 @@ using System.Management.Automation.Runspaces;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dbg = System.Management.Automation.Diagnostics;
|
||||
using MethodCacheEntry = System.Management.Automation.DotNetAdapter.MethodCacheEntry;
|
||||
|
||||
#if !CORECLR
|
||||
// System.DirectoryServices are not in CoreCLR
|
||||
#if !UNIX
|
||||
using System.DirectoryServices;
|
||||
using System.Management;
|
||||
#endif
|
||||
|
||||
#pragma warning disable 1634, 1691 // Stops compiler from warning about unknown warnings
|
||||
@@ -2147,15 +2146,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
#if !CORECLR
|
||||
// No Following Types In CoreCLR
|
||||
// ManagementObject
|
||||
// ManagementObjectSearcher
|
||||
// ManagementClass
|
||||
// CommaDelimitedStringCollection
|
||||
// DirectoryEntry
|
||||
#region Converters_Not_Available_In_CorePS
|
||||
|
||||
#if !UNIX
|
||||
private static ManagementObject ConvertToWMI(object valueToConvert,
|
||||
Type resultType,
|
||||
bool recursion,
|
||||
@@ -2279,6 +2270,7 @@ namespace System.Management.Automation
|
||||
valueToConvert.ToString(), resultType.ToString(), wmiClassException.Message);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// System.Configuration.CommaDelimitedStringCollection is derived from the StringCollection class
|
||||
private static System.Configuration.CommaDelimitedStringCollection ConvertToCommaDelimitedStringCollection(object valueToConvert,
|
||||
@@ -2294,6 +2286,7 @@ namespace System.Management.Automation
|
||||
return commaDelimitedStringCollection;
|
||||
}
|
||||
|
||||
#if !UNIX
|
||||
private static DirectoryEntry ConvertToADSI(object valueToConvert,
|
||||
Type resultType,
|
||||
bool recursion,
|
||||
@@ -2351,8 +2344,6 @@ namespace System.Management.Automation
|
||||
valueToConvert.ToString(), resultType.ToString(), e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Converters_Not_Available_In_CorePS
|
||||
#endif
|
||||
|
||||
private static StringCollection ConvertToStringCollection(object valueToConvert,
|
||||
@@ -4302,7 +4293,8 @@ namespace System.Management.Automation
|
||||
CacheConversion<bool>(typeofString, typeofBool, LanguagePrimitives.ConvertStringToBool, ConversionRank.Language);
|
||||
CacheConversion<bool>(typeof(SwitchParameter), typeofBool, LanguagePrimitives.ConvertSwitchParameterToBool, ConversionRank.Language);
|
||||
|
||||
#if !CORECLR // No DirectoryService && WMIv1 In CoreCLR
|
||||
#if !UNIX
|
||||
// Conversions to WMI and ADSI
|
||||
CacheConversion<ManagementObjectSearcher>(typeofString, typeof(ManagementObjectSearcher), LanguagePrimitives.ConvertToWMISearcher, ConversionRank.Language);
|
||||
CacheConversion<ManagementClass>(typeofString, typeof(ManagementClass), LanguagePrimitives.ConvertToWMIClass, ConversionRank.Language);
|
||||
CacheConversion<ManagementObject>(typeofString, typeof(ManagementObject), LanguagePrimitives.ConvertToWMI, ConversionRank.Language);
|
||||
|
||||
@@ -23,9 +23,9 @@ using System.Runtime.Serialization;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Microsoft.Management.Infrastructure;
|
||||
|
||||
#if !CORECLR
|
||||
#if !UNIX
|
||||
using System.DirectoryServices;
|
||||
using System.Management;
|
||||
#endif
|
||||
|
||||
#pragma warning disable 1634, 1691 // Stops compiler from warning about unknown warnings
|
||||
@@ -379,8 +379,7 @@ namespace System.Management.Automation
|
||||
new PSObject.AdapterSet(new ThirdPartyAdapter(typeof(Microsoft.Management.Infrastructure.CimInstance),
|
||||
new Microsoft.PowerShell.Cim.CimInstanceAdapter()),
|
||||
PSObject.dotNetInstanceAdapter);
|
||||
|
||||
#if !CORECLR // WMIv1/ADSI Adapters Not Supported in PowerShell Core
|
||||
#if !UNIX
|
||||
private static readonly AdapterSet managementObjectAdapter = new AdapterSet(new ManagementObjectAdapter(), dotNetInstanceAdapter);
|
||||
private static readonly AdapterSet managementClassAdapter = new AdapterSet(new ManagementClassApdapter(), dotNetInstanceAdapter);
|
||||
private static readonly AdapterSet directoryEntryAdapter = new AdapterSet(new DirectoryEntryAdapter(), dotNetInstanceAdapter);
|
||||
@@ -410,8 +409,7 @@ namespace System.Management.Automation
|
||||
if (obj is PSMemberSet) { return PSObject.s_mshMemberSetAdapter; }
|
||||
if (obj is PSObject) { return PSObject.s_mshObjectAdapter; }
|
||||
if (obj is CimInstance) { return PSObject.s_cimInstanceAdapter; }
|
||||
|
||||
#if !CORECLR // WMIv1/ADSI Adapters Not Supported in PowerShell Core
|
||||
#if !UNIX
|
||||
if (obj is ManagementClass) { return PSObject.managementClassAdapter; }
|
||||
if (obj is ManagementBaseObject) { return PSObject.managementObjectAdapter; }
|
||||
if (obj is DirectoryEntry) { return PSObject.directoryEntryAdapter; }
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Microsoft.Management.Infrastructure;
|
||||
using Microsoft.PowerShell.Commands;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
#if !UNIX
|
||||
using System.DirectoryServices;
|
||||
#endif
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Management.Automation.Language;
|
||||
@@ -18,12 +23,6 @@ using System.Security.AccessControl;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
using Microsoft.Management.Infrastructure;
|
||||
using Microsoft.PowerShell.Commands;
|
||||
#if !CORECLR
|
||||
// System.DirectoryServices are not in CoreCLR
|
||||
using System.DirectoryServices;
|
||||
#endif
|
||||
|
||||
namespace System.Management.Automation.Language
|
||||
{
|
||||
@@ -793,8 +792,7 @@ namespace System.Management.Automation
|
||||
{ typeof(CimSession), new[] { "CimSession" } },
|
||||
{ typeof(MailAddress), new[] { "mailaddress" } },
|
||||
{ typeof(SemanticVersion), new[] { "semver" } },
|
||||
#if !CORECLR
|
||||
// Following types not in CoreCLR
|
||||
#if !UNIX
|
||||
{ typeof(DirectoryEntry), new[] { "adsi" } },
|
||||
{ typeof(DirectorySearcher), new[] { "adsisearcher" } },
|
||||
{ typeof(ManagementClass), new[] { "wmiclass" } },
|
||||
|
||||
@@ -376,13 +376,13 @@ Describe "Type accelerators" -Tags "CI" {
|
||||
}
|
||||
)
|
||||
|
||||
if ( $IsCoreCLR )
|
||||
if ( !$IsWindows )
|
||||
{
|
||||
$totalAccelerators = 91
|
||||
}
|
||||
else
|
||||
{
|
||||
$totalAccelerators = 95
|
||||
$totalAccelerators = 96
|
||||
|
||||
$extraFullPSAcceleratorTestCases = @(
|
||||
@{
|
||||
@@ -418,7 +418,7 @@ Describe "Type accelerators" -Tags "CI" {
|
||||
$TypeAcceleratorsType::Get[$Accelerator] | Should -Be ($Type)
|
||||
}
|
||||
|
||||
It 'Should have a type accelerator for non-dotnet-core type: <Accelerator>' -Skip:$IsCoreCLR -TestCases $extraFullPSAcceleratorTestCases {
|
||||
It 'Should have a type accelerator for non-dotnet-core type: <Accelerator>' -Skip:(!$IsWindows) -TestCases $extraFullPSAcceleratorTestCases {
|
||||
param($Accelerator, $Type)
|
||||
$TypeAcceleratorsType::Get[$Accelerator] | Should -Be ($Type)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user