예제 #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));
        }