internal override IEnumerable <PSTypeName> GetInferredType(CompletionContext context) { TypeConstraintAst iteratorVariable0 = this.Attributes.OfType <TypeConstraintAst>().FirstOrDefault <TypeConstraintAst>(); if (iteratorVariable0 != null) { Type reflectionType = iteratorVariable0.TypeName.GetReflectionType(); if (reflectionType != null) { yield return(new PSTypeName(reflectionType)); } else { yield return(new PSTypeName(iteratorVariable0.TypeName.FullName)); } } IEnumerator <AttributeAst> enumerator = this.Attributes.OfType <AttributeAst>().GetEnumerator(); while (enumerator.MoveNext()) { AttributeAst current = enumerator.Current; PSTypeNameAttribute attribute = null; try { attribute = current.GetAttribute() as PSTypeNameAttribute; } catch (RuntimeException) { } if (attribute != null) { yield return(new PSTypeName(attribute.PSTypeName)); } } }
private void CheckForDuplicateParameters(IEnumerable <ParameterAst> parameters) { if (parameters.Any <ParameterAst>()) { HashSet <string> set = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (ParameterAst ast in parameters) { string userPath = ast.Name.VariablePath.UserPath; if (set.Contains(userPath)) { this._parser.ReportError(ast.Name.Extent, ParserStrings.DuplicateFormalParameter, new object[] { userPath }); } else { set.Add(userPath); } TypeConstraintAst ast2 = (from t in ast.Attributes.OfType <TypeConstraintAst>() where typeof(void).Equals(t.TypeName.GetReflectionType()) select t).FirstOrDefault <TypeConstraintAst>(); if (ast2 != null) { this._parser.ReportError(ast2.Extent, ParserStrings.VoidTypeConstraintNotAllowed, new object[0]); } } } }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { Type type = ast.TypeName.GetReflectionType(); if (type != null) { Diagnostics.Assert(!(type is TypeBuilder), "ReflectionType can never be TypeBuilder"); } return(AstVisitAction.Continue); }
public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent) { if (body == null) { throw PSTraceSource.NewArgumentNullException("body"); } if (trapType != null) { this.TrapType = trapType; base.SetParent(trapType); } this.Body = body; base.SetParent(body); }
internal static Attribute GetAttribute(TypeConstraintAst typeConstraintAst) { Type type = TypeOps.ResolveTypeName(typeConstraintAst.TypeName); return new ArgumentTypeConverterAttribute(new Type[] { type }); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { CheckArrayTypeNameDepth(typeConstraintAst.TypeName, typeConstraintAst.Extent, this._parser); return(AstVisitAction.Continue); }
private bool IsExactMatch(TypeConstraintAst typeConstraintAst, Exception ex) { return (typeConstraintAst != null) && (ex.GetType() == typeConstraintAst.TypeName.GetReflectionType()); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw new NotImplementedException(); //VisitTypeConstraint(typeConstraintAst); }
/// <summary> /// Visit type constraint /// </summary> /// <param name="typeConstraintAst"></param> /// <returns></returns> public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { System.Diagnostics.Debug.Assert(false, "Code is unreachable"); return null; }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { DispatchTypeName(typeConstraintAst.TypeName, genericArgumentCount: 0, isAttribute: false); return AstVisitAction.Continue; }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return AutomationNull.Value; }
public ConvertExpressionAst(IScriptExtent extent, TypeConstraintAst typeConstraint, ExpressionAst child) : base(extent, typeConstraint, child) { this.Type = typeConstraint; }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { this.CheckTypeName(typeConstraintAst, typeConstraintAst.TypeName); return(AstVisitAction.Continue); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { return this.Check(ast); }
public TrapStatementAst(IScriptExtent extent, TypeConstraintAst trapType, StatementBlockAst body) : base(extent) { this.TrapType = trapType; this.Body = body; }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw new UnexpectedElementException(); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { CheckArrayTypeNameDepth(typeConstraintAst.TypeName, typeConstraintAst.Extent, _parser); return AstVisitAction.Continue; }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return(AutomationNull.Value); }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw PSTraceSource.NewArgumentException("ast"); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { return CheckParent(ast); }
internal static Attribute GetAttribute(TypeConstraintAst typeConstraintAst) { Type type = null; var ihct = typeConstraintAst.TypeName as ISupportsTypeCaching; if (ihct != null) { type = ihct.CachedType; } if (type == null) { type = TypeOps.ResolveTypeName(typeConstraintAst.TypeName, typeConstraintAst.Extent); if (ihct != null) { ihct.CachedType = type; } } return new ArgumentTypeConverterAttribute(type); }
/// <summary/> public virtual object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return _decorated.VisitTypeConstraint(typeConstraintAst); }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { Diagnostics.Assert(false, "Nothing to generate for a type constraint"); return null; }
public System.Object VisitTypeConstraint(System.Management.Automation.Language.TypeConstraintAst typeConstraintAst) { IScriptExtent mappedExtent = MapExtent(typeConstraintAst.Extent); return(new TypeConstraintAst(mappedExtent, typeConstraintAst.TypeName)); }
internal static Expression ConvertValue(TypeConstraintAst typeConstraint, Expression expr) { var typeName = typeConstraint.TypeName; var toType = typeName.GetReflectionType(); if (toType != null) { if (toType == typeof(void)) { return Expression.Block(typeof(void), expr); } return expr.Convert(toType); } // typeName can't be resolved at compile time, so defer resolution until runtime. return DynamicExpression.Dynamic(PSDynamicConvertBinder.Get(), typeof(object), Expression.Call(CachedReflectionInfo.TypeOps_ResolveTypeName, Expression.Constant(typeName), Expression.Constant(typeName.Extent)), expr); }
private bool IsInheritedMatch(TypeConstraintAst typeConstraintAst, Exception ex) { return (typeConstraintAst != null) && (typeConstraintAst.TypeName.GetReflectionType().IsInstanceOfType(ex)); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { return(Check(ast)); }
public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return AstVisitAction.Continue; }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return false; }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst ast) { Type type = ast.TypeName.GetReflectionType(); if (type != null) { Diagnostics.Assert(!(type.GetTypeInfo() is TypeBuilder), "ReflectionType can never be TypeBuilder"); } return AstVisitAction.Continue; }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { DispatchTypeName(typeConstraintAst.TypeName, genericArgumentCount: 0, isAttribute: false); return(AstVisitAction.Continue); }
public override AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { this.CheckTypeName(typeConstraintAst, typeConstraintAst.TypeName); return AstVisitAction.Continue; }
/// <summary/> public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) => DefaultVisit(typeConstraintAst);
/// <summary/> public virtual object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return(null); }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return null; }
/// <summary/> public virtual AstVisitAction VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return(AstVisitAction.Continue); }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { return(false); }
public object VisitTypeConstraint(TypeConstraintAst typeConstraintAst) { throw new NotImplementedException(); }