diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..4557738
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,21 @@
+root = true
+
+[*]
+charset = utf-8
+
+# IDE0130: 命名空间与文件夹结构不匹配
+dotnet_style_namespace_match_folder = false
+# CS4014: 由于此调用不会等待,因此在调用完成前将继续执行当前方法
+dotnet_diagnostic.CS4014.severity = none
+# CA1822: 将成员标记为 static
+dotnet_diagnostic.CA1822.severity = none
+
+# formating
+csharp_new_line_before_open_brace = none
+csharp_new_line_before_else = none
+csharp_new_line_before_catch = none
+csharp_new_line_before_finally = none
+csharp_new_line_before_members_in_object_initializers = none
+csharp_new_line_before_members_in_anonymous_types = none
+csharp_new_line_between_query_expression_clauses = none
+
diff --git a/Directory.Build.props b/Directory.Build.props
index 4b2e817..4a8c40b 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -15,5 +15,6 @@
..\Build\.intermediate\Source
+ ..\Build\.intermediate\Generator
\ No newline at end of file
diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj
new file mode 100644
index 0000000..0e62845
--- /dev/null
+++ b/Generator/Generator.csproj
@@ -0,0 +1,9 @@
+
+
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
+
+
\ No newline at end of file
diff --git a/Generator/MySourceGenerator.cs b/Generator/MySourceGenerator.cs
new file mode 100644
index 0000000..88b51c3
--- /dev/null
+++ b/Generator/MySourceGenerator.cs
@@ -0,0 +1,25 @@
+using System.Text;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Text;
+
+namespace MySourceGenerator {
+ [Generator]
+ public class MySourceGenerator : ISourceGenerator {
+ public void Execute(GeneratorExecutionContext context) {
+ var sb = new StringBuilder();
+ sb.AppendLine("using System;");
+ sb.AppendLine("namespace Generated;");
+ sb.AppendLine("public static class HelloWorld {");
+ sb.AppendLine(" public static void SayHello() {");
+ sb.AppendLine(" Console.WriteLine(\"Hello World!!!\");");
+ sb.AppendLine(" }");
+ sb.AppendLine("}");
+
+ context.AddSource("HelleWorld.generated", SourceText.From(sb.ToString(), Encoding.UTF8));
+ }
+
+ public void Initialize(GeneratorInitializationContext context) {
+ System.Diagnostics.Debugger.Launch();
+ }
+ }
+}
diff --git a/Source/Program.cs b/Source/Program.cs
index 3751555..bfd50dd 100644
--- a/Source/Program.cs
+++ b/Source/Program.cs
@@ -1,2 +1,8 @@
-// See https://aka.ms/new-console-template for more information
-Console.WriteLine("Hello, World!");
+using Generated;
+namespace Source;
+
+class Program {
+ static void Main(string[] args) {
+ HelloWorld.SayHello();
+ }
+}
\ No newline at end of file
diff --git a/Source/Source.csproj b/Source/Source.csproj
index c0d67fc..6a90010 100644
--- a/Source/Source.csproj
+++ b/Source/Source.csproj
@@ -1,4 +1,7 @@
+
+
+
Exe
diff --git a/codegen.sln b/codegen.sln
index f60aa21..e8ab016 100644
--- a/codegen.sln
+++ b/codegen.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Source", "Source\Source.csproj", "{F1B0542C-51A8-4953-A350-10B350394FE2}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{AA6A4A38-6F2C-4EB2-8A6C-122030177E32}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -27,6 +29,18 @@ Global
{F1B0542C-51A8-4953-A350-10B350394FE2}.Release|x64.Build.0 = Release|Any CPU
{F1B0542C-51A8-4953-A350-10B350394FE2}.Release|x86.ActiveCfg = Release|Any CPU
{F1B0542C-51A8-4953-A350-10B350394FE2}.Release|x86.Build.0 = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|x64.Build.0 = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|x86.Build.0 = Debug|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|x64.ActiveCfg = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|x64.Build.0 = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|x86.ActiveCfg = Release|Any CPU
+ {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE