diff options
author | Aditya Patwardhan <adityap@microsoft.com> | 2022-09-14 00:51:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-14 00:51:32 +0300 |
commit | d1bd7eb841610201eb4908b42699668b47199720 (patch) | |
tree | a02162b6fb9f5cb890ada627f1761b6c76bbc9bf | |
parent | 78b555bdb08bc2955bab929de2ac9d7cc22b4464 (diff) |
Make experimental feature `PSAMSIMethodInvocationLogging` stable (#18041) (#18083)
4 files changed, 14 insertions, 23 deletions
diff --git a/experimental-feature-linux.json b/experimental-feature-linux.json index 326b8f608e..e4ad962129 100644 --- a/experimental-feature-linux.json +++ b/experimental-feature-linux.json @@ -1,5 +1,4 @@ [ - "PSAMSIMethodInvocationLogging", "PSCommandNotFoundSuggestion", "PSLoadAssemblyFromNativeCode", "PSNativeCommandErrorActionPreference", diff --git a/experimental-feature-windows.json b/experimental-feature-windows.json index 326b8f608e..e4ad962129 100644 --- a/experimental-feature-windows.json +++ b/experimental-feature-windows.json @@ -1,5 +1,4 @@ [ - "PSAMSIMethodInvocationLogging", "PSCommandNotFoundSuggestion", "PSLoadAssemblyFromNativeCode", "PSNativeCommandErrorActionPreference", diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index 8d8c2dd312..c03c53f335 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -23,7 +23,6 @@ namespace System.Management.Automation internal const string EngineSource = "PSEngine"; internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference"; internal const string PSRemotingSSHTransportErrorHandling = "PSRemotingSSHTransportErrorHandling"; - internal const string PSAMSIMethodInvocationLogging = "PSAMSIMethodInvocationLogging"; #endregion @@ -120,10 +119,7 @@ namespace System.Management.Automation description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"), new ExperimentalFeature( name: PSRemotingSSHTransportErrorHandling, - description: "Removes the SSH remoting transport stdErr stream message handling as terminating errors, and instead just writes error messages to console."), - new ExperimentalFeature( - name: PSAMSIMethodInvocationLogging, - description: "Provides AMSI notification of .NET method invocations.") + description: "Removes the SSH remoting transport stdErr stream message handling as terminating errors, and instead just writes error messages to console.") }; EngineExperimentalFeatures = new ReadOnlyCollection<ExperimentalFeature>(engineFeatures); diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index e6f7eee438..8662cc72ec 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -6891,22 +6891,19 @@ namespace System.Management.Automation.Language expr = Expression.Block(expr, ExpressionCache.AutomationNullConstant); } - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSAMSIMethodInvocationLogging)) - { - // Expression block runs two expressions in order: - // - Log method invocation to AMSI Notifications (can throw PSSecurityException) - // - Invoke method - string targetName = methodInfo.ReflectedType?.FullName ?? string.Empty; - expr = Expression.Block( - Expression.Call( - CachedReflectionInfo.MemberInvocationLoggingOps_LogMemberInvocation, - Expression.Constant(targetName), - Expression.Constant(name), - Expression.NewArrayInit( - typeof(object), - args.Select(static e => e.Expression.Cast(typeof(object))))), - expr); - } + // Expression block runs two expressions in order: + // - Log method invocation to AMSI Notifications (can throw PSSecurityException) + // - Invoke method + string targetName = methodInfo.ReflectedType?.FullName ?? string.Empty; + expr = Expression.Block( + Expression.Call( + CachedReflectionInfo.MemberInvocationLoggingOps_LogMemberInvocation, + Expression.Constant(targetName), + Expression.Constant(name), + Expression.NewArrayInit( + typeof(object), + args.Select(static e => e.Expression.Cast(typeof(object))))), + expr); // If we're calling SteppablePipeline.{Begin|Process|End}, we don't want // to wrap exceptions - this is very much a special case to help error |