From 76ece070ba7adde662b040b39cd93eec438e5e49 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 20 Jun 2019 10:27:13 -0700 Subject: [PATCH] Remove dead code about 'IsTransparentProxy' --- .../engine/parser/Parser.cs | 78 +++++++++---------- .../engine/runtime/Binding/Binders.cs | 14 +--- .../utils/ClrFacade.cs | 13 ---- 3 files changed, 42 insertions(+), 63 deletions(-) diff --git a/src/System.Management.Automation/engine/parser/Parser.cs b/src/System.Management.Automation/engine/parser/Parser.cs index d949a826e16..cff16b0c4de 100644 --- a/src/System.Management.Automation/engine/parser/Parser.cs +++ b/src/System.Management.Automation/engine/parser/Parser.cs @@ -4370,49 +4370,49 @@ private MemberAst ClassMemberRule(string className, out List astsOnError) switch (token.Kind) { #if SUPPORT_PUBLIC_PRIVATE - case TokenKind.Public: - if (publicToken != null) - { - ReportError(token.Extent, - nameof(ParserStrings.DuplicateQualifier), - ParserStrings.DuplicateQualifier, - token.Text); - } + case TokenKind.Public: + if (publicToken != null) + { + ReportError(token.Extent, + nameof(ParserStrings.DuplicateQualifier), + ParserStrings.DuplicateQualifier, + token.Text); + } - if (privateToken != null) - { - ReportError(token.Extent, - nameof(ParserStrings.ModifiersCannotBeCombined), - ParserStrings.ModifiersCannotBeCombined, - privateToken.Text, - token.Text); - } + if (privateToken != null) + { + ReportError(token.Extent, + nameof(ParserStrings.ModifiersCannotBeCombined), + ParserStrings.ModifiersCannotBeCombined, + privateToken.Text, + token.Text); + } - publicToken = token; - SkipToken(); - break; + publicToken = token; + SkipToken(); + break; - case TokenKind.Private: - if (privateToken != null) - { - ReportError(token.Extent, - nameof(ParserStrings.DuplicateQualifier), - ParserStrings.DuplicateQualifier, - token.Text); - } + case TokenKind.Private: + if (privateToken != null) + { + ReportError(token.Extent, + nameof(ParserStrings.DuplicateQualifier), + ParserStrings.DuplicateQualifier, + token.Text); + } - if (publicToken != null) - { - ReportError(token.Extent, - nameof(ParserStrings.ModifiersCannotBeCombined), - ParserStrings.ModifiersCannotBeCombined, - publicToken.Text, - token.Text); - } + if (publicToken != null) + { + ReportError(token.Extent, + nameof(ParserStrings.ModifiersCannotBeCombined), + ParserStrings.ModifiersCannotBeCombined, + publicToken.Text, + token.Text); + } - privateToken = token; - SkipToken(); - break; + privateToken = token; + SkipToken(); + break; #endif case TokenKind.Hidden: @@ -4529,7 +4529,7 @@ private MemberAst ClassMemberRule(string className, out List astsOnError) return null; } -#if FALSE +#if SUPPORT_PUBLIC_PRIVATE MethodAttributes attributes = privateToken != null ? MethodAttributes.Private : MethodAttributes.Public; #else MethodAttributes attributes = MethodAttributes.Public; diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index 55c34275123..f67cbab7a7a 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -79,7 +79,7 @@ internal static DynamicMetaObject WriteToDebugLog(this DynamicMetaObject obj, Dy internal static BindingRestrictions GetSimpleTypeRestriction(this DynamicMetaObject obj) { - if (obj.Value == null || ClrFacade.IsTransparentProxy(obj.Value)) + if (obj.Value == null) { return BindingRestrictions.GetInstanceRestriction(obj.Expression, obj.Value); } @@ -132,7 +132,7 @@ internal static BindingRestrictions PSGetStaticMemberRestriction(this DynamicMet return obj.Restrictions; } - if (obj.Value == null || ClrFacade.IsTransparentProxy(obj.Value)) + if (obj.Value == null) { return BindingRestrictions.GetInstanceRestriction(obj.Expression, obj.Value); } @@ -187,7 +187,7 @@ internal static BindingRestrictions PSGetTypeRestriction(this DynamicMetaObject return obj.Restrictions; } - if (obj.Value == null || ClrFacade.IsTransparentProxy(obj.Value)) + if (obj.Value == null) { return BindingRestrictions.GetInstanceRestriction(obj.Expression, obj.Value); } @@ -6878,14 +6878,6 @@ internal static DynamicMetaObject InvokeDotNetMethod( argValues[i] = arg == AutomationNull.Value ? null : arg; } - if (ClrFacade.IsTransparentProxy(target.Value) && (psMethodInvocationConstraints == null || psMethodInvocationConstraints.MethodTargetType == null)) - { - var argTypes = (psMethodInvocationConstraints == null) - ? new Type[numArgs] - : psMethodInvocationConstraints.ParameterTypes.ToArray(); - psMethodInvocationConstraints = new PSMethodInvocationConstraints(target.Value.GetType(), argTypes); - } - var result = Adapter.FindBestMethod( mi, psMethodInvocationConstraints, diff --git a/src/System.Management.Automation/utils/ClrFacade.cs b/src/System.Management.Automation/utils/ClrFacade.cs index eea0ffb7d70..cba0894e7ed 100644 --- a/src/System.Management.Automation/utils/ClrFacade.cs +++ b/src/System.Management.Automation/utils/ClrFacade.cs @@ -280,19 +280,6 @@ private static SecurityZone ReadFromZoneIdentifierDataStream(string filePath) #region Misc - /// - /// Facade for RemotingServices.IsTransparentProxy(object) - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal static bool IsTransparentProxy(object obj) - { -#if CORECLR // Namespace System.Runtime.Remoting is not in CoreCLR - return false; -#else - return System.Runtime.Remoting.RemotingServices.IsTransparentProxy(obj); -#endif - } - /// /// Facade for ManagementDateTimeConverter.ToDmtfDateTime(DateTime) ///