Finalizing Syntax Model for Out Variable Declarations.
Adjusted behavior of CSharpSyntaxGenerator and added some explicitly written code to achieve the following for the Syntax Model: - Factory static ArgumentSyntax Argument(NameColonSyntax nameColon, SyntaxToken refOrOutKeyword, CSharpSyntaxNode expressionOrDeclaration) will be internal. - Factory static ArgumentSyntax Argument(CSharpSyntaxNode expressionOrDeclaration) will be internal. - There will be the following public factories: public static ArgumentSyntax Argument(NameColonSyntax nameColon, SyntaxToken refOrOutKeyword, ExpressionSyntax expression) public static ArgumentSyntax Argument(ExpressionSyntax expression) public static ArgumentSyntax Argument(NameColonSyntax nameColon, SyntaxToken outKeyword, VariableDeclarationSyntax declaration) public static ArgumentSyntax Argument(SyntaxToken outKeyword, VariableDeclarationSyntax declaration) - Update method ArgumentSyntax Update(NameColonSyntax nameColon, SyntaxToken refOrOutKeyword, CSharpSyntaxNode expressionOrDeclaration) will be internal. - There will be the following public update methods: public ArgumentSyntax Update(NameColonSyntax nameColon, SyntaxToken refOrOutKeyword, ExpressionSyntax expression) public ArgumentSyntax Update(NameColonSyntax nameColon, SyntaxToken outKeyword, VariableDeclarationSyntax declaration) - With method ArgumentSyntax WithExpressionOrDeclaration(CSharpSyntaxNode expressionOrDeclaration) will be internal. - There will be the following public With methods: public ArgumentSyntax WithNameColon(NameColonSyntax nameColon) public ArgumentSyntax WithRefOrOutKeyword(SyntaxToken refOrOutKeyword) public ArgumentSyntax WithExpression(ExpressionSyntax expression) public ArgumentSyntax WithDeclaration(VariableDeclarationSyntax declaration) - Property CSharpSyntaxNode ExpressionOrDeclaration will be internal. - Instead there will be the following public properties (one of them will return null depending on the value of ExpressionOrDeclaration): public ExpressionSyntax Expression public VariableDeclarationSyntax Declaration - Factory, Update and With methods should provide stronger validation: a) ExpressionOrDeclaration must either be an ExpressionSyntax, or a VariableDeclarationSyntax; b) Declaration must be combined with out keyword; c) Declaration must have single VariableDeclarator; d) VariableDeclarator must have null ArgumentList and null Initializer.
Showing
想要评论请 注册 或 登录