Merge pull request #21 from kteong1012/pr220910

[new] config c#代码生成支持无命名空间
main
walon 2022-09-19 17:01:32 +08:00 committed by GitHub
commit 70b5a9b061
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 22 deletions

View File

@ -312,5 +312,27 @@ namespace Luban.Job.Cfg.Utils
{
return type.Apply(CsEditorInitValueVisitor.Ins);
}
public static string CsStartNameSpaceGrace(string np)
{
if (string.IsNullOrEmpty(np))
{
return string.Empty;
}
else
{
return $"namespace {np}\n{{";
}
}
public static string CsEndNameSpaceGrace(string np)
{
if (string.IsNullOrEmpty(np))
{
return string.Empty;
}
else
{
return "}";
}
}
}
}

View File

@ -5,8 +5,8 @@
items = x.items
~}}
namespace {{namespace_with_top_module}}
{
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{~if comment != '' ~}}
/// <summary>
/// {{comment | html.escape}}
@ -26,4 +26,5 @@ namespace {{namespace_with_top_module}}
{{item.name}} = {{item.value}},
{{~end~}}
}
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -1,4 +1,4 @@
using Bright.Serialization;
using Bright.Serialization;
using System.Collections.Generic;
{{
name = x.name
@ -7,10 +7,7 @@ using System.Collections.Generic;
hierarchy_export_fields = x.hierarchy_export_fields
}}
namespace {{x.namespace_with_top_module}}
{
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{~if x.comment != '' ~}}
/// <summary>
/// {{x.escape_comment}}
@ -115,4 +112,4 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
partial void PostResolve();
}
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -1,8 +1,8 @@
using Bright.Serialization;
using System.Collections.Generic;
namespace {{x.namespace_with_top_module}}
{
{{cs_start_name_space_grace x.namespace_with_top_module}}
{{
name = x.name
key_type = x.key_ttype
@ -170,4 +170,4 @@ public partial class {{name}}
partial void PostResolve();
}
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -6,9 +6,8 @@ using Bright.Serialization;
tables = x.tables
}}
namespace {{namespace}}
{
{{cs_start_name_space_grace x.namespace_with_top_module}}
public partial class {{name}}
{
{{~for table in tables ~}}
@ -46,4 +45,4 @@ public partial class {{name}}
partial void PostResolve();
}
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -10,8 +10,7 @@ using SimpleJSON;
fields = x.fields
}}
namespace {{x.namespace_with_editor_top_module}}
{
{{cs_start_name_space_grace x.namespace_with_editor_top_module}}
{{~if x.comment != '' ~}}
/// <summary>
@ -108,3 +107,5 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
{{~end~}}
}
}
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}

View File

@ -5,9 +5,7 @@
itemType = 'Bright.Config.EditorEnumItemInfo'
~}}
namespace {{x.namespace_with_editor_top_module}}
{
{{cs_start_name_space_grace x.namespace_with_editor_top_module}}
{{~if comment != '' ~}}
/// <summary>
/// {{comment | html.escape}}
@ -58,4 +56,5 @@ namespace {{x.namespace_with_editor_top_module}}
return __items.Find(c => c.Value == value);
}
}
}
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}