1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-18 14:21:41 +00:00

Merge pull request #72057 from raulsntos/dotnet/fix-must-be-variant

C#: Annotate API with `[MustBeVariant]`
This commit is contained in:
Rémi Verschelde
2023-01-26 23:00:30 +01:00
4 changed files with 51 additions and 27 deletions

View File

@@ -26,6 +26,10 @@ namespace Godot.SourceGenerators
private void AnalyzeNode(SyntaxNodeAnalysisContext context)
{
// Ignore syntax inside comments
if (IsInsideDocumentation(context.Node))
return;
var typeArgListSyntax = (TypeArgumentListSyntax)context.Node;
// Method invocation or variable declaration that contained the type arguments
@@ -73,6 +77,26 @@ namespace Godot.SourceGenerators
}
}
/// <summary>
/// Check if the syntax node is inside a documentation syntax.
/// </summary>
/// <param name="syntax">Syntax node to check.</param>
/// <returns><see langword="true"/> if the syntax node is inside a documentation syntax.</returns>
private bool IsInsideDocumentation(SyntaxNode? syntax)
{
while (syntax != null)
{
if (syntax is DocumentationCommentTriviaSyntax)
{
return true;
}
syntax = syntax.Parent;
}
return false;
}
/// <summary>
/// Check if the given type argument is being used in a type parameter that contains
/// the <c>MustBeVariantAttribute</c>; otherwise, we ignore the attribute.