diff --git a/Directory.Build.props b/Directory.Build.props index 4a8c40b..f7ccd9b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,6 +1,7 @@ + - net8.0 + net9.0 enable True lingdar77 @@ -8,13 +9,16 @@ enable True + - ..\Build + ..\Build\$(MSBuildProjectName) + ..\Build\Source false false + - ..\Build\.intermediate\Source - ..\Build\.intermediate\Generator + ..\Build\.intermediate\$(MSBuildProjectName) + \ No newline at end of file diff --git a/Generator/Generator.csproj b/Generator/Generator.csproj index 0e62845..5deb01c 100644 --- a/Generator/Generator.csproj +++ b/Generator/Generator.csproj @@ -1,9 +1,15 @@ - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - + + + false + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + \ No newline at end of file diff --git a/Generator/MySourceGenerator.cs b/Generator/MySourceGenerator.cs index c30e60a..5d9fef6 100644 --- a/Generator/MySourceGenerator.cs +++ b/Generator/MySourceGenerator.cs @@ -10,8 +10,8 @@ namespace MySourceGenerator { 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(" public static string SayHello() {"); + sb.AppendLine(" return \"Hello World!!!\";"); sb.AppendLine(" }"); sb.AppendLine("}"); diff --git a/Source/Program.cs b/Source/Program.cs index bfd50dd..4f79b13 100644 --- a/Source/Program.cs +++ b/Source/Program.cs @@ -3,6 +3,6 @@ namespace Source; class Program { static void Main(string[] args) { - HelloWorld.SayHello(); + Console.WriteLine(HelloWorld.SayHello()); } } \ No newline at end of file diff --git a/Source/Source.csproj b/Source/Source.csproj index 6a90010..95232ef 100644 --- a/Source/Source.csproj +++ b/Source/Source.csproj @@ -1,8 +1,11 @@  - - - + Exe + + + + + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj new file mode 100644 index 0000000..b9b10ee --- /dev/null +++ b/Tests/Tests.csproj @@ -0,0 +1,23 @@ + + + + false + + + + + + + + + + + + + + + + + + + diff --git a/Tests/UnitTest1.cs b/Tests/UnitTest1.cs new file mode 100644 index 0000000..9b5171c --- /dev/null +++ b/Tests/UnitTest1.cs @@ -0,0 +1,10 @@ +using Generated; + +namespace Tests; + +public class UnitTest1 { + [Fact] + public void Test1() { + Assert.Equal("Hello World!!!", HelloWorld.SayHello()); + } +} diff --git a/codegen.sln b/codegen.sln index 5a7d52b..3d26eea 100644 --- a/codegen.sln +++ b/codegen.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Source", "Source\Source.csp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generator", "Generator\Generator.csproj", "{AA6A4A38-6F2C-4EB2-8A6C-122030177E32}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{C2653F10-1B69-4E2D-A858-E9E7773D9624}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {AA6A4A38-6F2C-4EB2-8A6C-122030177E32}.Debug|Any CPU.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 + {C2653F10-1B69-4E2D-A858-E9E7773D9624}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C2653F10-1B69-4E2D-A858-E9E7773D9624}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C2653F10-1B69-4E2D-A858-E9E7773D9624}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C2653F10-1B69-4E2D-A858-E9E7773D9624}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE