Просмотр исходного кода

修复分析器跟sourcegenerator的问题

tanghai 1 год назад
Родитель
Сommit
f5e8b1219e

+ 4 - 4
Share/Analyzer/Analyzer/ClientClassInServerAnalyzer.cs

@@ -20,10 +20,10 @@ namespace ET.Analyzer
 
         private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
         {
-            if (!AnalyzerHelper.IsAssemblyNeedAnalyze(context.Compilation.AssemblyName, AnalyzeAssembly.ServerModelHotfix))
-            {
-                return;
-            }
+            //if (!AnalyzerHelper.IsAssemblyNeedAnalyze(context.Compilation.AssemblyName, AnalyzeAssembly.ServerModelHotfix))
+            //{
+            //    return;
+            //}
             
             var usingDirective = (UsingDirectiveSyntax)context.Node;
             var namespaceName = usingDirective.Name.ToString();

+ 20 - 31
Share/Analyzer/Config/AnalyzeAssembly.cs

@@ -4,47 +4,36 @@ namespace ET.Analyzer
 {
     public static class AnalyzeAssembly
     {
-        public const string DotNetCore = "Core";
-        public const string DotNetModel = "Model";
-        public const string DotNetHotfix = "Hotfix";
-
-        public const string UnityCore = "Unity.Core";
-        public const string UnityModel = "Unity.Model";
-        public const string UnityHotfix = "Unity.Hotfix";
-        public const string UnityModelView = "Unity.ModelView";
-        public const string UnityHotfixView = "Unity.HotfixView";
+        private const string Core = "ET.Core";
+        private const string Model = "ET.Model";
+        private const string Hotfix = "ET.Hotfix";
+        private const string ModelView = "ET.ModelView";
+        private const string HotfixView = "ET.HotfixView";
 
         public static readonly string[] AllHotfix =
-        {
-            DotNetHotfix, UnityHotfix, UnityHotfixView,
-        };
+        [
+            Hotfix, HotfixView
+        ];
 
         public static readonly string[] AllModel =
-        {
-            DotNetModel, UnityModel, UnityModelView
-        };
+        [
+            Model, ModelView
+        ];
 
         public static readonly string[] AllModelHotfix =
-        {
-            DotNetModel, DotNetHotfix, 
-            UnityModel, UnityHotfix, UnityModelView, UnityHotfixView, 
-        };
+        [
+            Model, Hotfix, ModelView, HotfixView
+        ];
         
         public static readonly string[] All =
-        {
-            DotNetCore, DotNetModel, DotNetHotfix, 
-            UnityCore, UnityModel, UnityHotfix, UnityModelView, UnityHotfixView, 
-        };
-
-        public static readonly string[] ServerModelHotfix =
-        {
-            DotNetModel,DotNetHotfix,
-        };
+        [
+            Core, Model, Hotfix, ModelView, HotfixView
+        ];
         
         public static readonly string[] AllLogicModel =
-        {
-            DotNetModel, UnityModel
-        };
+        [
+            Model
+        ];
     }
     
 }

+ 10 - 2
Share/SourceGenerator/Generator/ETEntitySerializeFormatterGenerator.cs

@@ -1,3 +1,5 @@
+#define DOTNET
+
 using System.Collections.Generic;
 using System.Text;
 using ET.Analyzer;
@@ -27,8 +29,14 @@ public class ETEntitySerializeFormatterGenerator : ISourceGenerator
         string typeHashCodeMapDeclaration = GenerateTypeHashCodeMapDeclaration(receiver);
         string serializeContent = GenerateSerializeContent(receiver);
         string deserializeContent = GenerateDeserializeContent(receiver);
-        string genericTypeParam = context.Compilation.AssemblyName == AnalyzeAssembly.DotNetModel? "<TBufferWriter>" : "";
-        string scopedCode = context.Compilation.AssemblyName == AnalyzeAssembly.DotNetModel? "scoped" : "";
+#if DOTNET
+        string genericTypeParam = "<TBufferWriter>";
+        string scopedCode = "scoped";
+#else
+        string genericTypeParam = "";
+        string scopedCode = "";
+#endif
+        
         string code = $$"""
 #nullable enable
 #pragma warning disable CS0108 // hides inherited member

+ 2 - 2
Unity/Assets/Scripts/Hotfix/ET.Hotfix.asmdef

@@ -6,8 +6,8 @@
         "Unity.Mathematics",
         "MemoryPack",
         "ET.Model",
-        "ET.Loader",
-        "ET.DotRecast"
+        "ET.Recast",
+        "ET.Loader"
     ],
     "includePlatforms": [
         "Editor"

+ 2 - 1
Unity/Assets/Scripts/Model/ET.Model.asmdef

@@ -4,7 +4,8 @@
     "references": [
         "ET.Core",
         "Unity.Mathematics",
-        "MemoryPack"
+        "MemoryPack",
+        "ET.Recast"
     ],
     "includePlatforms": [
         "Editor"

+ 8 - 3
Unity/Packages/com.et.aoi/Runtime~/Hotfix/Server/AOIEntitySystem.cs

@@ -5,7 +5,7 @@ namespace ET.Server
 {
     [EntitySystemOf(typeof(AOIEntity))]
     [FriendOf(typeof(Cell))]
-    public static partial class AOIEntitySystem
+    public static partial class AOIEntitySystem2
     {
         [EntitySystem]
         private static void Awake(this AOIEntity self, int distance, float3 pos)
@@ -13,7 +13,7 @@ namespace ET.Server
             self.ViewDistance = distance;
             self.Scene().GetComponent<AOIManagerComponent>().Add(self, pos.x, pos.z);
         }
-        
+
         [EntitySystem]
         private static void Destroy(this AOIEntity self)
         {
@@ -26,7 +26,12 @@ namespace ET.Server
             self.SubEnterCells.Clear();
             self.SubLeaveCells.Clear();
         }
-        
+    }
+
+    [FriendOf(typeof(Cell))]
+    [FriendOf(typeof(AOIEntity))]
+    public static partial class AOIEntitySystem
+    {
         // 获取在自己视野中的对象
         public static Dictionary<long, EntityRef<AOIEntity>> GetSeeUnits(this AOIEntity self)
         {

+ 1 - 1
Unity/Packages/com.et.core/DotNet~/ET.Core.csproj

@@ -43,7 +43,7 @@
 
     <ItemGroup>
         <PackageReference Include="CommandLineParser" Version="2.9.1" />
-        <PackageReference Include="MemoryPack" Version="1.10.0" />
+        <PackageReference Include="MemoryPack" Version="1.21.1" />
         <PackageReference Include="MongoDB.Driver" Version="2.17.1" />
         <PackageReference Include="NLog" Version="5.3.2" />
     </ItemGroup>

BIN
Unity/Packages/com.et.core/Plugins/ET.SourceGenerator.dll


+ 11 - 1
Unity/Packages/com.et.core/Plugins/ET.SourceGenerator.dll.meta

@@ -1,5 +1,7 @@
 fileFormatVersion: 2
-guid: f9c7e8183c5b945d3b3fb35bf4cfb20a
+guid: c7d66580a57c7824da2502ebcd0f33a2
+labels:
+- RoslynAnalyzer
 PluginImporter:
   externalObjects: {}
   serializedVersion: 2
@@ -16,11 +18,19 @@ PluginImporter:
     second:
       enabled: 0
       settings:
+        Exclude Android: 1
         Exclude Editor: 1
         Exclude Linux64: 1
         Exclude OSXUniversal: 1
         Exclude Win: 1
         Exclude Win64: 1
+  - first:
+      Android: Android
+    second:
+      enabled: 0
+      settings:
+        AndroidSharedLibraryType: Executable
+        CPU: ARMv7
   - first:
       Any: 
     second:

+ 2 - 2
Unity/Packages/com.et.loader/Editor/AssetPostProcessor/OnGenerateCSProjectProcessor.cs

@@ -89,8 +89,8 @@ namespace ET
             var rootNode = newDoc.GetElementsByTagName("Project")[0];
 
             {
-                string links = "<Compile Include=\"Library/PackageCache/com.et.*/Runtime~/" + dllName + "~/Share/**/*.cs\">\n            " +
-                        "<Link>$([System.String]::new(%(RecursiveDir)).Substring(7, $([System.String]::new(%(RecursiveDir)).Replace(\"Runtime~\", \"\")\"%(FileName)%(Extension)</Link>\n" +
+                string links = "<Compile Include=\"Library/PackageCache/com.et.*/Runtime~/" + dllName + "/Share/**/*.cs\">\n            " +
+                        "<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>\n" +
                         "</Compile>\n\n        " +
                         
                         "<Compile Include=\"Packages/com.et.*/Runtime~/" + dllName + "/Share/**/*.cs\">\n            " +

+ 0 - 0
Unity/Packages/com.et.recast/Runtime~/Model/ET.Recast.asmdef → Unity/Packages/com.et.recast/Runtime~/Hotfix/ET.Hotfix.asmdef


+ 5 - 0
Unity/Packages/com.et.recast/Runtime~/Model/ET.Model.asmdef

@@ -0,0 +1,5 @@
+{
+    "references": [
+        "ET.Recast"
+    ]
+}

+ 1 - 2
Unity/Packages/com.et.statesync/Runtime~/Hotfix/ET.Hotfix.asmdef

@@ -4,7 +4,6 @@
         "Unity.Mathematics",
         "ET.Loader",
         "MemoryPack",
-        "ET.Model",
-        "ET.DotRecast"
+        "ET.Model"
     ]
 }