|
3 | 3 | using Microsoft.CodeAnalysis.CSharp.Syntax; |
4 | 4 | using System.Collections.Immutable; |
5 | 5 | using System.Reflection; |
| 6 | +using System.Security.Cryptography.X509Certificates; |
6 | 7 | using System.Xml.Linq; |
7 | 8 |
|
8 | 9 | namespace ConsoleAppFramework; |
@@ -604,10 +605,6 @@ static void EmitConsoleAppBuilder(SourceProductionContext sourceProductionContex |
604 | 605 | { |
605 | 606 | if (generatorSyntaxContexts.Length == 0) return; |
606 | 607 |
|
607 | | - // var model = generatorSyntaxContexts[0].Model; |
608 | | - |
609 | | - // var wellKnownTypes = new WellKnownTypes(model.Compilation); |
610 | | - |
611 | 608 | // validation, invoke in loop is not allowed. |
612 | 609 | foreach (var item in generatorSyntaxContexts) |
613 | 610 | { |
@@ -893,6 +890,54 @@ public bool Equals(BuilderContext other) |
893 | 890 |
|
894 | 891 | bool EqualsAddClass(BuilderContext other) |
895 | 892 | { |
| 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 | + |
896 | 941 | return true; // TODO:final |
897 | 942 | } |
898 | 943 |
|
|
0 commit comments