Merge pull request #88495 from paulloz/dotnet/test-and-fix-exports-diagnostics
[.NET] Test and fix exports diagnostics
This commit is contained in:
@@ -3,6 +3,7 @@ namespace Godot.SourceGenerators
|
||||
public static class GodotClasses
|
||||
{
|
||||
public const string GodotObject = "Godot.GodotObject";
|
||||
public const string Node = "Godot.Node";
|
||||
public const string AssemblyHasScriptsAttr = "Godot.AssemblyHasScriptsAttribute";
|
||||
public const string ExportAttr = "Godot.ExportAttribute";
|
||||
public const string ExportCategoryAttr = "Godot.ExportCategoryAttribute";
|
||||
|
||||
+11
-9
@@ -66,11 +66,13 @@ namespace Godot.SourceGenerators
|
||||
)
|
||||
{
|
||||
INamespaceSymbol namespaceSymbol = symbol.ContainingNamespace;
|
||||
string classNs = namespaceSymbol != null && !namespaceSymbol.IsGlobalNamespace ?
|
||||
namespaceSymbol.FullQualifiedNameOmitGlobal() :
|
||||
string.Empty;
|
||||
string classNs = namespaceSymbol is { IsGlobalNamespace: false }
|
||||
? namespaceSymbol.FullQualifiedNameOmitGlobal()
|
||||
: string.Empty;
|
||||
bool hasNamespace = classNs.Length != 0;
|
||||
|
||||
bool isNode = symbol.InheritsFrom("GodotSharp", GodotClasses.Node);
|
||||
|
||||
bool isInnerClass = symbol.ContainingType != null;
|
||||
|
||||
string uniqueHint = symbol.FullQualifiedNameOmitGlobal().SanitizeQualifiedNameForUniqueHint()
|
||||
@@ -114,14 +116,14 @@ namespace Godot.SourceGenerators
|
||||
var members = symbol.GetMembers();
|
||||
|
||||
var exportedProperties = members
|
||||
.Where(s => !s.IsStatic && s.Kind == SymbolKind.Property)
|
||||
.Where(s => s.Kind == SymbolKind.Property)
|
||||
.Cast<IPropertySymbol>()
|
||||
.Where(s => s.GetAttributes()
|
||||
.Any(a => a.AttributeClass?.IsGodotExportAttribute() ?? false))
|
||||
.ToArray();
|
||||
|
||||
var exportedFields = members
|
||||
.Where(s => !s.IsStatic && s.Kind == SymbolKind.Field && !s.IsImplicitlyDeclared)
|
||||
.Where(s => s.Kind == SymbolKind.Field && !s.IsImplicitlyDeclared)
|
||||
.Cast<IFieldSymbol>()
|
||||
.Where(s => s.GetAttributes()
|
||||
.Any(a => a.AttributeClass?.IsGodotExportAttribute() ?? false))
|
||||
@@ -198,13 +200,13 @@ namespace Godot.SourceGenerators
|
||||
|
||||
if (marshalType == MarshalType.GodotObjectOrDerived)
|
||||
{
|
||||
if (!symbol.InheritsFrom("GodotSharp", "Godot.Node") &&
|
||||
propertyType.InheritsFrom("GodotSharp", "Godot.Node"))
|
||||
if (!isNode && propertyType.InheritsFrom("GodotSharp", GodotClasses.Node))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
Common.OnlyNodesShouldExportNodesRule,
|
||||
property.Locations.FirstLocationWithSourceTreeOrDefault()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,13 +319,13 @@ namespace Godot.SourceGenerators
|
||||
|
||||
if (marshalType == MarshalType.GodotObjectOrDerived)
|
||||
{
|
||||
if (!symbol.InheritsFrom("GodotSharp", "Godot.Node") &&
|
||||
fieldType.InheritsFrom("GodotSharp", "Godot.Node"))
|
||||
if (!isNode && fieldType.InheritsFrom("GodotSharp", GodotClasses.Node))
|
||||
{
|
||||
context.ReportDiagnostic(Diagnostic.Create(
|
||||
Common.OnlyNodesShouldExportNodesRule,
|
||||
field.Locations.FirstLocationWithSourceTreeOrDefault()
|
||||
));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user