mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make experimental feature PSAMSIMethodInvocationLogging stable (#18041)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
[
|
||||
"PSAMSIMethodInvocationLogging",
|
||||
"PSAnsiRenderingFileInfo",
|
||||
"PSCommandNotFoundSuggestion",
|
||||
"PSLoadAssemblyFromNativeCode",
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[
|
||||
"PSAMSIMethodInvocationLogging",
|
||||
"PSAnsiRenderingFileInfo",
|
||||
"PSCommandNotFoundSuggestion",
|
||||
"PSLoadAssemblyFromNativeCode",
|
||||
|
||||
@@ -23,7 +23,6 @@ namespace System.Management.Automation
|
||||
internal const string EngineSource = "PSEngine";
|
||||
internal const string PSNativeCommandArgumentPassingFeatureName = "PSNativeCommandArgumentPassing";
|
||||
internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference";
|
||||
internal const string PSAMSIMethodInvocationLogging = "PSAMSIMethodInvocationLogging";
|
||||
internal const string PSStrictModeAssignment = "PSStrictModeAssignment";
|
||||
|
||||
#endregion
|
||||
@@ -125,9 +124,6 @@ namespace System.Management.Automation
|
||||
new ExperimentalFeature(
|
||||
name: PSNativeCommandErrorActionPreferenceFeatureName,
|
||||
description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"),
|
||||
new ExperimentalFeature(
|
||||
name: PSAMSIMethodInvocationLogging,
|
||||
description: "Provides AMSI notification of .NET method invocations."),
|
||||
new ExperimentalFeature(
|
||||
name: PSStrictModeAssignment,
|
||||
description: "Add support of setting Strict-Mode with Invoke-Command"),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user