diff --git a/src/ComputeSharp.SourceGenerators/AnalyzerReleases.Unshipped.md b/src/ComputeSharp.SourceGenerators/AnalyzerReleases.Unshipped.md index fa8b86cd..f9fd1d07 100644 --- a/src/ComputeSharp.SourceGenerators/AnalyzerReleases.Unshipped.md +++ b/src/ComputeSharp.SourceGenerators/AnalyzerReleases.Unshipped.md @@ -13,4 +13,25 @@ CMPS0005 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, CMPS0006 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) CMPS0007 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) CMPS0008 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) -CMPS0009 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) \ No newline at end of file +CMPS0009 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0010 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0011 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0012 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0013 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0014 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0015 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0016 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0017 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0018 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0019 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0020 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0021 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0022 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0023 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0024 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0025 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0026 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0027 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0028 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0029 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) +CMPS0030 | ComputeSharp.IComputeShader | Error | IComputeShaderSourceGenerator, [Documentation](https://github.com/Sergio0694/ComputeSharp) \ No newline at end of file diff --git a/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs b/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs index 676b4f4c..d5447612 100644 --- a/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs +++ b/src/ComputeSharp.SourceGenerators/Diagnostics/DiagnosticDescriptors.cs @@ -150,5 +150,281 @@ namespace ComputeSharp.SourceGenerators.Diagnostics isEnabledByDefault: true, description: "The WarpIds type can only be used within the main body of a compute shader.", helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for an invalid object creation expression. + /// + /// Format: "The type {0} cannot be created in a compute shader". + /// + /// + public static DiagnosticDescriptor InvalidObjectCreationExpression { get; } = new( + id: "CMPS0010", + title: "Invalid object creation expression", + messageFormat: "The type {0} cannot be created in a compute shader (only unmanaged types are supported)", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "Only unmanaged value type objects can be created in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for an anonymous object creation expression. + /// + public static DiagnosticDescriptor AnonymousObjectCreationExpression { get; } = new( + id: "CMPS0011", + title: "Anonymous object creation expression", + messageFormat: "An anonymous object cannot be created in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "An anonymous object cannot be created in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for an async modifier on a method or function. + /// + public static DiagnosticDescriptor AsyncModifierOnMethodOrFunction { get; } = new( + id: "CMPS0012", + title: "Async modifier on method or function", + messageFormat: "The async modifier cannot be used in methods or functions used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "The async modifier cannot be used in methods or functions used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for an await expression. + /// + public static DiagnosticDescriptor AwaitExpression { get; } = new( + id: "CMPS0013", + title: "Await expression", + messageFormat: "The await expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "The await expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a checked expression. + /// + public static DiagnosticDescriptor CheckedExpression { get; } = new( + id: "CMPS0014", + title: "Checked expression", + messageFormat: "A checked expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A checked expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a checked statement. + /// + public static DiagnosticDescriptor CheckedStatement { get; } = new( + id: "CMPS0015", + title: "Checked statement", + messageFormat: "A checked statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A checked statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a fixed statement. + /// + public static DiagnosticDescriptor FixedStatement { get; } = new( + id: "CMPS0016", + title: "Fixed statement", + messageFormat: "A fixed statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A fixed statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a foreach statement. + /// + public static DiagnosticDescriptor ForEachStatement { get; } = new( + id: "CMPS0017", + title: "Foreach statement", + messageFormat: "A foreach statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A foreach statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a lock statement. + /// + public static DiagnosticDescriptor LockStatement { get; } = new( + id: "CMPS0018", + title: "Foreach statement", + messageFormat: "A lock statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A lock statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a query statement. + /// + public static DiagnosticDescriptor QueryExpression { get; } = new( + id: "CMPS0019", + title: "Foreach statement", + messageFormat: "A LINQ query expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A LINQ query expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a range expression. + /// + public static DiagnosticDescriptor RangeExpression { get; } = new( + id: "CMPS0020", + title: "Range expression", + messageFormat: "A range expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A range expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a recursive pattern. + /// + public static DiagnosticDescriptor RecursivePattern { get; } = new( + id: "CMPS0021", + title: "Recursive pattern", + messageFormat: "A recursive pattern cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A recursive pattern cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a ref type. + /// + public static DiagnosticDescriptor RefType { get; } = new( + id: "CMPS0022", + title: "Ref type", + messageFormat: "A compute shader cannot have a ref type declaration", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A compute shader cannot have a ref type declaration.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a relational pattern. + /// + public static DiagnosticDescriptor RelationalPattern { get; } = new( + id: "CMPS0023", + title: "Relational pattern", + messageFormat: "A relational pattern cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A relational pattern cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a sizeof expression. + /// + public static DiagnosticDescriptor SizeOfExpression { get; } = new( + id: "CMPS0024", + title: "Sizeof expression", + messageFormat: "A sizeof expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A sizeof expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a stackalloc expression. + /// + public static DiagnosticDescriptor StackAllocArrayCreationExpression { get; } = new( + id: "CMPS0025", + title: "Stackalloc expression", + messageFormat: "A stackalloc expression cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A stackalloc expression cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a throw expression or statement. + /// + public static DiagnosticDescriptor ThrowExpressionOrStatement { get; } = new( + id: "CMPS0026", + title: "Throw expression or statement", + messageFormat: "Throw expressions and statements cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "Throw expressions and statements cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a try statement. + /// + public static DiagnosticDescriptor TryStatement { get; } = new( + id: "CMPS0027", + title: "Try statement", + messageFormat: "A try statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A try statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a tuple type. + /// + public static DiagnosticDescriptor TupleType { get; } = new( + id: "CMPS0028", + title: "Tuple type", + messageFormat: "A compute shader cannot have a tuple type declaration", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A compute shader cannot have a tuple type declaration.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a using statement or declaration. + /// + public static DiagnosticDescriptor UsingStatementOrDeclaration { get; } = new( + id: "CMPS0029", + title: "Using statement or declaration", + messageFormat: "Using statements and declarations cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "Using statements and declarations cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); + + /// + /// Gets a for a yield statement. + /// + public static DiagnosticDescriptor YieldStatement { get; } = new( + id: "CMPS0030", + title: "Yield statement", + messageFormat: "A yield statement cannot be used in a compute shader", + category: typeof(IComputeShader).FullName, + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + description: "A yield statement cannot be used in a compute shader.", + helpLinkUri: "https://github.com/Sergio0694/ComputeSharp"); } } diff --git a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs index 4e17c631..9a52a64a 100644 --- a/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs +++ b/src/ComputeSharp.SourceGenerators/SyntaxRewriters/ShaderSourceRewriter.cs @@ -154,6 +154,14 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters var updatedNode = (MethodDeclarationSyntax?)base.Visit(node); + + if (node!.Modifiers.Contains(Token(SyntaxKind.AsyncKeyword))) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.AsyncModifierOnMethodOrFunction, + node.GetLocation())); + } + if (updatedNode is not null) { var implicitBlock = Block(this.implicitVariables.Select(static v => LocalDeclarationStatement(v)).ToArray()); @@ -201,6 +209,13 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters { var updatedNode = ((LocalDeclarationStatementSyntax)base.VisitLocalDeclarationStatement(node)!); + if (this.semanticModel.GetOperation(node) is IOperation { Kind: OperationKind.UsingDeclaration }) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.UsingStatementOrDeclaration, + node.GetLocation())); + } + return updatedNode.ReplaceAndTrackType(updatedNode.Declaration.Type, node.Declaration.Type, this.semanticModel, this.discoveredTypes); } @@ -209,6 +224,14 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters { var updatedNode = (ObjectCreationExpressionSyntax)base.VisitObjectCreationExpression(node)!; + if (this.semanticModel.GetTypeInfo(node).Type is ITypeSymbol { IsUnmanagedType: false } type) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.InvalidObjectCreationExpression, + node.GetLocation(), + type)); + } + updatedNode = updatedNode.ReplaceAndTrackType(updatedNode.Type, node, this.semanticModel, this.discoveredTypes); // New objects use the default HLSL cast syntax, eg. (float4)0 @@ -220,6 +243,18 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters return InvocationExpression(updatedNode.Type, updatedNode.ArgumentList); } + /// + public override SyntaxNode? VisitAnonymousObjectCreationExpression(AnonymousObjectCreationExpressionSyntax node) + { + var updatedNode = (AnonymousObjectCreationExpressionSyntax)base.VisitAnonymousObjectCreationExpression(node)!; + + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.AnonymousObjectCreationExpression, + node.GetLocation())); + + return updatedNode; + } + /// public override SyntaxNode VisitImplicitObjectCreationExpression(ImplicitObjectCreationExpressionSyntax node) { @@ -318,6 +353,13 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters .WithAttributeLists(List()) .WithIdentifier(Identifier($"__{this.currentMethod!.Identifier.Text}__{node.Identifier.Text}")); + if (node.Modifiers.Contains(Token(SyntaxKind.AsyncKeyword))) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.AsyncModifierOnMethodOrFunction, + node.GetLocation())); + } + this.localFunctionDepth--; // HLSL doesn't support local functions, so we first process them as usual and then remove @@ -555,6 +597,206 @@ namespace ComputeSharp.SourceGenerators.SyntaxRewriters return updatedNode; } + /// + public override SyntaxNode? VisitAwaitExpression(AwaitExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.AwaitExpression, + node.GetLocation())); + + return base.VisitAwaitExpression(node); + } + + /// + public override SyntaxNode? VisitCheckedExpression(CheckedExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.CheckedExpression, + node.GetLocation())); + + return base.VisitCheckedExpression(node); + } + + /// + public override SyntaxNode? VisitCheckedStatement(CheckedStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.CheckedStatement, + node.GetLocation())); + + return base.VisitCheckedStatement(node); + } + + /// + public override SyntaxNode? VisitFixedStatement(FixedStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.FixedStatement, + node.GetLocation())); + + return base.VisitFixedStatement(node); + } + + /// + public override SyntaxNode? VisitForEachStatement(ForEachStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.ForEachStatement, + node.GetLocation())); + + return base.VisitForEachStatement(node); + } + + /// + public override SyntaxNode? VisitForEachVariableStatement(ForEachVariableStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.ForEachStatement, + node.GetLocation())); + + return base.VisitForEachVariableStatement(node); + } + + /// + public override SyntaxNode? VisitLockStatement(LockStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.LockStatement, + node.GetLocation())); + + return base.VisitLockStatement(node); + } + + /// + public override SyntaxNode? VisitQueryExpression(QueryExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.QueryExpression, + node.GetLocation())); + + return base.VisitQueryExpression(node); + } + + /// + public override SyntaxNode? VisitRangeExpression(RangeExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.RangeExpression, + node.GetLocation())); + + return base.VisitRangeExpression(node); + } + + /// + public override SyntaxNode? VisitRecursivePattern(RecursivePatternSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.RecursivePattern, + node.GetLocation())); + + return base.VisitRecursivePattern(node); + } + + /// + public override SyntaxNode? VisitRefType(RefTypeSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.RefType, + node.GetLocation())); + + return base.VisitRefType(node); + } + + /// + public override SyntaxNode? VisitRelationalPattern(RelationalPatternSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.RelationalPattern, + node.GetLocation())); + + return base.VisitRelationalPattern(node); + } + + /// + public override SyntaxNode? VisitSizeOfExpression(SizeOfExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.SizeOfExpression, + node.GetLocation())); + + return base.VisitSizeOfExpression(node); + } + + /// + public override SyntaxNode? VisitStackAllocArrayCreationExpression(StackAllocArrayCreationExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.StackAllocArrayCreationExpression, + node.GetLocation())); + + return base.VisitStackAllocArrayCreationExpression(node); + } + + /// + public override SyntaxNode? VisitThrowExpression(ThrowExpressionSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.ThrowExpressionOrStatement, + node.GetLocation())); + + return base.VisitThrowExpression(node); + } + + /// + public override SyntaxNode? VisitThrowStatement(ThrowStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.ThrowExpressionOrStatement, + node.GetLocation())); + + return base.VisitThrowStatement(node); + } + + /// + public override SyntaxNode? VisitTryStatement(TryStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.TryStatement, + node.GetLocation())); + + return base.VisitTryStatement(node); + } + + /// + public override SyntaxNode? VisitTupleType(TupleTypeSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.TupleType, + node.GetLocation())); + + return base.VisitTupleType(node); + } + + /// + public override SyntaxNode? VisitUsingStatement(UsingStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.UsingStatementOrDeclaration, + node.GetLocation())); + + return base.VisitUsingStatement(node); + } + + /// + public override SyntaxNode? VisitYieldStatement(YieldStatementSyntax node) + { + this.context.ReportDiagnostic(Diagnostic.Create( + DiagnosticDescriptors.YieldStatement, + node.GetLocation())); + + return base.VisitYieldStatement(node); + } + /// public override SyntaxToken VisitToken(SyntaxToken token) {