Sfoglia il codice sorgente

* 修复ComponentOfAnalyzer Bug (#356)
1.修复当组件类型参数含有命名空间时无法分析的问题
2.当组件类型参数为泛型类型参数T时,忽略检查

tanghai 3 anni fa
parent
commit
fd67d775db

+ 6 - 6
Apps/Hotfix/Server/Robot/Case/RobotCase_FirstCase.cs

@@ -14,12 +14,12 @@ namespace ET.Server
 
             foreach (Scene robotScene in robots)
             {
-                //M2C_TestRobotCase response = await robotScene.GetComponent<Client.SessionComponent>().Session.Call(new C2M_TestRobotCase() {N = robotScene.Zone}) as M2C_TestRobotCase;
-                //if (response.N != robotScene.Zone)
-                //{
-                //    // 跟预期不一致就抛异常,外层会catch住在控制台上打印
-                //    throw new Exception($"robot case: {RobotCaseType.FirstCase} run fail!");
-                //}
+                M2C_TestRobotCase response = await robotScene.GetComponent<Client.SessionComponent>().Session.Call(new C2M_TestRobotCase() {N = robotScene.Zone}) as M2C_TestRobotCase;
+                if (response.N != robotScene.Zone)
+                {
+                    // 跟预期不一致就抛异常,外层会catch住在控制台上打印
+                    throw new Exception($"robot case: {RobotCaseType.FirstCase} run fail!");
+                }
             }
         }
     }

+ 6 - 1
Share/Analyzer/Analyzer/AddChildTypeAnalyzer.cs

@@ -114,7 +114,7 @@ namespace ET.Analyzer
 
                 TypeArgumentListSyntax? typeArgumentList = genericNameSyntax?.GetFirstChild<TypeArgumentListSyntax>();
 
-                IdentifierNameSyntax? childTypeSyntax = typeArgumentList?.GetFirstChild<IdentifierNameSyntax>();
+                var childTypeSyntax = typeArgumentList?.Arguments.First();
 
                 if (childTypeSyntax == null)
                 {
@@ -180,6 +180,11 @@ namespace ET.Analyzer
                 return;
             }
 
+            // 忽略 child类型为泛型类型
+            if (childTypeSymbol is ITypeParameterSymbol typeParameterSymbol)
+            {
+                return;
+            }
             
             // 判断child类型是否属于约束类型
             if (availableChildTypeSymbol?.ToString() == childTypeSymbol.ToString())

+ 8 - 2
Share/Analyzer/Analyzer/EntityComponentAnalyzer.cs

@@ -95,8 +95,8 @@ namespace ET.Analyzer
 
                 TypeArgumentListSyntax? typeArgumentList = genericNameSyntax?.GetFirstChild<TypeArgumentListSyntax>();
 
-                IdentifierNameSyntax? componentTypeSyntax = typeArgumentList?.GetFirstChild<IdentifierNameSyntax>();
-
+                var componentTypeSyntax = typeArgumentList?.Arguments.First();
+                
                 if (componentTypeSyntax == null)
                 {
                     Diagnostic diagnostic = Diagnostic.Create(Rule, memberAccessExpressionSyntax?.Name.Identifier.GetLocation());
@@ -161,6 +161,12 @@ namespace ET.Analyzer
                 return;
             }
 
+            // 忽略 component类型为泛型类型
+            if (componentTypeSymbol is ITypeParameterSymbol typeParameterSymbol)
+            {
+                return;
+            }
+            
             // 组件类型为Entity时 忽略检查
             if (componentTypeSymbol.ToString()== EntityType)
             {