Пример #1
0
 public static SyntaxNode CreateThrowNotImplementStatement(
     this ISyntaxFactoryService codeDefinitionFactory,
     Compilation compilation)
 {
     return(codeDefinitionFactory.CreateThrowStatement(
                codeDefinitionFactory.CreateObjectCreationExpression(
                    compilation.NotImplementedExceptionType(),
                    SpecializedCollections.EmptyList <SyntaxNode>())));
 }
Пример #2
0
        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);
        }
Пример #3
0
        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));
        }