| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  | using System.Linq; | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  | using Microsoft.CodeAnalysis; | 
					
						
							|  |  |  | using Microsoft.CodeAnalysis.CSharp.Syntax; | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  | using Microsoft.CodeAnalysis.Diagnostics; | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Godot.SourceGenerators | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     public static class Common | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         public static void ReportNonPartialGodotScriptClass( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ClassDeclarationSyntax cds, INamedTypeSymbol symbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = | 
					
						
							|  |  |  |                 "Missing partial modifier on declaration of type '" + | 
					
						
							| 
									
										
										
										
											2022-12-07 16:16:51 +01:00
										 |  |  |                 $"{symbol.FullQualifiedNameOmitGlobal()}' which is a subclass of '{GodotClasses.GodotObject}'"; | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 16:16:51 +01:00
										 |  |  |             string description = $"{message}. Subclasses of '{GodotClasses.GodotObject}' " + | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  |                                  "must be declared with the partial modifier."; | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0001", | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 cds.GetLocation(), | 
					
						
							|  |  |  |                 cds.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportNonPartialGodotScriptOuterClass( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             TypeDeclarationSyntax outerTypeDeclSyntax | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var outerSymbol = context.Compilation | 
					
						
							|  |  |  |                 .GetSemanticModel(outerTypeDeclSyntax.SyntaxTree) | 
					
						
							|  |  |  |                 .GetDeclaredSymbol(outerTypeDeclSyntax); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string fullQualifiedName = outerSymbol is INamedTypeSymbol namedTypeSymbol ? | 
					
						
							| 
									
										
										
										
											2022-11-24 01:04:15 +01:00
										 |  |  |                 namedTypeSymbol.FullQualifiedNameOmitGlobal() : | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  |                 "type not found"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = | 
					
						
							|  |  |  |                 $"Missing partial modifier on declaration of type '{fullQualifiedName}', " + | 
					
						
							| 
									
										
										
										
											2022-12-07 16:16:51 +01:00
										 |  |  |                 $"which contains one or more subclasses of '{GodotClasses.GodotObject}'"; | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-07 16:16:51 +01:00
										 |  |  |             string description = $"{message}. Subclasses of '{GodotClasses.GodotObject}' and their " + | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  |                                  "containing types must be declared with the partial modifier."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0002", | 
					
						
							| 
									
										
										
										
											2021-12-28 23:25:16 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 outerTypeDeclSyntax.GetLocation(), | 
					
						
							|  |  |  |                 outerTypeDeclSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportExportedMemberIsStatic( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  |             bool isField = exportedMemberSymbol is IFieldSymbol; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"Attempted to export static {(isField ? "field" : "property")}: " + | 
					
						
							|  |  |  |                              $"'{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Only instance fields and properties can be exported." + | 
					
						
							|  |  |  |                                  " Remove the 'static' modifier or the '[Export]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0101", | 
					
						
							| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportExportedMemberTypeNotSupported( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  |             bool isField = exportedMemberSymbol is IFieldSymbol; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"The type of the exported {(isField ? "field" : "property")} " + | 
					
						
							|  |  |  |                              $"is not supported: '{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Use a supported type or remove the '[Export]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0102", | 
					
						
							| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportExportedMemberIsReadOnly( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  |             bool isField = exportedMemberSymbol is IFieldSymbol; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"The exported {(isField ? "field" : "property")} " + | 
					
						
							|  |  |  |                              $"is read-only: '{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = isField ? | 
					
						
							|  |  |  |                 $"{message}. Exported fields cannot be read-only." : | 
					
						
							|  |  |  |                 $"{message}. Exported properties must be writable."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0103", | 
					
						
							| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportExportedMemberIsWriteOnly( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"The exported property is write-only: '{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Exported properties must be readable."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0104", | 
					
						
							| 
									
										
										
										
											2022-02-27 21:57:30 +01:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 18:16:57 +02:00
										 |  |  |         public static void ReportExportedMemberIsIndexer( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"Attempted to export indexer property: " + | 
					
						
							|  |  |  |                              $"'{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Indexer properties can't be exported." + | 
					
						
							|  |  |  |                                  " Remove the '[Export]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0105", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-03-04 19:16:48 +01:00
										 |  |  |         public static void ReportExportedMemberIsExplicitInterfaceImplementation( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             ISymbol exportedMemberSymbol | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = exportedMemberSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = $"Attempted to export explicit interface property implementation: " + | 
					
						
							|  |  |  |                              $"'{exportedMemberSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Explicit interface implementations can't be exported." + | 
					
						
							|  |  |  |                                  " Remove the '[Export]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0106", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  |         public static void ReportSignalDelegateMissingSuffix( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             INamedTypeSymbol delegateSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = delegateSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = "The name of the delegate must end with 'EventHandler': " + | 
					
						
							|  |  |  |                              delegateSymbol.ToDisplayString() + | 
					
						
							|  |  |  |                              $". Did you mean '{delegateSymbol.Name}EventHandler'?"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Rename the delegate accordingly or remove the '[Signal]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0201", | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 06:21:27 +02:00
										 |  |  |         public static void ReportSignalParameterTypeNotSupported( | 
					
						
							|  |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             IParameterSymbol parameterSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = parameterSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = "The parameter of the delegate signature of the signal " + | 
					
						
							|  |  |  |                              $"is not supported: '{parameterSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Use supported types only or remove the '[Signal]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0202", | 
					
						
							| 
									
										
										
										
											2022-08-13 06:21:27 +02:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportSignalDelegateSignatureMustReturnVoid( | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  |             GeneratorExecutionContext context, | 
					
						
							|  |  |  |             INamedTypeSymbol delegateSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             var locations = delegateSymbol.Locations; | 
					
						
							|  |  |  |             var location = locations.FirstOrDefault(l => l.SourceTree != null) ?? locations.FirstOrDefault(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string message = "The delegate signature of the signal " + | 
					
						
							| 
									
										
										
										
											2022-08-13 06:21:27 +02:00
										 |  |  |                              $"must return void: '{delegateSymbol.ToDisplayString()}'"; | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-13 06:21:27 +02:00
										 |  |  |             string description = $"{message}. Return void or remove the '[Signal]' attribute."; | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  |                 new DiagnosticDescriptor(id: "GD0203", | 
					
						
							| 
									
										
										
										
											2022-07-28 17:41:47 +02:00
										 |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 location, | 
					
						
							|  |  |  |                 location?.SourceTree?.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2022-08-15 05:57:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         public static readonly DiagnosticDescriptor GenericTypeArgumentMustBeVariantRule = | 
					
						
							|  |  |  |             new DiagnosticDescriptor(id: "GD0301", | 
					
						
							|  |  |  |                 title: "The generic type argument must be a Variant compatible type", | 
					
						
							|  |  |  |                 messageFormat: "The generic type argument must be a Variant compatible type: {0}", | 
					
						
							|  |  |  |                 category: "Usage", | 
					
						
							|  |  |  |                 DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                 isEnabledByDefault: true, | 
					
						
							|  |  |  |                 "The generic type argument must be a Variant compatible type. Use a Variant compatible type as the generic type argument."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportGenericTypeArgumentMustBeVariant( | 
					
						
							|  |  |  |             SyntaxNodeAnalysisContext context, | 
					
						
							|  |  |  |             SyntaxNode typeArgumentSyntax, | 
					
						
							|  |  |  |             ISymbol typeArgumentSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = "The generic type argument " + | 
					
						
							|  |  |  |                             $"must be a Variant compatible type: '{typeArgumentSymbol.ToDisplayString()}'"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Use a Variant compatible type as the generic type argument."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0301", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 typeArgumentSyntax.GetLocation(), | 
					
						
							|  |  |  |                 typeArgumentSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static readonly DiagnosticDescriptor GenericTypeParameterMustBeVariantAnnotatedRule = | 
					
						
							|  |  |  |             new DiagnosticDescriptor(id: "GD0302", | 
					
						
							|  |  |  |                 title: "The generic type parameter must be annotated with the MustBeVariant attribute", | 
					
						
							|  |  |  |                 messageFormat: "The generic type argument must be a Variant type: {0}", | 
					
						
							|  |  |  |                 category: "Usage", | 
					
						
							|  |  |  |                 DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                 isEnabledByDefault: true, | 
					
						
							|  |  |  |                 "The generic type argument must be a Variant type. Use a Variant type as the generic type argument."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportGenericTypeParameterMustBeVariantAnnotated( | 
					
						
							|  |  |  |             SyntaxNodeAnalysisContext context, | 
					
						
							|  |  |  |             SyntaxNode typeArgumentSyntax, | 
					
						
							|  |  |  |             ISymbol typeArgumentSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = "The generic type parameter must be annotated with the MustBeVariant attribute"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Add the MustBeVariant attribute to the generic type parameter."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0302", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 typeArgumentSyntax.GetLocation(), | 
					
						
							|  |  |  |                 typeArgumentSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static readonly DiagnosticDescriptor TypeArgumentParentSymbolUnhandledRule = | 
					
						
							|  |  |  |             new DiagnosticDescriptor(id: "GD0303", | 
					
						
							|  |  |  |                 title: "The generic type parameter must be annotated with the MustBeVariant attribute", | 
					
						
							|  |  |  |                 messageFormat: "The generic type argument must be a Variant type: {0}", | 
					
						
							|  |  |  |                 category: "Usage", | 
					
						
							|  |  |  |                 DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                 isEnabledByDefault: true, | 
					
						
							|  |  |  |                 "The generic type argument must be a Variant type. Use a Variant type as the generic type argument."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportTypeArgumentParentSymbolUnhandled( | 
					
						
							|  |  |  |             SyntaxNodeAnalysisContext context, | 
					
						
							|  |  |  |             SyntaxNode typeArgumentSyntax, | 
					
						
							|  |  |  |             ISymbol parentSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = $"Symbol '{parentSymbol.ToDisplayString()}' parent of a type argument " + | 
					
						
							|  |  |  |                              "that must be Variant compatible was not handled."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Handle type arguments that are children of the unhandled symbol type."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0303", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 typeArgumentSyntax.GetLocation(), | 
					
						
							|  |  |  |                 typeArgumentSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-07-03 19:35:54 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         public static readonly DiagnosticDescriptor GlobalClassMustDeriveFromGodotObjectRule = | 
					
						
							|  |  |  |             new DiagnosticDescriptor(id: "GD0401", | 
					
						
							|  |  |  |                 title: "The class must derive from GodotObject or a derived class", | 
					
						
							|  |  |  |                 messageFormat: "The class '{0}' must derive from GodotObject or a derived class.", | 
					
						
							|  |  |  |                 category: "Usage", | 
					
						
							|  |  |  |                 DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                 isEnabledByDefault: true, | 
					
						
							|  |  |  |                 "The class must derive from GodotObject or a derived class. Change the base class or remove the '[GlobalClass]' attribute."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportGlobalClassMustDeriveFromGodotObject( | 
					
						
							|  |  |  |             SyntaxNodeAnalysisContext context, | 
					
						
							|  |  |  |             SyntaxNode classSyntax, | 
					
						
							|  |  |  |             ISymbol typeSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = $"The class '{typeSymbol.ToDisplayString()}' must derive from GodotObject or a derived class"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Change the base class or remove the '[GlobalClass]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0401", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 classSyntax.GetLocation(), | 
					
						
							|  |  |  |                 classSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static readonly DiagnosticDescriptor GlobalClassMustNotBeGenericRule = | 
					
						
							|  |  |  |             new DiagnosticDescriptor(id: "GD0402", | 
					
						
							|  |  |  |                 title: "The class must not contain generic arguments", | 
					
						
							|  |  |  |                 messageFormat: "The class '{0}' must not contain generic arguments", | 
					
						
							|  |  |  |                 category: "Usage", | 
					
						
							|  |  |  |                 DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                 isEnabledByDefault: true, | 
					
						
							|  |  |  |                 "The class must be a non-generic type. Remove the generic arguments or the '[GlobalClass]' attribute."); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         public static void ReportGlobalClassMustNotBeGeneric( | 
					
						
							|  |  |  |             SyntaxNodeAnalysisContext context, | 
					
						
							|  |  |  |             SyntaxNode classSyntax, | 
					
						
							|  |  |  |             ISymbol typeSymbol) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             string message = $"The class '{typeSymbol.ToDisplayString()}' must not contain generic arguments"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             string description = $"{message}. Remove the generic arguments or the '[GlobalClass]' attribute."; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             context.ReportDiagnostic(Diagnostic.Create( | 
					
						
							|  |  |  |                 new DiagnosticDescriptor(id: "GD0402", | 
					
						
							|  |  |  |                     title: message, | 
					
						
							|  |  |  |                     messageFormat: message, | 
					
						
							|  |  |  |                     category: "Usage", | 
					
						
							|  |  |  |                     DiagnosticSeverity.Error, | 
					
						
							|  |  |  |                     isEnabledByDefault: true, | 
					
						
							|  |  |  |                     description), | 
					
						
							|  |  |  |                 classSyntax.GetLocation(), | 
					
						
							|  |  |  |                 classSyntax.SyntaxTree.FilePath)); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2021-03-06 00:12:42 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | } |