public static void Go(OutputWriter writer, TypeOfExpressionSyntax expression) { writer.Write("__TypeOf!("); TypeProcessor.AddUsedType(TypeProcessor.GetTypeInfo(expression.Type).Type); writer.Write(TypeProcessor.ConvertType(expression.Type)); writer.Write(")"); }
internal static bool TryGetType(TypeOfExpressionSyntax expression, INamedTypeSymbol containingType, SemanticModel semanticModel, CancellationToken cancellationToken, out ITypeSymbol type) { type = null; if (expression == null) { return(false); } type = semanticModel.GetTypeInfoSafe(expression.Type, cancellationToken).Type; if (type.Kind == SymbolKind.TypeParameter) { while (containingType != null) { if (containingType.IsGenericType && containingType != KnownSymbols.Object) { var index = containingType.TypeParameters.IndexOf((ITypeParameterSymbol)type); if (index >= 0) { type = containingType.TypeArguments[index]; return(true); } } containingType = containingType.ContainingType; } } return(type != null); }
public static bool IsConstantExpression(ExpressionSyntax expression, SemanticModel semanticModel) { // this assumes you've already checked for literals MemberAccessExpressionSyntax memberAccess = expression as MemberAccessExpressionSyntax; if (memberAccess != null) { // return true for member accesses that resolve to a constant e.g. SurveillanceConstants.TrendWidth Optional <object> constValue = semanticModel.GetConstantValue(expression); return(constValue.HasValue); } else { TypeOfExpressionSyntax typeOfExpression = expression as TypeOfExpressionSyntax; if (typeOfExpression != null) { if (typeOfExpression.Type is PredefinedTypeSyntax) { // return true for typeof(<static type>) return(true); } } } return(false); }
SyntaxList <AttributeListSyntax> CreateAttributes() { TypeOfExpressionSyntax typeOfExpression = SF.TypeOfExpression(Symbols.GetNameSyntax(Type)); SyntaxToken fullyQualifiedNameLiteral = SF.Literal(Type.FullyQualifiedName); return(SF.List(GetAttributeLists())); IEnumerable <AttributeListSyntax> GetAttributeLists() { yield return(SF.AttributeList(SF.SeparatedList(new[] { SF.Attribute( SF.ParseName("JsiiEnum"), SF.ParseAttributeArgumentList($"(nativeType: {typeOfExpression}, fullyQualifiedName: {fullyQualifiedNameLiteral})") ) }))); if (Type.Docs?.Stability == Stability.Deprecated) { var argument = Type.Docs?.Deprecated != null?SF.Literal(Type.Docs?.Deprecated).ToString() : ""; yield return(SF.AttributeList(SF.SeparatedList(new[] { SF.Attribute( SF.ParseName("System.Obsolete"), SF.ParseAttributeArgumentList($"({argument})") ) }))); } } }
public static void Go(HaxeWriter writer, TypeOfExpressionSyntax expression) { throw new Exception("typeof is not supported unless part of Enum.Parse or Enum.GetValues " + Utility.Descriptor(expression)); //writer.Write("typeof("); //writer.Write(TypeProcessor.ConvertType(expression.Type)); //writer.Write(")"); }
public override SyntaxNode VisitTypeOfExpression(TypeOfExpressionSyntax node) { bool legal = true; var oper = m_Model.GetOperation(node) as ITypeOfExpression; var type = oper.TypeOperand as INamedTypeSymbol; SymbolTable.TryRemoveNullable(ref type); if (null != type && SymbolTable.Instance.IsExternSymbol(type)) { if (type.IsGenericType) { if (!SymbolTable.Instance.IsLegalGenericType(type)) { legal = false; } } else { if (SymbolTable.Instance.IsIllegalType(type)) { legal = false; } } } var newNode = base.VisitTypeOfExpression(node); if (!legal) { newNode = ReportAndAttachError(newNode, "[Cs2LuaRewriter] Unsupported extern type !"); } return(newNode); }
public IEnumerable <VulnerabilityDetail> FindVulnerabilties(SyntaxNode syntaxNode, string filePath, SemanticModel model = null, Solution solution = null) { List <VulnerabilityDetail> vulnerabilities = new List <VulnerabilityDetail>(); var classDeclarations = syntaxNode.DescendantNodesAndSelf().OfType <ClassDeclarationSyntax>(); foreach (var item in classDeclarations) { if (item.AttributeLists != null && item.AttributeLists.Count == 0) { continue; } foreach (var attributeList in item.AttributeLists) { foreach (var attribute in attributeList.Attributes) { //Export var exportSymbol = model.GetTypeSymbol(attribute); if (exportSymbol == null || !ExportTypes.Contains(exportSymbol.ToString())) { continue; } if (attribute.ArgumentList == null || attribute.ArgumentList.Arguments.Count == 0) { continue; } TypeOfExpressionSyntax typeOfExpression = null; if (attribute.ArgumentList.Arguments.Count == 1) { typeOfExpression = attribute.ArgumentList.Arguments[0].Expression as TypeOfExpressionSyntax; } else if (attribute.ArgumentList.Arguments.Count == 2) { int i = -1; foreach (var attributeArgument in attribute.ArgumentList.Arguments) { i++; if (i == 1 && attributeArgument.NameColon == null) { typeOfExpression = attributeArgument.Expression as TypeOfExpressionSyntax; break; } else if (attributeArgument.NameColon != null && attributeArgument.NameColon.Name.ToString() == "contractType") { typeOfExpression = attributeArgument.Expression as TypeOfExpressionSyntax; break; } } } if (typeOfExpression != null && ValidateType(model, typeOfExpression.Type, item)) { var action = exportSymbol.TypeKind == TypeKind.Interface ? ActionForInterface : ActionForClass; vulnerabilities.Add(VulnerabilityDetail.Create(filePath, attribute, Enums.ScannerType.ExportInterface, string.Format(message, action, exportSymbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat), typeOfExpression.Type.ToString()))); } } } } return(vulnerabilities); }
/// <summary> /// Rewrites the type inside typeof. /// </summary> /// <param name="node">ExpressionStatementSyntax</param> /// <returns>SyntaxNode</returns> private SyntaxNode RewriteStatement(TypeOfExpressionSyntax node) { // Gets containing method. var methoddecl = node.Ancestors().OfType <MethodDeclarationSyntax>().FirstOrDefault(); if (methoddecl == null) { return(node); } // Gets containing class. var classdecl = methoddecl.Ancestors().OfType <ClassDeclarationSyntax>().FirstOrDefault(); if (classdecl == null) { return(node); } // Gets containing namespace. var namespacedecl = classdecl.Ancestors().OfType <NamespaceDeclarationSyntax>().FirstOrDefault(); if (namespacedecl == null) { return(node); } var key = Tuple.Create(methoddecl.Identifier.ValueText, classdecl.Identifier.ValueText, namespacedecl.Name.ToString()); var rewrittenMethod = this.RewrittenQualifiedMethods.SingleOrDefault( val => val.Name.Equals(methoddecl.Identifier.ValueText) && val.MachineName.Equals(classdecl.Identifier.ValueText) && val.NamespaceName.Equals(namespacedecl.Name.ToString())); if (rewrittenMethod == null) { return(node); } this.CurrentAllQualifiedStateNames = rewrittenMethod.MachineQualifiedStateNames; this.CurrentQualifiedStateName = rewrittenMethod.QualifiedStateName; var typeUsed = node.Type.ToString(); var fullyQualifiedName = this.GetFullyQualifiedStateName(typeUsed); if (fullyQualifiedName == typeUsed) { return(node); } var tokenizedName = this.ToTokens(fullyQualifiedName); var rewritten = SyntaxFactory.ParseExpression("typeof(" + fullyQualifiedName + ")"); rewritten = rewritten.WithTriviaFrom(node); return(rewritten); }
private Doc PrintTypeOfExpressionSyntax(TypeOfExpressionSyntax node) { return(Concat( this.PrintSyntaxToken(node.Keyword), this.PrintSyntaxToken(node.OpenParenToken), this.Print(node.Type), this.PrintSyntaxToken(node.CloseParenToken) )); }
public static Doc Print(TypeOfExpressionSyntax node) { return(Doc.Concat( Token.Print(node.Keyword), Token.Print(node.OpenParenToken), Node.Print(node.Type), Token.Print(node.CloseParenToken) )); }
public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) { var ci = m_ClassInfoStack.Peek(); var oper = m_Model.GetOperation(node) as ITypeOfExpression; var type = oper.TypeOperand; OutputType(type, node, ci, "typeof"); }
private static async Task <Document> ApplyFixAsync(CodeFixContext context, TypeOfExpressionSyntax typeOfExpression, TypeSyntax containingType) { var document = context.Document; var syntaxRoot = await document.GetSyntaxRootAsync(context.CancellationToken) .ConfigureAwait(false); var updated = typeOfExpression.WithType(containingType); return(document.WithSyntaxRoot(syntaxRoot.ReplaceNode(typeOfExpression, updated))); }
static bool Matches(ExpressionSyntax member, ExpressionSyntax typeofExpr, out InvocationExpressionSyntax invoc, out TypeOfExpressionSyntax typeOf) { invoc = member as InvocationExpressionSyntax; typeOf = typeofExpr as TypeOfExpressionSyntax; if (invoc == null || typeOf == null) return false; var memberAccess = invoc.Expression as MemberAccessExpressionSyntax; return memberAccess != null && memberAccess.Name.Identifier.ValueText == "GetType"; }
public override Ust VisitTypeOfExpression(TypeOfExpressionSyntax node) { IdToken id = ConvertId(node.Keyword); TypeToken type = ConvertType(base.Visit(node.Type)); ArgsUst args = new ArgsUst(new[] { type }, type.TextSpan); var result = new InvocationExpression(id, args, node.GetTextSpan()); return(result); }
public override BoundNode VisitTypeOfExpression(TypeOfExpressionSyntax node) { TypeSymbol type = GetTypeSymbol(node.Type); if (!type.IsExtern) { throw new NotSupportedException("Cannot use typeof on user-defined types", node.GetLocation()); } return(new BoundConstantExpression(type.UdonType.SystemType, Context.GetTypeSymbol(typeof(Type)))); }
/// <summary> /// Rewrites the type inside typeof. /// </summary> /// <param name="node">TypeOfExpressionSyntax</param> /// <returns>SyntaxNode</returns> private SyntaxNode RewriteStatement(TypeOfExpressionSyntax node) { this.typeNameQualifier.InitializeForNode(node); var fullyQualifiedName = this.typeNameQualifier.GetQualifiedName(node.Type, out var succeeded); var rewritten = succeeded ? SyntaxFactory.ParseExpression("typeof(" + fullyQualifiedName + ")").WithTriviaFrom(node) : node; return(rewritten); }
private static bool TryGetTypeOfComparison(BinaryExpressionSyntax binary, out TypeOfExpressionSyntax typeofExpression, out ExpressionSyntax getTypeSide) { typeofExpression = binary.Left as TypeOfExpressionSyntax; getTypeSide = binary.Right; if (typeofExpression == null) { typeofExpression = binary.Right as TypeOfExpressionSyntax; getTypeSide = binary.Left; } return(typeofExpression != null); }
protected override IValue VisitTypeOfExpression(TypeOfExpressionSyntax node) { var g = ModelExtensions.GetTypeInfo(context.RoslynModel, node.Type); if (g.Type == null) { throw new NotSupportedException(); } Type t = context.Roslyn_ResolveType(g.Type); return(new TypeOfExpression(t)); }
public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) { if (!PreVisit(node)) { return; } node.Type?.Accept(this); base.VisitTypeOfExpression(node); PostVisit(node); }
SyntaxList <AttributeListSyntax> CreateAttributes() { TypeOfExpressionSyntax typeOfExpression = SF.TypeOfExpression(Symbols.GetNameSyntax(Type)); SyntaxToken fullyQualifiedNameLiteral = SF.Literal(Type.FullyQualifiedName); return(SF.List(new[] { SF.AttributeList(SF.SeparatedList(new[] { SF.Attribute( SF.ParseName("JsiiEnum"), SF.ParseAttributeArgumentList($"({typeOfExpression}, {fullyQualifiedNameLiteral})") ) })) })); }
protected override MemberDeclarationSyntax CreateType() { return(SF.InterfaceDeclaration ( CreateAttributes(), SF.TokenList(SF.Token(SyntaxKind.PublicKeyword)), Symbols.GetNameSyntaxToken(Type), null, CreateBaseList(), SF.List <TypeParameterConstraintClauseSyntax>(), SF.List(CreateMembers()) )); SyntaxList <AttributeListSyntax> CreateAttributes() { TypeOfExpressionSyntax typeOfExpression = SF.TypeOfExpression(Symbols.GetNameSyntax(Type)); SyntaxToken fullyQualifiedNameLiteral = SF.Literal(Type.FullyQualifiedName); return(SF.List(new[] { SF.AttributeList(SF.SeparatedList(new[] { SF.Attribute( SF.ParseName("JsiiInterface"), SF.ParseAttributeArgumentList($"({typeOfExpression}, {fullyQualifiedNameLiteral})") ) })) })); } BaseListSyntax CreateBaseList() { IEnumerable <BaseTypeSyntax> baseTypes = GetBaseTypes(); return(baseTypes?.Any() == true?SF.BaseList(SF.SeparatedList(baseTypes)) : null); IEnumerable <BaseTypeSyntax> GetBaseTypes() { foreach (TypeReference interfaceReference in Type.Interfaces ?? Enumerable.Empty <TypeReference>()) { Namespaces.Add(interfaceReference); yield return(SF.SimpleBaseType(Symbols.GetTypeSyntax(interfaceReference))); } } } IEnumerable <MemberDeclarationSyntax> CreateMembers() { return(CreateProperties().Concat(CreateMethods())); } }
public override LuaSyntaxNode VisitTypeOfExpression(TypeOfExpressionSyntax node) { var type = semanticModel_.GetTypeInfo(node.Type).Type; if (type != null && type.TypeKind == TypeKind.Enum) { AddExportEnum(type); var typeNameExpression = GetTypeShortName(type); return(new LuaInvocationExpressionSyntax(LuaIdentifierNameSyntax.TypeOf, typeNameExpression)); } var typeName = (LuaIdentifierNameSyntax)node.Type.Accept(this); return(new LuaInvocationExpressionSyntax(LuaIdentifierNameSyntax.TypeOf, typeName)); }
protected override MemberDeclarationSyntax CreateType() { return(SF.ClassDeclaration ( CreateAttributes(), SF.TokenList(SF.Token(SyntaxKind.InternalKeyword)), GetProxyTypeNameSyntax(), null, CreateBaseList(), SF.List <TypeParameterConstraintClauseSyntax>(), SF.List(CreateMembers()) )); SyntaxList <AttributeListSyntax> CreateAttributes() { TypeOfExpressionSyntax typeOfExpression = SF.TypeOfExpression(Symbols.GetNameSyntax(Type)); SyntaxToken fullyQualifiedNameLiteral = SF.Literal(Type.FullyQualifiedName); return(SF.List(new[] { SF.AttributeList(SF.SeparatedList(new[] { SF.Attribute( SF.ParseName("JsiiInterfaceProxy"), SF.ParseAttributeArgumentList($"({typeOfExpression}, {fullyQualifiedNameLiteral})") ) })) })); } BaseListSyntax CreateBaseList() { return(SF.BaseList(SF.SeparatedList(GetBaseTypes()))); IEnumerable <BaseTypeSyntax> GetBaseTypes() { yield return(SF.SimpleBaseType(SF.ParseTypeName("DeputyBase"))); Namespaces.Add(Type); yield return(SF.SimpleBaseType(Symbols.GetNameSyntax(Type, disambiguate: true))); } } IEnumerable <MemberDeclarationSyntax> CreateMembers() { return(CreateConstructors() .Concat(CreateProperties()) .Concat(CreateMethods())); } }
internal static TypeArguments?Find(InvocationExpressionSyntax invocation, SemanticModel semanticModel, CancellationToken cancellationToken) { if (invocation.ArgumentList is { } argumentList&& (TryGetTypeParameters(invocation, semanticModel, cancellationToken, out var symbol, out var parameters) || TryGetMethodParameters(invocation, semanticModel, cancellationToken, out symbol, out parameters))) { if (argumentList.Arguments.TrySingle(out var argument) && Array.TryGetValues(argument.Expression, semanticModel, cancellationToken, out var arrayExpressions)) { return(new TypeArguments(symbol, parameters, arrayExpressions)); } if (!IsUnknownArray()) { return(new TypeArguments(symbol, parameters, ArgumentsExpressions())); ImmutableArray <ExpressionSyntax> ArgumentsExpressions() { var builder = ImmutableArray.CreateBuilder <ExpressionSyntax>(argumentList.Arguments.Count); foreach (var arg in argumentList.Arguments) { builder.Add(arg.Expression); } return(builder.ToImmutable()); } } } return(null); bool IsUnknownArray() { if (argumentList.Arguments.TrySingle(out var single)) { return(single.Expression switch { TypeOfExpressionSyntax _ => false, _ => true, }); } return(false); }
private bool TryTyepofExpression(TypeOfExpressionSyntax typeOfExpression, IDom newItem, SemanticModel model, ref object value, ref LiteralKind literalKind, ref string constantIdentifier) { if (typeOfExpression == null) { return(false); } literalKind = LiteralKind.Type; value = Corporation .Create(typeOfExpression.Type, newItem, model) .FirstOrDefault() as IReferencedType; return(true); }
public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) { var oper = m_Model.GetOperation(node) as ITypeOfExpression; var type = oper.TypeOperand; if (null != type) { if (type.TypeKind == TypeKind.TypeParameter) { var typeParam = type as ITypeParameterSymbol; if (typeParam.TypeParameterKind == TypeParameterKind.Type) { m_UseExplicitTypeParam = true; } } } base.VisitTypeOfExpression(node); }
private bool TryGenerateTypeOfExpression(TypeOfExpressionSyntax typeOfExpression) { if (typeOfExpression.Type == null) { return(false); } var type = SemanticModel.GetTypeInfo(typeOfExpression.Type).Type; if (type == null) { return(false); } GenerateType(type); return(true); }
/// <summary> /// Rewrites the type inside typeof. /// </summary> private SyntaxNode RewriteStatement(TypeOfExpressionSyntax node) { this.typeNameQualifier.InitializeForNode(node); var fullyQualifiedName = this.typeNameQualifier.GetQualifiedName(node.Type, out var succeeded); if (!succeeded) { return(node); } var rewritten = SyntaxFactory.ParseExpression("typeof(" + fullyQualifiedName + ")"); this.Program.AddRewrittenTerm(node, rewritten.ToString()); rewritten = rewritten.WithTriviaFrom(node); return(rewritten); }
private bool IsTypeOfUnboundGenericType(SemanticModel semanticModel, TypeOfExpressionSyntax typeOfExpression) { if (typeOfExpression != null) { var type = semanticModel.GetTypeInfo(typeOfExpression.Type, _cancellationToken).Type as INamedTypeSymbol; // It's possible the immediate type might not be an unbound type, such as typeof(A<>.B). So walk through // parent types too while (type != null) { if (type.IsUnboundGenericType) { return(true); } type = type.ContainingType; } } return(false); }
public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) { UpdateSyntaxNode(node); System.Type capturedType = null; using (ExpressionCaptureScope typeCapture = new ExpressionCaptureScope(visitorContext, null)) { Visit(node.Type); capturedType = typeCapture.captureType; // Just throw a compile error for now instead of letting people get the typeof a type that won't exist in game if (capturedType == typeof(UdonSharpBehaviour) || capturedType.IsSubclassOf(typeof(UdonSharpBehaviour))) { throw new System.NotSupportedException("UdonSharp does not currently support using `typeof` on user defined types"); } } if (visitorContext.topCaptureScope != null) { visitorContext.topCaptureScope.SetToLocalSymbol(visitorContext.topTable.CreateConstSymbol(typeof(System.Type), capturedType)); } }
private bool IsTypeOfUnboundGenericType(SemanticModel semanticModel, TypeOfExpressionSyntax typeOfExpression) { if (typeOfExpression != null) { var type = semanticModel.GetTypeInfo(typeOfExpression.Type, _cancellationToken).Type as INamedTypeSymbol; // It's possible the immediate type might not be an unbound type, such as typeof(A<>.B). So walk through // parent types too while (type != null) { if (type.IsUnboundGenericType) { return true; } type = type.ContainingType; } } return false; }
private bool TryGenerateTypeOfExpression(TypeOfExpressionSyntax typeOfExpression) { if (typeOfExpression.Type == null) { return false; } var type = SemanticModel.GetTypeInfo(typeOfExpression.Type).Type; if (type == null) { return false; } GenerateType(type); return true; }
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitTypeOfExpression(TypeOfExpressionSyntax node) { this.OnNodeVisited(node, this.type.IsInstanceOfType(node)); base.VisitTypeOfExpression(node); }
public override void VisitTypeOfExpression(TypeOfExpressionSyntax node) { base.VisitTypeOfExpression(node); }
public TooltipInformation GetTypeOfTooltip (TypeOfExpressionSyntax typeOfExpression, ITypeSymbol resolveResult) { var result = new TooltipInformation (); if (resolveResult == null) { result.SignatureMarkup = MonoDevelop.Ide.TypeSystem.Ambience.EscapeText (typeOfExpression.Type.ToString ()); } else { result.SignatureMarkup = GetTypeMarkup (resolveResult, true); } return result; }
/// <summary> /// Rewrites the type inside typeof. /// </summary> /// <param name="node">ExpressionStatementSyntax</param> /// <returns>SyntaxNode</returns> private SyntaxNode RewriteStatement(TypeOfExpressionSyntax node) { // Gets containing method. var methoddecl = node.Ancestors().OfType<MethodDeclarationSyntax>().FirstOrDefault(); if (methoddecl == null) { return node; } // Gets containing class. var classdecl = methoddecl.Ancestors().OfType<ClassDeclarationSyntax>().FirstOrDefault(); if (classdecl == null) { return node; } // Gets containing namespace. var namespacedecl = classdecl.Ancestors().OfType<NamespaceDeclarationSyntax>().FirstOrDefault(); if (namespacedecl == null) { return node; } var key = Tuple.Create(methoddecl.Identifier.ValueText, classdecl.Identifier.ValueText, namespacedecl.Name.ToString()); var rewrittenMethod = this.RewrittenQualifiedMethods.SingleOrDefault( val => val.Name.Equals(methoddecl.Identifier.ValueText) && val.MachineName.Equals(classdecl.Identifier.ValueText) && val.NamespaceName.Equals(namespacedecl.Name.ToString())); if (rewrittenMethod == null) { return node; } this.CurrentAllQualifiedStateNames = rewrittenMethod.MachineQualifiedStateNames; this.CurrentQualifiedStateName = rewrittenMethod.QualifiedStateName; var typeUsed = node.Type.ToString(); var fullyQualifiedName = this.GetFullyQualifiedStateName(typeUsed); if (fullyQualifiedName == typeUsed) { return node; } var tokenizedName = this.ToTokens(fullyQualifiedName); var rewritten = SyntaxFactory.ParseExpression("typeof(" + fullyQualifiedName + ")"); rewritten = rewritten.WithTriviaFrom(node); return rewritten; }
/// <summary> /// /// </summary> /// <param name="node"></param> public override sealed void VisitTypeOfExpression(TypeOfExpressionSyntax node) { this.OnNodeVisited(node); if (!this.traverseRootOnly) base.VisitTypeOfExpression(node); }
private static bool TryGetTypeOfComparison(BinaryExpressionSyntax binary, out TypeOfExpressionSyntax typeofExpression, out ExpressionSyntax getTypeSide) { typeofExpression = binary.Left as TypeOfExpressionSyntax; getTypeSide = binary.Right; if (typeofExpression == null) { typeofExpression = binary.Right as TypeOfExpressionSyntax; getTypeSide = binary.Left; } return typeofExpression != null; }
public TypeOfExpressionTranslation(TypeOfExpressionSyntax syntax, SyntaxTranslation parent) : base(syntax, parent) { Type = syntax.Type.Get<TypeTranslation>(this); }
public override SyntaxNode VisitTypeOfExpression(TypeOfExpressionSyntax node) { this.AppendCompileIssue(node, IssueType.Error, IssueId.TypeOfNotSupport); return node; }
public override Expression VisitTypeOfExpression(TypeOfExpressionSyntax node) { // TODO really safe to strip the arguments? The arguments should only be Types. return(new GenericLiteralExpression()); }
public void VisitTypeOfExpression(TypeOfExpressionSyntax node) { if (node == null) throw new ArgumentNullException("node"); node.Validate(); ExpressionStart(node); _writer.WriteKeyword(PrinterKeyword.TypeOf); if (_writer.Configuration.Spaces.BeforeParentheses.TypeOfParentheses) _writer.WriteSpace(); _writer.WriteSyntax(Syntax.OpenParen); if (_writer.Configuration.Spaces.WithinParentheses.TypeOfParentheses) _writer.WriteSpace(); node.Type.Accept(this); if (_writer.Configuration.Spaces.WithinParentheses.TypeOfParentheses) _writer.WriteSpace(); _writer.WriteSyntax(Syntax.CloseParen); ExpressionEnd(node); }