diff --git a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs index c0055b8dab..1ae30cf916 100644 --- a/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs +++ b/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs @@ -782,7 +782,7 @@ namespace System.Management.Automation private static string GetOperatorDescription(string op) { - return ResourceManagerCache.GetResourceString(typeof(CompletionCompleters).GetTypeInfo().Assembly, + return ResourceManagerCache.GetResourceString(typeof(CompletionCompleters).Assembly, "System.Management.Automation.resources.TabCompletionStrings", op + "OperatorDescription"); } @@ -1639,7 +1639,7 @@ namespace System.Management.Automation parameterType = parameterType.GetElementType(); } - if (parameterType.GetTypeInfo().IsEnum) + if (parameterType.IsEnum) { RemoveLastNullCompletionResult(result); @@ -5468,15 +5468,13 @@ namespace System.Management.Automation protected string GetTooltipPrefix() { - TypeInfo typeInfo = Type.GetTypeInfo(); - if (typeof(Delegate).IsAssignableFrom(Type)) return "Delegate "; - if (typeInfo.IsInterface) + if (Type.IsInterface) return "Interface "; - if (typeInfo.IsClass) + if (Type.IsClass) return "Class "; - if (typeInfo.IsEnum) + if (Type.IsEnum) return "Enum "; if (typeof(ValueType).IsAssignableFrom(Type)) return "Struct "; @@ -6337,7 +6335,7 @@ namespace System.Management.Automation if (strValue == null) { object baseObj = PSObject.Base(value); - if (baseObj is string || baseObj.GetType().GetTypeInfo().IsPrimitive) + if (baseObj is string || baseObj.GetType().IsPrimitive) { strValue = LanguagePrimitives.ConvertTo(value); } diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 037b9651bb..a16e50e589 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -4796,7 +4796,7 @@ namespace Microsoft.PowerShell.Commands ProviderInfo pi = pl.Value[i]; // If it was implemented by this module, remove it - string implAssemblyLocation = pi.ImplementingType.GetTypeInfo().Assembly.Location; + string implAssemblyLocation = pi.ImplementingType.Assembly.Location; if (implAssemblyLocation.Equals(module.Path, StringComparison.OrdinalIgnoreCase)) { // Remove all drives from the top level session state diff --git a/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs b/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs index 3dd8d3ac92..bde9976d2e 100644 --- a/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs +++ b/src/System.Management.Automation/engine/Modules/RemoveModuleCommand.cs @@ -259,7 +259,7 @@ namespace Microsoft.PowerShell.Commands Dbg.Assert(pList.Value != null, "There should never be a null list of entries in the provider table"); foreach (ProviderInfo pInfo in pList.Value) { - string implTypeAssemblyLocation = pInfo.ImplementingType.GetTypeInfo().Assembly.Location; + string implTypeAssemblyLocation = pInfo.ImplementingType.Assembly.Location; if (implTypeAssemblyLocation.Equals(module.Path, StringComparison.OrdinalIgnoreCase)) { foreach (PSDriveInfo dInfo in Context.TopLevelSessionState.GetDrivesForProvider(pInfo.FullName)) diff --git a/src/System.Management.Automation/engine/WinRT/IInspectable.cs b/src/System.Management.Automation/engine/WinRT/IInspectable.cs index 8177dcb2ff..42ef2b36b2 100644 --- a/src/System.Management.Automation/engine/WinRT/IInspectable.cs +++ b/src/System.Management.Automation/engine/WinRT/IInspectable.cs @@ -34,7 +34,7 @@ namespace System.Management.Automation // TypeAttributes.WindowsRuntime is part of CLR 4.5. Inorder to build PowerShell for // CLR 4.0, a string comparison for the for the existence of TypeAttributes.WindowsRuntime // in the Attributes flag is performed rather than the actual bitwise comparison. - return type.GetTypeInfo().Attributes.ToString().Contains("WindowsRuntime"); + return type.Attributes.ToString().Contains("WindowsRuntime"); } } } diff --git a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs index 4fa7952163..03eb9b7534 100644 --- a/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs +++ b/src/System.Management.Automation/engine/hostifaces/PSDataCollection.cs @@ -1614,7 +1614,7 @@ namespace System.Management.Automation { if (null == value) { - if (typeof(T).GetTypeInfo().IsValueType) + if (typeof(T).IsValueType) { throw PSTraceSource.NewArgumentNullException("value", PSDataBufferStrings.ValueNullReference); } diff --git a/src/System.Management.Automation/engine/lang/parserutils.cs b/src/System.Management.Automation/engine/lang/parserutils.cs index 7d5e7f0889..50e22f3f00 100644 --- a/src/System.Management.Automation/engine/lang/parserutils.cs +++ b/src/System.Management.Automation/engine/lang/parserutils.cs @@ -440,7 +440,7 @@ namespace System.Management.Automation Type lvalType = lval != null ? lval.GetType() : null; Type rvalType = rval != null ? rval.GetType() : null; Type opType; - if (lvalType == null || (lvalType.GetTypeInfo().IsPrimitive)) + if (lvalType == null || (lvalType.IsPrimitive)) { // Prefer the LHS type when looking for the operator, but attempt the right // the lhs can't have an operator. @@ -449,7 +449,7 @@ namespace System.Management.Automation // would look for overloads in both types, but this logic covers the most common // cases. - opType = (rvalType == null || rvalType.GetTypeInfo().IsPrimitive) ? null : rvalType; + opType = (rvalType == null || rvalType.IsPrimitive) ? null : rvalType; } else { diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs index 418724d8dd..e1fb2a8a86 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/EncodeAndDecode.cs @@ -1649,7 +1649,7 @@ namespace System.Management.Automation throw PSTraceSource.NewArgumentNullException("propertyName"); } - if (typeof(T).GetTypeInfo().IsEnum) + if (typeof(T).IsEnum) { if (propertyValue is string) { @@ -1698,14 +1698,12 @@ namespace System.Management.Automation } else if (propertyValue == null) { - TypeInfo typeInfo = typeof(T).GetTypeInfo(); - - if (!typeInfo.IsValueType) + if (!typeof(T).IsValueType) { return default(T); } - if (typeInfo.IsGenericType && typeof(T).GetGenericTypeDefinition().Equals(typeof(Nullable<>))) + if (typeof(T).IsGenericType && typeof(T).GetGenericTypeDefinition().Equals(typeof(Nullable<>))) { return default(T); } diff --git a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs index 1199b6afc3..f04aae5213 100644 --- a/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs +++ b/src/System.Management.Automation/engine/remoting/common/WireDataFormat/RemoteHostEncoder.cs @@ -107,7 +107,7 @@ namespace System.Management.Automation.Remoting /// private static bool IsCollection(Type type) { - return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Collection<>)); + return type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Collection<>)); } private static bool IsGenericIEnumerableOfInt(Type type) @@ -155,7 +155,7 @@ namespace System.Management.Automation.Remoting /// private static bool IsDictionary(Type type) { - return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Dictionary<,>)); + return type.IsGenericType && type.GetGenericTypeDefinition().Equals(typeof(Dictionary<,>)); } /// @@ -335,7 +335,7 @@ namespace System.Management.Automation.Remoting { return obj; } - else if (type.GetTypeInfo().IsEnum) + else if (type.IsEnum) { return (int)obj; } @@ -449,7 +449,7 @@ namespace System.Management.Automation.Remoting } return cred; } - else if (obj is int && type.GetTypeInfo().IsEnum) + else if (obj is int && type.IsEnum) { return Enum.ToObject(type, (int)obj); } diff --git a/src/System.Management.Automation/namespaces/ProviderBase.cs b/src/System.Management.Automation/namespaces/ProviderBase.cs index a299513149..eefaf9d9be 100644 --- a/src/System.Management.Automation/namespaces/ProviderBase.cs +++ b/src/System.Management.Automation/namespaces/ProviderBase.cs @@ -1547,7 +1547,7 @@ namespace System.Management.Automation.Provider ResourceManager manager = ResourceManagerCache.GetResourceManager( - this.GetType().GetTypeInfo().Assembly, + this.GetType().Assembly, baseName); string retValue = null; diff --git a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs index 32741bea03..fa2c1f5d54 100644 --- a/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs +++ b/src/System.Management.Automation/singleshell/config/MshSnapinInfo.cs @@ -901,7 +901,7 @@ namespace System.Management.Automation // the assemblies is patched. ie., all monad assemblies should have the // same version number. - Assembly currentAssembly = typeof(PSSnapInReader).GetTypeInfo().Assembly; + Assembly currentAssembly = typeof(PSSnapInReader).Assembly; assemblyVersion = currentAssembly.GetName().Version; byte[] publicTokens = currentAssembly.GetName().GetPublicKeyToken(); if (publicTokens.Length == 0) diff --git a/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs b/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs index 179d9f7615..e3eacff364 100644 --- a/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs +++ b/src/System.Management.Automation/singleshell/config/MshSnapinLoadException.cs @@ -101,7 +101,7 @@ namespace System.Management.Automation.Runspaces // no useful information anyway. if (!String.IsNullOrEmpty(_PSSnapin) && !String.IsNullOrEmpty(_reason)) { - Assembly currentAssembly = typeof(PSSnapInException).GetTypeInfo().Assembly; + Assembly currentAssembly = typeof(PSSnapInException).Assembly; if (_warning) { diff --git a/src/System.Management.Automation/utils/ExtensionMethods.cs b/src/System.Management.Automation/utils/ExtensionMethods.cs index e36d698a82..fe4d5ea908 100644 --- a/src/System.Management.Automation/utils/ExtensionMethods.cs +++ b/src/System.Management.Automation/utils/ExtensionMethods.cs @@ -99,12 +99,12 @@ namespace System.Management.Automation internal static bool IsNumericOrPrimitive(this Type type) { - return type.GetTypeInfo().IsPrimitive || LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(type)); + return type.IsPrimitive || LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(type)); } internal static bool IsSafePrimitive(this Type type) { - return type.GetTypeInfo().IsPrimitive && (type != typeof(IntPtr)) && (type != typeof(UIntPtr)); + return type.IsPrimitive && (type != typeof(IntPtr)) && (type != typeof(UIntPtr)); } internal static bool IsFloating(this Type type) @@ -126,7 +126,7 @@ namespace System.Management.Automation internal static IEnumerable GetCustomAttributes(this Type type, bool inherit) where T : Attribute { - return from attr in type.GetTypeInfo().GetCustomAttributes(typeof(T), inherit) + return from attr in type.GetCustomAttributes(typeof(T), inherit) where attr is T select (T)attr; } diff --git a/src/System.Management.Automation/utils/PSTelemetryWrapper.cs b/src/System.Management.Automation/utils/PSTelemetryWrapper.cs index 995de89a16..969ef39d01 100644 --- a/src/System.Management.Automation/utils/PSTelemetryWrapper.cs +++ b/src/System.Management.Automation/utils/PSTelemetryWrapper.cs @@ -27,7 +27,7 @@ namespace System.Management.Automation.Internal // We build against CLR4.5 so we can run on Win7/Win8, but we want to use apis added to CLR 4.6. // So we use reflection, and if that fails, we just silently skip logging our telemetry. - var diagnosticsTracingAssembly = typeof(EventSource).GetTypeInfo().Assembly; + var diagnosticsTracingAssembly = typeof(EventSource).Assembly; Type eventSourceSettingsType = diagnosticsTracingAssembly.GetType("System.Diagnostics.Tracing.EventSourceSettings"); if (eventSourceSettingsType == null) diff --git a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs index ca1b5c8680..d7f4827af0 100755 --- a/src/System.Management.Automation/utils/tracing/SysLogProvider.cs +++ b/src/System.Management.Automation/utils/tracing/SysLogProvider.cs @@ -198,7 +198,7 @@ namespace System.Management.Automation.Tracing { if (object.ReferenceEquals(_resourceManager, null)) { - _resourceManager = new global::System.Resources.ResourceManager("System.Management.Automation.resources.EventResource", typeof(EventResource).GetTypeInfo().Assembly); + _resourceManager = new global::System.Resources.ResourceManager("System.Management.Automation.resources.EventResource", typeof(EventResource).Assembly); } return _resourceManager; }