public static ThrowStatementSyntax CreateArgumentNullException(string parameterName, bool includeSystem = true) { if (includeSystem) { return(SyntaxFactory.ThrowStatement( SyntaxObjectCreationExpressionFactory.Create("System", nameof(ArgumentNullException)) .WithArgumentList( SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument( SyntaxFactory.InvocationExpression(SyntaxFactory.IdentifierName("nameof")) .WithArgumentList( SyntaxArgumentListFactory.CreateWithOneItem(parameterName)))))))); } return(SyntaxFactory.ThrowStatement( SyntaxObjectCreationExpressionFactory.Create(nameof(ArgumentNullException)) .WithArgumentList( SyntaxFactory.ArgumentList( SyntaxFactory.SingletonSeparatedList( SyntaxFactory.Argument( SyntaxFactory.InvocationExpression(SyntaxFactory.IdentifierName("nameof")) .WithArgumentList( SyntaxArgumentListFactory.CreateWithOneItem(parameterName)))))))); }
public static ThrowStatementSyntax CreateNotImplementedException(bool includeSystem = true) { if (includeSystem) { return(SyntaxFactory.ThrowStatement( SyntaxObjectCreationExpressionFactory.Create("System", "NotImplementedException") .WithArgumentList(SyntaxFactory.ArgumentList()))); } return(SyntaxFactory.ThrowStatement( SyntaxObjectCreationExpressionFactory.Create("NotImplementedException") .WithArgumentList(SyntaxFactory.ArgumentList()))); }