This commit is contained in:
2025-10-03 19:37:52 +08:00
parent 5e36931536
commit c0157a7e91
8 changed files with 69 additions and 17 deletions
+8 -4
View File
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<Authors>lingdar77</Authors>
@@ -8,13 +9,16 @@
<Nullable>enable</Nullable>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(MSBuildProjectName)' != 'Launcher'">
<OutputPath>..\Build</OutputPath>
<OutputPath>..\Build\$(MSBuildProjectName)</OutputPath>
<OutputPath Condition="'$(MSBuildProjectName)' == 'Generator'">..\Build\Source</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup>
<BaseIntermediateOutputPath Condition="'$(MSBuildProjectName)' == 'Source'">..\Build\.intermediate\Source</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath Condition="'$(MSBuildProjectName)' == 'Generator'">..\Build\.intermediate\Generator</BaseIntermediateOutputPath>
<BaseIntermediateOutputPath>..\Build\.intermediate\$(MSBuildProjectName)</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>
+13 -7
View File
@@ -1,9 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
</ItemGroup>
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.13.0" />
</ItemGroup>
</Project>
+2 -2
View File
@@ -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("}");
+1 -1
View File
@@ -3,6 +3,6 @@ namespace Source;
class Program {
static void Main(string[] args) {
HelloWorld.SayHello();
Console.WriteLine(HelloWorld.SayHello());
}
}
+6 -3
View File
@@ -1,8 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\Generator\Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Generator\Generator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
</Project>
+23
View File
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Source\Source.csproj" />
</ItemGroup>
</Project>
+10
View File
@@ -0,0 +1,10 @@
using Generated;
namespace Tests;
public class UnitTest1 {
[Fact]
public void Test1() {
Assert.Equal("Hello World!!!", HelloWorld.SayHello());
}
}
+6
View File
@@ -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