C#: Fix to allow usage of [MustBeVariant] in generic typed attributes
This commit is contained in:
parent
0bcc0e92b3
commit
692412562d
6 changed files with 1093 additions and 9 deletions
|
|
@ -109,11 +109,19 @@ namespace Godot.SourceGenerators
|
|||
/// <returns><see langword="true"/> if the type must be variant and must be analyzed.</returns>
|
||||
private bool ShouldCheckTypeArgument(SyntaxNodeAnalysisContext context, SyntaxNode parentSyntax, ISymbol parentSymbol, TypeSyntax typeArgumentSyntax, ITypeSymbol typeArgumentSymbol, int typeArgumentIndex)
|
||||
{
|
||||
var typeParamSymbol = parentSymbol switch
|
||||
ITypeParameterSymbol? typeParamSymbol = parentSymbol switch
|
||||
{
|
||||
IMethodSymbol methodSymbol => methodSymbol.TypeParameters[typeArgumentIndex],
|
||||
INamedTypeSymbol typeSymbol => typeSymbol.TypeParameters[typeArgumentIndex],
|
||||
_ => null,
|
||||
IMethodSymbol methodSymbol when parentSyntax.Parent is AttributeSyntax &&
|
||||
methodSymbol.ContainingType.TypeParameters.Length > 0
|
||||
=> methodSymbol.ContainingType.TypeParameters[typeArgumentIndex],
|
||||
|
||||
IMethodSymbol { TypeParameters.Length: > 0 } methodSymbol
|
||||
=> methodSymbol.TypeParameters[typeArgumentIndex],
|
||||
|
||||
INamedTypeSymbol { TypeParameters.Length: > 0 } typeSymbol
|
||||
=> typeSymbol.TypeParameters[typeArgumentIndex],
|
||||
_
|
||||
=> null
|
||||
};
|
||||
|
||||
if (typeParamSymbol == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue