feat(godot-source-generators): 重构Godot源代码生成器项目配置

- 将TargetFramework从net10.0更改为netstandard2.0以提高兼容性
- 添加必要的using语句(System和System.Linq)到GodotLoggerGenerator
- 配置项目属性以支持Roslyn分析器功能,包括GeneratePackageOnBuild、
  IsRoslynAnalyzer等设置
- 添加EnforceExtendedAnalyzerRules以启用扩展规则验证
- 配置项目引用GFramework.Godot.SourceGenerators.Attributes并设置
  PrivateAssets="all"避免运行时依赖
- 设置打包配置将生成器DLL打包为analyzers/dotnet/cs路径
- 修正GodotLogAttribute命名空间为GFramework.Godot.SourceGenerators.Attributes.logging
- 更新PackageId为GeWuYou.GFramework.SourceGenerators.Attributes
- 移除不必要的PackageReadmeFile配置
This commit is contained in:
GwWuYou 2025-12-25 21:22:20 +08:00
parent 763b460575
commit 2f3bc2d526
6 changed files with 39 additions and 10 deletions

View File

@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>GeWuYou.GFramework.SourceGenerators.Attributes</PackageId>
<Version>1.0.0</Version>
<LangVersion>10</LangVersion>
</PropertyGroup>
</Project>

View File

@ -1,5 +1,7 @@
#nullable enable
namespace GFramework.SourceGenerators.Attributes.logging;
using System;
namespace GFramework.Godot.SourceGenerators.Attributes.logging;
/// <summary>
/// Godot日志特性用于在类上标记以自动生成日志字段

View File

@ -1,9 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>GeWuYou.GFramework.Godot.SourceGenerators</PackageId>
<TargetFramework>netstandard2.0</TargetFramework>
<IsRoslynAnalyzer>true</IsRoslynAnalyzer>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<IsRoslynComponent>true</IsRoslynComponent>
<!-- 对 generator 项目要启用扩展规则 -->
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<!-- 不把输出当作运行时库 -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<!-- 有助于调试生成的代码(可选) -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>
<ItemGroup>
@ -16,4 +28,17 @@
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md"/>
</ItemGroup>
<ItemGroup>
<!-- Generator 需要引用 Attributes 项目,但不作为运行时依赖 -->
<ProjectReference Include="..\GFramework.Godot.SourceGenerators.Attributes\GFramework.SourceGenerators.Attributes.csproj"
PrivateAssets="all"/>
</ItemGroup>
<!-- 将 Generator 和 Attributes DLL 打包为 Analyzer -->
<ItemGroup>
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true"
PackagePath="analyzers/dotnet/cs" Visible="false"/>
<None Include="$(OutputPath)$(AssemblyName).dll" Pack="true" PackagePath="lib/netstandard2.0"/>
<None Include="$(OutputPath)\GFramework.Godot.SourceGenerators.Attributes.dll" Pack="true"
PackagePath="analyzers/dotnet/cs" Visible="false"/>
</ItemGroup>
</Project>

View File

@ -1,4 +1,6 @@
using System.Text;
using System;
using System.Linq;
using System.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>GeWuYou.GFramework.Generator.Attributes</PackageId>
<PackageId>GeWuYou.GFramework.SourceGenerators.Attributes</PackageId>
<Version>1.0.0</Version>
<LangVersion>10</LangVersion>
</PropertyGroup>

View File

@ -12,7 +12,6 @@
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<!-- 不把输出当作运行时库 -->
<IncludeBuildOutput>false</IncludeBuildOutput>
<PackageReadmeFile>README.md</PackageReadmeFile>
<!-- 有助于调试生成的代码(可选) -->
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>