public static SyntaxNode CreateThrowNotImplementStatement( this ISyntaxFactoryService codeDefinitionFactory, Compilation compilation) { return(codeDefinitionFactory.CreateThrowStatement( codeDefinitionFactory.CreateObjectCreationExpression( compilation.NotImplementedExceptionType(), SpecializedCollections.EmptyList <SyntaxNode>()))); }
public static SyntaxNode GenerateThrowStatement( ISyntaxFactoryService factory, SemanticDocument document, string exceptionMetadataName, CancellationToken cancellationToken) { var compilation = document.SemanticModel.Compilation; var exceptionType = compilation.GetTypeByMetadataName(exceptionMetadataName); // If we can't find the Exception, we obviously can't generate anything. if (exceptionType == null) { return null; } var exceptionCreationExpression = factory.CreateObjectCreationExpression( exceptionType, SpecializedCollections.EmptyList<SyntaxNode>()); return factory.CreateThrowStatement(exceptionCreationExpression); }
public static SyntaxNode GenerateThrowStatement( ISyntaxFactoryService factory, SemanticDocument document, string exceptionMetadataName, CancellationToken cancellationToken) { var compilation = document.SemanticModel.Compilation; var exceptionType = compilation.GetTypeByMetadataName(exceptionMetadataName); // If we can't find the Exception, we obviously can't generate anything. if (exceptionType == null) { return(null); } var exceptionCreationExpression = factory.CreateObjectCreationExpression( exceptionType, SpecializedCollections.EmptyList <SyntaxNode>()); return(factory.CreateThrowStatement(exceptionCreationExpression)); }