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

导表把json转成protobuf格式成功

tanghai 5 лет назад
Родитель
Сommit
fff1281a42

+ 1 - 1
.gitignore

@@ -49,4 +49,4 @@ Server/.DS_Store
 .objs/
 /Unity/.gradle
 /*.user
-ToolApp/
+/ToolApp

BIN
Excel/UnitConfig.xlsx


+ 3 - 2
Generate/Client/Code/Config/StartMachineConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartMachineConfigCategory : ProtoObject
     {
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartMachineConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Client/Code/Config/StartProcessConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartProcessConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartProcessConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartProcessConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Client/Code/Config/StartSceneConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartSceneConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartSceneConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartSceneConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Client/Code/Config/StartZoneConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartZoneConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartZoneConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartZoneConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Client/Code/Config/UnitConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class UnitConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (UnitConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class UnitConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 1 - 1
Generate/Client/Json/UnitConfig.txt

@@ -1,3 +1,3 @@
 {"list":[
-{"_id":1001,"Name":"测试说明","Desc":"米克尔","Position":带有强力攻击技能,"Height":1,"Weight":178},
+{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178},
 ]}

+ 3 - 2
Generate/Server/Code/Config/StartMachineConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartMachineConfigCategory : ProtoObject
     {
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartMachineConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Server/Code/Config/StartProcessConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartProcessConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartProcessConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartProcessConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Server/Code/Config/StartSceneConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartSceneConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartSceneConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartSceneConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Server/Code/Config/StartZoneConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class StartZoneConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (StartZoneConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class StartZoneConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 4 - 3
Generate/Server/Code/Config/UnitConfig.cs

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class UnitConfigCategory : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach (UnitConfig config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class UnitConfig: IConfig
 	{
 		[ProtoMember(1, IsRequired  = true)]

+ 1 - 1
Generate/Server/Json/UnitConfig.txt

@@ -1,3 +1,3 @@
 {"list":[
-{"_id":1001,"Name":"测试说明","Desc":"米克尔","Position":带有强力攻击技能,"Height":1,"Weight":178},
+{"_id":1001,"Name":"米克尔","Desc":"带有强力攻击技能","Position":1,"Height":178},
 ]}

+ 1 - 0
Server/App/Server.App.csproj

@@ -9,6 +9,7 @@
 
   <PropertyGroup>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

+ 1 - 0
Server/Hotfix/Server.Hotfix.csproj

@@ -6,6 +6,7 @@
   </PropertyGroup>
   <PropertyGroup>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DefineConstants>TRACE2_0;SERVER;NOT_CLIENT</DefineConstants>

+ 1 - 0
Server/Model/Server.Model.csproj

@@ -6,6 +6,7 @@
   </PropertyGroup>
   <PropertyGroup>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+    <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DefineConstants>TRACE2_0;SERVER;NOT_CLIENT</DefineConstants>

+ 18 - 1
Tools/ExcelExporter/ExcelExporter.csproj

@@ -20,12 +20,29 @@
     
     <ItemGroup>
       <PackageReference Include="EPPlus" Version="5.5.2" />
+      <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="2.9.0" />
     </ItemGroup>
     
     <ItemGroup>
       <None Update="Template.txt">
-        <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
       </None>
     </ItemGroup>
+    
+    <ItemGroup>
+      <ProjectReference Include="..\..\Server\ThirdParty\Server.ThirdParty.csproj" />
+    </ItemGroup>
+    
+    <ItemGroup>
+      <Compile Include="..\..\Unity\Assets\Model\Core\Object\BaseAttribute.cs">
+        <Link>BaseAttribute.cs</Link>
+      </Compile>
+      <Compile Include="..\..\Unity\Assets\Model\Module\Config\ConfigAttribute.cs">
+        <Link>ConfigAttribute.cs</Link>
+      </Compile>
+      <Compile Include="..\..\Unity\Assets\Model\Module\Config\IConfig.cs">
+        <Link>IConfig.cs</Link>
+      </Compile>
+    </ItemGroup>
 
 </Project>

+ 139 - 21
Tools/ExcelExporter/Program.cs

@@ -1,8 +1,17 @@
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.IO;
+using System.Reflection;
 using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.Emit;
+using MongoDB.Bson.Serialization;
+using MongoDB.Bson.Serialization.Attributes;
 using OfficeOpenXml;
+using ProtoBuf;
+using LicenseContext = OfficeOpenXml.LicenseContext;
 
 namespace ET
 {
@@ -38,25 +47,39 @@ namespace ET
         
         private const string jsonDir = "../../Generate/{0}/Json";
         
+        private const string protoDir = "../../Generate/{0}/Proto";
+        
         static void Main(string[] args)
         {
-            template = File.ReadAllText("Template.txt");
-            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
-            foreach (string path in Directory.GetFiles(excelDir, "*.xlsx"))
+            try
             {
-                using Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
-                using ExcelPackage p = new ExcelPackage(stream);
-                string name = Path.GetFileNameWithoutExtension(path);
+                template = File.ReadAllText("Template.txt");
+                ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
+                foreach (string path in Directory.GetFiles(excelDir, "*.xlsx"))
+                {
+                    using Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
+                    using ExcelPackage p = new ExcelPackage(stream);
+                    string name = Path.GetFileNameWithoutExtension(path);
                 
-                ExportExcelClass(p, name, ConfigType.Client);
-                ExportExcelClass(p, name, ConfigType.Server);
+                    ExportExcelClass(p, name, ConfigType.Client);
+                    ExportExcelClass(p, name, ConfigType.Server);
                 
-                ExportExcelJson(p, name, ConfigType.Client);
-                ExportExcelJson(p, name, ConfigType.Server);
+                    ExportExcelJson(p, name, ConfigType.Client);
+                    ExportExcelJson(p, name, ConfigType.Server);
+                }
+            
+                ExportExcelProtobuf(ConfigType.Client);
+                ExportExcelProtobuf(ConfigType.Server);
+                
+                Console.WriteLine("导表成功!");
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
             }
         }
 
-        #region 导出class
+#region 导出class
         static void ExportExcelClass(ExcelPackage p, string name, ConfigType configType)
         {
             List<HeadInfo> classField = new List<HeadInfo>();
@@ -92,7 +115,12 @@ namespace ET
 
         static void ExportClass(string protoName, List<HeadInfo> classField, ConfigType configType)
         {
-            string exportPath = Path.Combine(string.Format(classDir, configType.ToString()), $"{protoName}.cs");
+            string dir = string.Format(classDir, configType.ToString());
+            if (!Directory.Exists(dir))
+            {
+                Directory.CreateDirectory(dir);
+            }
+            string exportPath = Path.Combine(dir, $"{protoName}.cs");
             
             using FileStream txt = new FileStream(exportPath, FileMode.Create);
             using StreamWriter sw = new StreamWriter(txt);
@@ -111,8 +139,9 @@ namespace ET
             string content = template.Replace("(ConfigName)", protoName).Replace(("(Fields)"), sb.ToString());
             sw.Write(content);
         }
-        #endregion
-        
+#endregion
+
+#region 导出json
         static void ExportExcelJson(ExcelPackage p, string name, ConfigType configType)
         {
             StringBuilder sb = new StringBuilder();
@@ -123,7 +152,13 @@ namespace ET
             }
             sb.AppendLine("]}");
             
-            string jsonPath = Path.Combine(string.Format(jsonDir, configType.ToString()), $"{name}.txt");
+            string dir = string.Format(jsonDir, configType.ToString());
+            if (!Directory.Exists(dir))
+            {
+                Directory.CreateDirectory(dir);
+            }
+            
+            string jsonPath = Path.Combine(dir, $"{name}.txt");
             using FileStream txt = new FileStream(jsonPath, FileMode.Create);
             using StreamWriter sw = new StreamWriter(txt);
             sw.Write(sb.ToString());
@@ -132,22 +167,25 @@ namespace ET
         static void ExportSheetJson(ExcelWorksheet worksheet, ConfigType configType, StringBuilder sb)
         {
             int infoRow = 2;
-            List<HeadInfo> headInfos = new List<HeadInfo>();
-            headInfos.Add(new HeadInfo());
-            headInfos.Add(new HeadInfo());
-            headInfos.Add(new HeadInfo());
+            HeadInfo[] headInfos = new HeadInfo[100];
             for (int col = 3; col <= worksheet.Dimension.End.Column; ++col)
             {
+                string fieldCS = worksheet.Cells[infoRow, col].Text.Trim();
+                if (fieldCS.Contains("#"))
+                {
+                    continue;
+                }
+                
                 string fieldName = worksheet.Cells[infoRow + 2, col].Text.Trim();
                 if (fieldName == "")
                 {
                     continue;
                 }
-                string fieldCS = worksheet.Cells[infoRow, col].Text.Trim();
+                
                 string fieldDesc = worksheet.Cells[infoRow + 1, col].Text.Trim();
                 string fieldType = worksheet.Cells[infoRow + 3, col].Text.Trim();
 
-                headInfos.Add(new HeadInfo(fieldCS, fieldDesc, fieldName, fieldType));
+                headInfos[col] = new HeadInfo(fieldCS, fieldDesc, fieldName, fieldType);
             }
             
             for (int row = 6; row <= worksheet.Dimension.End.Row; ++row)
@@ -156,6 +194,10 @@ namespace ET
                 for (int col = 3; col < worksheet.Dimension.End.Column; ++col)
                 {
                     HeadInfo headInfo = headInfos[col];
+                    if (headInfo.FieldAttribute == null)
+                    {
+                        continue;
+                    }
                     if (headInfo.FieldAttribute.Contains("#"))
                     {
                         continue;
@@ -198,5 +240,81 @@ namespace ET
                     throw new Exception($"不支持此类型: {type}");
             }
         }
+#endregion
+
+        // 根据生成的类,动态编译把json转成protobuf
+        private static void ExportExcelProtobuf(ConfigType configType)
+        {
+            string classPath = string.Format(classDir, configType);
+            List<SyntaxTree> syntaxTrees = new List<SyntaxTree>();
+            List<string> protoNames = new List<string>();
+            foreach (string classFile in Directory.GetFiles(classPath, "*.cs"))
+            {
+                protoNames.Add(Path.GetFileNameWithoutExtension(classFile));
+                syntaxTrees.Add(CSharpSyntaxTree.ParseText(File.ReadAllText(classFile)));
+            }
+            
+            List<PortableExecutableReference> references = new List<PortableExecutableReference>();
+            
+            string assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(object).Assembly.Location).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(BsonDefaultValueAttribute).Assembly.Location).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(IConfig).Assembly.Location).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(Attribute).Assembly.Location).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(Path.Combine(assemblyPath, "mscorlib.dll")).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(Path.Combine(assemblyPath, "System.dll")).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(Path.Combine(assemblyPath, "System.Core.dll")).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(Path.Combine(assemblyPath, "System.Runtime.dll")).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(Path.Combine(assemblyPath, "netstandard.dll")).GetReference());
+            references.Add(AssemblyMetadata.CreateFromFile(typeof(ISupportInitialize).Assembly.Location).GetReference());
+           
+            
+            CSharpCompilation compilation = CSharpCompilation.Create(
+                null, 
+                syntaxTrees.ToArray(), 
+                references.ToArray(), 
+                new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary));
+
+            using MemoryStream memSteam = new MemoryStream();
+            
+            EmitResult emitResult = compilation.Emit(memSteam);
+            if (!emitResult.Success)
+            {
+                StringBuilder stringBuilder = new StringBuilder();
+                foreach (Diagnostic t in emitResult.Diagnostics)
+                {
+                    stringBuilder.AppendLine(t.GetMessage());
+                }
+                throw new Exception($"动态编译失败:\n{stringBuilder}");
+            }
+            
+            memSteam.Seek(0, SeekOrigin.Begin);
+
+            Assembly ass = Assembly.Load(memSteam.ToArray());
+
+            string dir = string.Format(protoDir, configType.ToString());
+            if (!Directory.Exists(dir))
+            {
+                Directory.CreateDirectory(dir);
+            }
+            
+            foreach (string protoName in protoNames)
+            {
+                Type type = ass.GetType($"ET.{protoName}Category");
+                Type subType = ass.GetType($"ET.{protoName}");
+                Serializer.NonGeneric.PrepareSerializer(type);
+                Serializer.NonGeneric.PrepareSerializer(subType);
+                
+                
+                string json = File.ReadAllText(Path.Combine(string.Format(jsonDir, configType), $"{protoName}.txt"));
+                object deserialize = BsonSerializer.Deserialize(json, type);
+
+                string path = Path.Combine(dir, $"{protoName}.bytes");
+
+                using FileStream file = File.Create(path);
+                Serializer.Serialize(file, deserialize);
+            }
+        }
     }
 }

+ 35 - 0
Tools/ExcelExporter/ProtoObject.cs

@@ -0,0 +1,35 @@
+using System;
+using System.ComponentModel;
+using ProtoBuf;
+
+namespace ET
+{
+    public abstract class Object: ISupportInitialize, IDisposable
+    {
+        public Object()
+        {
+        }
+
+        public virtual void BeginInit()
+        {
+        }
+
+        [ProtoAfterDeserialization]
+        public virtual void AfterDeserialization()
+        {
+            this.EndInit();
+        }
+
+        public virtual void EndInit()
+        {
+        }
+
+        public virtual void Dispose()
+        {
+        }
+    }
+
+    public class ProtoObject: Object
+    {
+    }
+}

+ 4 - 3
Tools/ExcelExporter/Template.txt

@@ -1,11 +1,11 @@
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using MongoDB.Bson.Serialization.Attributes;
 using ProtoBuf;
 
 namespace ET
 {
+    [ProtoContract]
     [Config]
     public partial class (ConfigName)Category : ProtoObject
     {
@@ -26,7 +26,7 @@ namespace ET
 		
         public override void AfterDeserialization()
         {
-            foreach (StartMachineConfig config in list)
+            foreach ((ConfigName) config in list)
             {
                 this.dict.Add(config.Id, config);
             }
@@ -62,10 +62,11 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 
+    [ProtoContract]
 	public partial class (ConfigName): IConfig
 	{
 (Fields)

+ 1 - 0
Tools/Proto2CS/Proto2CS.csproj

@@ -2,6 +2,7 @@
 
     <PropertyGroup>
         <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+        <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
     </PropertyGroup>
 
     <PropertyGroup>

+ 2 - 1
Unity/Assets/Model/Generate/Config/StartMachineConfig.cs

@@ -62,7 +62,8 @@ namespace ET
             {
                 return null;
             }
-            return this.dict.Values.First();
+
+            return this.dict.Values.GetEnumerator().Current;
         }
     }
 

+ 5 - 5
Unity/Unity.Model.csproj

@@ -60,6 +60,7 @@
      <Compile Include="Assets\Model\Module\Message\MessageProxy.cs" />
      <Compile Include="Assets\Model\EventType.cs" />
      <Compile Include="Assets\Model\Core\UnOrderMultiMapSet.cs" />
+     <Compile Include="Assets\Model\Generate\Config\UnitConfig.cs" />
      <Compile Include="Assets\Model\Core\Entity\SceneType.cs" />
      <Compile Include="Assets\Model\Module\Message\SessionIdleCheckerComponent.cs" />
      <Compile Include="Assets\Model\Core\Helper\NetworkHelper.cs" />
@@ -72,6 +73,7 @@
      <Compile Include="Assets\Model\Module\Resource\AssetsLoaderAsync.cs" />
      <Compile Include="Assets\Model\Core\Helper\EnumHelper.cs" />
      <Compile Include="Assets\Model\Core\Object\BaseAttribute.cs" />
+     <Compile Include="Assets\Model\Generate\Config\StartZoneConfig.cs" />
      <Compile Include="Assets\Model\Module\CoroutineLock\CoroutineLockQueueType.cs" />
      <Compile Include="Assets\Model\Unit\Unit.cs" />
      <Compile Include="Assets\Model\Module\Message\MessageSerializeHelper.cs" />
@@ -84,6 +86,7 @@
      <Compile Include="Assets\Model\Core\Helper\MethodInfoHelper.cs" />
      <Compile Include="Assets\Model\Module\Network\Kcp.cs" />
      <Compile Include="Assets\Model\Core\Helper\FileHelper.cs" />
+     <Compile Include="Assets\Model\Generate\Config\StartProcessConfig.cs" />
      <Compile Include="Assets\Model\Core\Log\UnityLogger.cs" />
      <Compile Include="Assets\Model\Core\Object\HideInHierarchy.cs" />
      <Compile Include="Assets\Model\Module\Config\ConfigAttribute.cs" />
@@ -154,6 +157,7 @@
      <Compile Include="Assets\Model\Module\Message\SessionAcceptTimeoutComponent.cs" />
      <Compile Include="Assets\Model\Module\Numeric\NumericComponent.cs" />
      <Compile Include="Assets\Model\Module\Message\Session.cs" />
+     <Compile Include="Assets\Model\Generate\Config\StartMachineConfig.cs" />
      <Compile Include="Assets\Model\Core\Object\NoMemoryCheck.cs" />
      <Compile Include="Assets\Model\Core\ObjectWait.cs" />
      <Compile Include="Assets\Model\Core\Object\Entity.cs" />
@@ -175,6 +179,7 @@
      <Compile Include="Assets\Model\Generate\OuterProtoOpcode.cs" />
      <Compile Include="Assets\Model\Core\Object\ProtoObject.cs" />
      <Compile Include="Assets\Model\Module\Message\ProtobufHelper.cs" />
+     <Compile Include="Assets\Model\Generate\Config\StartSceneConfig.cs" />
      <Compile Include="Assets\Model\Module\Message\NetThreadComponent.cs" />
      <Compile Include="Assets\Model\Core\Helper\TimeHelper.cs" />
      <Compile Include="Assets\Model\Core\Object\ISerializeToEntity.cs" />
@@ -197,11 +202,6 @@
      <Compile Include="Assets\Model\Core\Async\ETTaskHelper.cs" />
      <Compile Include="Assets\Model\Module\NetworkTCP\TChannel.cs" />
      <Compile Include="Assets\Model\Module\Network\AChannel.cs" />
-     <Compile Include="Assets\Model\Generate\Config\UnitConfig.cs" />
-     <Compile Include="Assets\Model\Generate\Config\StartSceneConfig.cs" />
-     <Compile Include="Assets\Model\Generate\Config\StartZoneConfig.cs" />
-     <Compile Include="Assets\Model\Generate\Config\StartProcessConfig.cs" />
-     <Compile Include="Assets\Model\Generate\Config\StartMachineConfig.cs" />
      <None Include="Assets\Model\Unity.Model.asmdef" />
  <Reference Include="UnityEngine">
  <HintPath>/Applications/Unity/Hub/Editor/2020.2.2f1c1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.dll</HintPath>