Browse Source

兼容FISLib

felix 1 year ago
parent
commit
4e89a8be8a
4 changed files with 17 additions and 6 deletions
  1. BIN
      FISLib.dll
  2. 5 2
      Helper/CodeGeneratorForFISLib.cs
  3. 5 2
      Helper/CodeGeneratorForWing.cs
  4. 7 2
      Map/ServiceMap.cs

BIN
FISLib.dll


+ 5 - 2
Helper/CodeGeneratorForFISLib.cs

@@ -51,8 +51,11 @@ namespace FlutterCodeGenerator.Helper
             foreach (var interfaceType in interfaceTypes)
             {
                 var sericeName = interfaceType.Name[1..];
-                var serviceMap = new ServiceMap(interfaceType);
-                _serviceMapDictionary.Add(LetterConverterHelper.FirstCharToLower(sericeName), serviceMap);
+                var serviceMap = new ServiceMap(interfaceType,true);
+                if(serviceMap.HasMethod)
+                {
+                    _serviceMapDictionary.Add(LetterConverterHelper.FirstCharToLower(sericeName), serviceMap);
+                }
             }
         }
 

+ 5 - 2
Helper/CodeGeneratorForWing.cs

@@ -64,8 +64,11 @@ namespace FlutterCodeGenerator.Helper
             foreach (var interfaceType in interfaceTypes)
             {
                 var sericeName = interfaceType.Name[1..];
-                var serviceMap = new ServiceMap(interfaceType);
-                _serviceMapDictionary.Add(LetterConverterHelper.FirstCharToLower(sericeName), serviceMap);
+                var serviceMap = new ServiceMap(interfaceType, false);
+                if (serviceMap.HasMethod)
+                {
+                    _serviceMapDictionary.Add(LetterConverterHelper.FirstCharToLower(sericeName), serviceMap);
+                }
             }
             var otherServiceMap = new OtherServiceMap(restNeedGeneratedTypes);
             _serviceMapDictionary.Add("otherService", otherServiceMap);

+ 7 - 2
Map/ServiceMap.cs

@@ -19,7 +19,9 @@ namespace FlutterCodeGenerator.Map
 
         public List<ComplexModelType> UsedComplexModelTypeList { get; }
 
-        public ServiceMap(Type type)
+        public bool HasMethod => _methodMapList.Count > 0;
+
+        public ServiceMap(Type type, bool isFISLib)
         {
             ServiceName = type.Name[1..];
             UsedComplexModelTypeList = new List<ComplexModelType>();
@@ -34,7 +36,10 @@ namespace FlutterCodeGenerator.Map
                 eventMethodList.Add(eventType.AddMethod);
             }
             methodsList = methodsList.Where(x => !eventMethodList.Contains(x)).ToList();//将Event的Method屏蔽
-            methodsList = methodsList.Where(x => !x.CustomAttributes.Any(y => y.AttributeType.FullName == "FISLib.FISAttribute" && y.ConstructorArguments.FirstOrDefault().ArgumentType == typeof(string) && (string)y.ConstructorArguments.FirstOrDefault().Value == "FlutterIgnored")).ToList();//将FISAttribue为FlutterIgnore的屏蔽
+            if (isFISLib)
+            {
+                methodsList = methodsList.Where(x => x.CustomAttributes.Any(y => y.AttributeType.FullName == "FISLib.FISAttribute" && y.ConstructorArguments.FirstOrDefault().ArgumentType == typeof(string) && (string)y.ConstructorArguments.FirstOrDefault().Value == "ForFlutter")).ToList();
+            }
             foreach (var method in methodsList)
             {
                 var methodMap = new MethodMap(method);