Skip to content

Commit 7b78cc9

Browse files
committed
ge
1 parent cd7c130 commit 7b78cc9

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

src/ConsoleAppFramework/ConsoleAppGenerator.cs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Microsoft.CodeAnalysis.CSharp.Syntax;
44
using System.Collections.Immutable;
55
using System.Reflection;
6+
using System.Security.Cryptography.X509Certificates;
67
using System.Xml.Linq;
78

89
namespace ConsoleAppFramework;
@@ -604,10 +605,6 @@ static void EmitConsoleAppBuilder(SourceProductionContext sourceProductionContex
604605
{
605606
if (generatorSyntaxContexts.Length == 0) return;
606607

607-
// var model = generatorSyntaxContexts[0].Model;
608-
609-
// var wellKnownTypes = new WellKnownTypes(model.Compilation);
610-
611608
// validation, invoke in loop is not allowed.
612609
foreach (var item in generatorSyntaxContexts)
613610
{
@@ -893,6 +890,54 @@ public bool Equals(BuilderContext other)
893890

894891
bool EqualsAddClass(BuilderContext other)
895892
{
893+
// Add<T>
894+
var genericName = (node.Expression as MemberAccessExpressionSyntax)?.Name as GenericNameSyntax;
895+
var genericType = genericName!.TypeArgumentList.Arguments[0];
896+
897+
// Add<T>(string commandPath)
898+
string? commandPath = null;
899+
var args = node.ArgumentList.Arguments;
900+
if (node.ArgumentList.Arguments.Count == 1)
901+
{
902+
var commandName = args[0];
903+
if (!commandName.Expression.IsKind(SyntaxKind.StringLiteralExpression))
904+
{
905+
//context.ReportDiagnostic(DiagnosticDescriptors.AddCommandMustBeStringLiteral, commandName.GetLocation());
906+
//return [];
907+
return false;
908+
}
909+
910+
commandPath = (commandName.Expression as LiteralExpressionSyntax)!.Token.ValueText;
911+
}
912+
913+
// T
914+
var type = model.GetTypeInfo(genericType).Type!;
915+
916+
917+
// Type:Attributes
918+
// Type:Interface
919+
920+
// Public Constructor
921+
922+
// Public Methods
923+
924+
var publicMethods = type.GetMembers()
925+
.Where(x => x.DeclaredAccessibility == Accessibility.Public)
926+
.OfType<IMethodSymbol>()
927+
.Where(x => x.DeclaredAccessibility == Accessibility.Public && !x.IsStatic)
928+
.Where(x => x.MethodKind == Microsoft.CodeAnalysis.MethodKind.Ordinary)
929+
.Where(x => !(x.Name is "Dispose" or "DisposeAsync" or "GetHashCode" or "Equals" or "ToString"))
930+
.ToArray();
931+
932+
933+
934+
935+
936+
937+
938+
939+
940+
896941
return true; // TODO:final
897942
}
898943

0 commit comments

Comments
 (0)