`TextAlignmentExtensionsGenerator` shouldn't have `ISymbol`s in the pipeline
Youssef1313 opened this issue · 0 comments
Youssef1313 commented
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
Lines 22 to 61 in cf4b8e3
var userGeneratedClassesProvider = context.SyntaxProvider.CreateSyntaxProvider( | |
static (syntaxNode, cancellationToken) => syntaxNode is ClassDeclarationSyntax { BaseList: not null }, | |
static (context, cancellationToken) => | |
{ | |
var compilation = context.SemanticModel.Compilation; | |
var iTextAlignmentInterfaceSymbol = compilation.GetTypeByMetadataName(iTextAlignmentInterface); | |
if (iTextAlignmentInterfaceSymbol is null) | |
{ | |
throw new Exception("There's no .NET MAUI referenced in the project."); | |
} | |
var classSymbol = (INamedTypeSymbol?)context.SemanticModel.GetDeclaredSymbol(context.Node); | |
// If the ClassDlecarationSyntax doesn't implements those interfaces we just return null | |
if (classSymbol?.AllInterfaces.Contains(iTextAlignmentInterfaceSymbol, SymbolEqualityComparer.Default) is not true) | |
{ | |
return null; | |
} | |
return classSymbol; | |
}); | |
// Get Microsoft.Maui.Controls Symbols that implements the desired interfaces | |
var mauiControlsAssemblySymbolProvider = context.CompilationProvider.Select( | |
static (compilation, token) => | |
{ | |
var iTextAlignmentInterfaceSymbol = compilation.GetTypeByMetadataName(iTextAlignmentInterface); | |
if (iTextAlignmentInterfaceSymbol is null) | |
{ | |
throw new Exception("There's no .NET MAUI referenced in the project."); | |
} | |
var mauiAssembly = compilation.SourceModule.ReferencedAssemblySymbols.Single(q => q.Name == mauiControlsAssembly); | |
var symbols = GetMauiInterfaceImplementors(mauiAssembly, iTextAlignmentInterfaceSymbol).Where(static x => x is not null); | |
return symbols; | |
}); |
Expected Behavior
Better pipeline