diff --git a/src/System.Management.Automation/System.Management.Automation.csproj b/src/System.Management.Automation/System.Management.Automation.csproj index a93edb556..676781b77 100644 --- a/src/System.Management.Automation/System.Management.Automation.csproj +++ b/src/System.Management.Automation/System.Management.Automation.csproj @@ -12,7 +12,10 @@ + + + @@ -88,8 +91,6 @@ - - @@ -129,6 +130,8 @@ + + diff --git a/src/System.Management.Automation/engine/ExtraAdapter.cs b/src/System.Management.Automation/engine/ExtraAdapter.cs index a53f73545..0239e8d5d 100644 --- a/src/System.Management.Automation/engine/ExtraAdapter.cs +++ b/src/System.Management.Automation/engine/ExtraAdapter.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; + } /// /// Returns null if memberName is not a member in the adapter or diff --git a/src/System.Management.Automation/engine/LanguagePrimitives.cs b/src/System.Management.Automation/engine/LanguagePrimitives.cs index bec3a84d7..300c072df 100644 --- a/src/System.Management.Automation/engine/LanguagePrimitives.cs +++ b/src/System.Management.Automation/engine/LanguagePrimitives.cs @@ -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(typeofString, typeofBool, LanguagePrimitives.ConvertStringToBool, ConversionRank.Language); CacheConversion(typeof(SwitchParameter), typeofBool, LanguagePrimitives.ConvertSwitchParameterToBool, ConversionRank.Language); -#if !CORECLR // No DirectoryService && WMIv1 In CoreCLR +#if !UNIX + // Conversions to WMI and ADSI CacheConversion(typeofString, typeof(ManagementObjectSearcher), LanguagePrimitives.ConvertToWMISearcher, ConversionRank.Language); CacheConversion(typeofString, typeof(ManagementClass), LanguagePrimitives.ConvertToWMIClass, ConversionRank.Language); CacheConversion(typeofString, typeof(ManagementObject), LanguagePrimitives.ConvertToWMI, ConversionRank.Language); diff --git a/src/System.Management.Automation/engine/MshObject.cs b/src/System.Management.Automation/engine/MshObject.cs index 822dc3fe0..ff989b54a 100644 --- a/src/System.Management.Automation/engine/MshObject.cs +++ b/src/System.Management.Automation/engine/MshObject.cs @@ -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; } diff --git a/src/System.Management.Automation/engine/parser/TypeResolver.cs b/src/System.Management.Automation/engine/parser/TypeResolver.cs index c4a749abb..c70693602 100644 --- a/src/System.Management.Automation/engine/parser/TypeResolver.cs +++ b/src/System.Management.Automation/engine/parser/TypeResolver.cs @@ -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" } }, diff --git a/test/powershell/Language/Parser/TypeAccelerator.Tests.ps1 b/test/powershell/Language/Parser/TypeAccelerator.Tests.ps1 index 2bbb04668..c7b2cb077 100644 --- a/test/powershell/Language/Parser/TypeAccelerator.Tests.ps1 +++ b/test/powershell/Language/Parser/TypeAccelerator.Tests.ps1 @@ -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: ' -Skip:$IsCoreCLR -TestCases $extraFullPSAcceleratorTestCases { + It 'Should have a type accelerator for non-dotnet-core type: ' -Skip:(!$IsWindows) -TestCases $extraFullPSAcceleratorTestCases { param($Accelerator, $Type) $TypeAcceleratorsType::Get[$Accelerator] | Should -Be ($Type) }