Skip to content

Commit 351c82e

Browse files
committed
[Feature] Make some minor cleanup changes
1 parent 46fa226 commit 351c82e

7 files changed

Lines changed: 42 additions & 90 deletions

File tree

src/ResGen/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ internal class {0} {{
140140
internal static global::System.Resources.ResourceManager ResourceManager {{
141141
get {{
142142
if (object.ReferenceEquals(resourceMan, null)) {{
143-
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(""{1}.resources.{3}"", typeof({0}).GetTypeInfo().Assembly);
143+
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager(""{1}.resources.{3}"", typeof({0}).Assembly);
144144
resourceMan = temp;
145145
}}
146146
return resourceMan;

src/System.Management.Automation/engine/SessionState.cs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -376,55 +376,6 @@ internal void InitializeFixedVariables()
376376
this.GlobalScope.SetVariable(v.Name, v, false, true, this, CommandOrigin.Internal, fastPath: true);
377377
}
378378

379-
/// <summary>
380-
/// Add all of the default built-in functions to this session state instance...
381-
/// </summary>
382-
internal void AddBuiltInEntries(bool addSetStrictMode)
383-
{
384-
// Other built-in variables
385-
AddBuiltInVariables();
386-
AddBuiltInFunctions();
387-
AddBuiltInAliases();
388-
if (addSetStrictMode)
389-
{
390-
SessionStateFunctionEntry f = new SessionStateFunctionEntry("Set-StrictMode", "");
391-
this.AddSessionStateEntry(f);
392-
}
393-
}
394-
395-
/// <summary>
396-
/// Add the built-in variables to this instance of session state...
397-
/// </summary>
398-
internal void AddBuiltInVariables()
399-
{
400-
foreach (SessionStateVariableEntry e in InitialSessionState.BuiltInVariables)
401-
{
402-
this.AddSessionStateEntry(e);
403-
}
404-
}
405-
406-
/// <summary>
407-
/// Add the built-in functions to this instance of session state...
408-
/// </summary>
409-
internal void AddBuiltInFunctions()
410-
{
411-
foreach (SessionStateFunctionEntry f in InitialSessionState.BuiltInFunctions)
412-
{
413-
this.AddSessionStateEntry(f);
414-
}
415-
}
416-
417-
/// <summary>
418-
/// Add the built-in aliases to this instance of session state...
419-
/// </summary>
420-
internal void AddBuiltInAliases()
421-
{
422-
foreach (SessionStateAliasEntry ae in InitialSessionState.BuiltInAliases)
423-
{
424-
this.AddSessionStateEntry(ae, StringLiterals.Global);
425-
}
426-
}
427-
428379
/// <summary>
429380
/// Check to see if an application is allowed to be run.
430381
/// </summary>

src/System.Management.Automation/engine/parser/Compiler.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ internal static Expression Convert(this Expression expr, Type type)
596596
return Expression.Convert(expr, type);
597597
}
598598

599-
if (type.GetTypeInfo().ContainsGenericParameters)
599+
if (type.ContainsGenericParameters)
600600
{
601601
return Expression.Call(
602602
CachedReflectionInfo.LanguagePrimitives_ThrowInvalidCastException,
@@ -614,7 +614,7 @@ internal static Expression Cast(this Expression expr, Type type)
614614
return expr;
615615
}
616616

617-
if ((expr.Type.IsFloating() || expr.Type == typeof(Decimal)) && type.GetTypeInfo().IsPrimitive)
617+
if ((expr.Type.IsFloating() || expr.Type == typeof(Decimal)) && type.IsPrimitive)
618618
{
619619
// Convert correctly handles most "primitive" conversions for PowerShell,
620620
// but it does not correctly handle floating point.
@@ -1513,7 +1513,7 @@ internal static bool TryGetDefaultParameterValue(Type type, out object value)
15131513
return true;
15141514
}
15151515

1516-
if (type.GetTypeInfo().IsClass)
1516+
if (type.IsClass)
15171517
{
15181518
value = null;
15191519
return true;
@@ -1531,7 +1531,7 @@ internal static bool TryGetDefaultParameterValue(Type type, out object value)
15311531
return true;
15321532
}
15331533

1534-
if (LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(type)) && !type.GetTypeInfo().IsEnum)
1534+
if (LanguagePrimitives.IsNumeric(LanguagePrimitives.GetTypeCode(type)) && !type.IsEnum)
15351535
{
15361536
value = 0;
15371537
return true;
@@ -4856,7 +4856,7 @@ public object VisitBinaryExpression(BinaryExpressionAst binaryExpressionAst)
48564856
var isType = (Type)((ConstantExpression)rhs).Value;
48574857
if (!(isType == typeof(PSCustomObject)) && !(isType == typeof(PSObject)))
48584858
{
4859-
lhs = lhs.Type.GetTypeInfo().IsValueType ? lhs : Expression.Call(CachedReflectionInfo.PSObject_Base, lhs);
4859+
lhs = lhs.Type.IsValueType ? lhs : Expression.Call(CachedReflectionInfo.PSObject_Base, lhs);
48604860
if (binaryExpressionAst.Operator == TokenKind.Is)
48614861
return Expression.TypeIs(lhs, isType);
48624862
return Expression.Not(Expression.TypeIs(lhs, isType));
@@ -5162,7 +5162,7 @@ private Expression CompileIncrementOrDecrement(ExpressionAst exprAst, int valueT
51625162
var newValue = DynamicExpression.Dynamic(PSUnaryOperationBinder.Get(valueToAdd == 1 ? ExpressionType.Increment : ExpressionType.Decrement),
51635163
typeof(object), tmp);
51645164
exprs.Add(av.SetValue(this, newValue));
5165-
if (tmp.Type.GetTypeInfo().IsValueType)
5165+
if (tmp.Type.IsValueType)
51665166
{
51675167
// This is the result of the expression - it might be unused, but we don't bother knowing if it is used or not.
51685168
exprs.Add(tmp);
@@ -5363,7 +5363,7 @@ public object VisitMemberExpression(MemberExpressionAst memberExpressionAst)
53635363
if (memberExpressionAst.Static && (memberExpressionAst.Expression is TypeExpressionAst))
53645364
{
53655365
var type = ((TypeExpressionAst)memberExpressionAst.Expression).TypeName.GetReflectionType();
5366-
if (type != null && !type.GetTypeInfo().IsGenericTypeDefinition)
5366+
if (type != null && !type.IsGenericTypeDefinition)
53675367
{
53685368
var member = memberExpressionAst.Member as StringConstantExpressionAst;
53695369
if (member != null)
@@ -5419,7 +5419,7 @@ internal static PSMethodInvocationConstraints GetInvokeMemberConstraints(BaseCto
54195419
TypeDefinitionAst typeDefinitionAst = Ast.GetAncestorTypeDefinitionAst(invokeMemberExpressionAst);
54205420
if (typeDefinitionAst != null)
54215421
{
5422-
targetTypeConstraint = (typeDefinitionAst as TypeDefinitionAst).Type.GetTypeInfo().BaseType;
5422+
targetTypeConstraint = (typeDefinitionAst as TypeDefinitionAst).Type.BaseType;
54235423
}
54245424
else
54255425
{

src/System.Management.Automation/engine/parser/VariableAnalysis.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public override AstVisitAction VisitTrap(TrapStatementAst trapStatementAst)
290290
return AstVisitAction.SkipChildren;
291291
}
292292

293-
// Return true if the variable is newly allocated and should be allocated in the locals tuple.
293+
// Add a variable to the variable dictionary
294294
private void NoteVariable(string variableName, int index, Type type, bool automatic = false, bool preferenceVariable = false)
295295
{
296296
if (!_variables.ContainsKey(variableName))
@@ -504,7 +504,7 @@ private Tuple<Type, Dictionary<string, int>> AnalyzeImpl(ExpressionAst exprAst)
504504
{
505505
_variables = FindAllVariablesVisitor.Visit(exprAst);
506506

507-
// We disable optimizations for trap because it simplifies what we need to do when invoking
507+
// We disable optimizations for expression because it simplifies what we need to do when invoking
508508
// the default argument, and it's assumed that the code inside a default argument rarely, if ever, actually creates
509509
// any local variables.
510510
_disableOptimizations = true;
@@ -731,7 +731,7 @@ private static bool MustBeBoxed(Type type)
731731
// $value.Property = 42
732732
// We make sure we never allocate an instance of such mutable types in the MutableType.
733733

734-
return (type.GetTypeInfo().IsValueType && PSVariableAssignmentBinder.IsValueTypeMutable(type)) && typeof(SwitchParameter) != type;
734+
return (type.IsValueType && PSVariableAssignmentBinder.IsValueTypeMutable(type)) && typeof(SwitchParameter) != type;
735735
}
736736

737737
private static void FixTupleIndex(Ast ast, int newIndex)

0 commit comments

Comments
 (0)