mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-22 10:34:30 +08:00
feat(diagnostic): 添加通用诊断描述符并重构诊断系统
- 添加 CommonDiagnostics 类提供通用诊断描述符 - 将诊断相关文件从 logging 目录移动到 diagnostics 目录 - 更新命名空间从 GFramework.SourceGenerators.Common.diagnostics 到 GFramework.SourceGenerators.diagnostics - 修改诊断ID从 GFC001 到 GF_Common_Class_001 - 移除 GFramework.SourceGenerators.Common 项目引用 - 更新 AnalyzerReleases.Unshipped.md 文件中的诊断规则 - 重构 README.md 文件提供完整的项目介绍和使用指南
This commit is contained in:
parent
7cd3979c48
commit
f3c5840ebe
@ -5,4 +5,5 @@
|
||||
|
||||
Rule ID | Category | Severity | Notes
|
||||
----------------------|--------------------------|----------|------------------------
|
||||
GF_Common_Class_001 | GFramework.Common | Error | CommonDiagnostics
|
||||
GF_Godot_Logging_001 | GFramework.Godot.Logging | Warning | GodotLoggerDiagnostics
|
||||
@ -27,8 +27,7 @@
|
||||
|
||||
<!-- Generator 编译期引用 Attributes / Common,但不打包 -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GFramework.Godot.SourceGenerators.Abstractions\GFramework.SourceGenerators.Abstractions.csproj" PrivateAssets="all"/>
|
||||
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj" PrivateAssets="all"/>
|
||||
<ProjectReference Include="..\..\GFramework.Godot.SourceGenerators.Abstractions\GFramework.Godot.SourceGenerators.Abstractions.csproj" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ★关键:只把 Generator DLL 放进 analyzers -->
|
||||
@ -44,17 +43,10 @@
|
||||
Pack="true"
|
||||
PackagePath="analyzers/dotnet/cs"
|
||||
Visible="false"/>
|
||||
|
||||
<None Include="$(OutputPath)\GFramework.SourceGenerators.Common.dll"
|
||||
Pack="true"
|
||||
PackagePath="analyzers/dotnet/cs"
|
||||
Visible="false"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="$(OutputPath)\$(AssemblyName).Abstractions.dll" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="$(OutputPath)\$(AssemblyName).Abstractions.xml" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="GFramework.SourceGenerators.Common.dll" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="GFramework.SourceGenerators.Common.xml" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<!-- 包含targets文件 -->
|
||||
<None Include="GFramework.Godot.SourceGenerators.targets" Pack="true" PackagePath="build" Visible="false"/>
|
||||
</ItemGroup>
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace GFramework.Godot.SourceGenerators.diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供通用诊断描述符的静态类
|
||||
/// </summary>
|
||||
public static class CommonDiagnostics
|
||||
{
|
||||
/// <summary>
|
||||
/// 定义类必须为partial的诊断描述符
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 诊断ID: GF001
|
||||
/// 诊断消息: "Class '{0}' must be declared partial for code generation"
|
||||
/// 分类: GFramework.Common
|
||||
/// 严重性: Error
|
||||
/// 是否启用: true
|
||||
/// </remarks>
|
||||
public static readonly DiagnosticDescriptor ClassMustBePartial =
|
||||
new(
|
||||
"GF_Common_Class_001",
|
||||
"Class must be partial",
|
||||
"Class '{0}' must be declared partial for code generation",
|
||||
"GFramework.Common",
|
||||
DiagnosticSeverity.Error,
|
||||
true
|
||||
);
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace GFramework.Godot.SourceGenerators.logging;
|
||||
namespace GFramework.Godot.SourceGenerators.diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供诊断描述符的静态类,用于GFramework日志生成器的编译时检查
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GFramework.SourceGenerators.Common.diagnostics;
|
||||
using GFramework.Godot.SourceGenerators.diagnostics;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
; Shipped analyzer releases
|
||||
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
|
||||
|
||||
@ -1,8 +0,0 @@
|
||||
; Unshipped analyzer release
|
||||
; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
|
||||
|
||||
### New Rules
|
||||
|
||||
Rule ID | Category | Severity | Notes
|
||||
---------|-------------------|----------|-------------------
|
||||
GFC001 | GFramework.Common | Error | CommonDiagnostics
|
||||
@ -1,23 +0,0 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||
<!--
|
||||
we use a higher version than supported by the target framework to have nullable types and other nice features
|
||||
(a lot of features get polyfilled by Meziantou.Polyfill)
|
||||
however we need to be careful with the available features!
|
||||
-->
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Meziantou.Analyzer" Version="2.0.264">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Meziantou.Polyfill" Version="1.0.71">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -1,18 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<MeziantouPolyfill_IncludedPolyfills>T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute</MeziantouPolyfill_IncludedPolyfills>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.14.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="AnalyzerReleases.Shipped.md"/>
|
||||
<AdditionalFiles Include="AnalyzerReleases.Unshipped.md"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -3,7 +3,8 @@
|
||||
|
||||
### New Rules
|
||||
|
||||
Rule ID | Category | Severity | Notes
|
||||
----------------|----------------------------------|----------|------------------------
|
||||
GF_Logging_001 | GFramework.Godot.Logging | Warning | LoggerDiagnostics
|
||||
GF_Rule_001 | GFramework.SourceGenerators.rule | Error | ContextAwareDiagnostic
|
||||
Rule ID | Category | Severity | Notes
|
||||
---------------------|----------------------------------|----------|------------------------
|
||||
GF_Common_Class_001 | GFramework.Common | Error | CommonDiagnostics
|
||||
GF_Logging_001 | GFramework.Godot.Logging | Warning | LoggerDiagnostics
|
||||
GF_Rule_001 | GFramework.SourceGenerators.rule | Error | ContextAwareDiagnostic
|
||||
@ -28,7 +28,6 @@
|
||||
<!-- Generator 编译期引用 Attributes / Common,但不打包 -->
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GFramework.SourceGenerators.Abstractions\GFramework.SourceGenerators.Abstractions.csproj" PrivateAssets="all"/>
|
||||
<ProjectReference Include="..\GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj" PrivateAssets="all"/>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ★关键:只把 Generator DLL 放进 analyzers -->
|
||||
@ -45,16 +44,10 @@
|
||||
PackagePath="analyzers/dotnet/cs"
|
||||
Visible="false"/>
|
||||
|
||||
<None Include="$(OutputPath)\GFramework.SourceGenerators.Common.dll"
|
||||
Pack="true"
|
||||
PackagePath="analyzers/dotnet/cs"
|
||||
Visible="false"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="$(OutputPath)\$(AssemblyName).Abstractions.dll" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="$(OutputPath)\$(AssemblyName).Abstractions.xml" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="GFramework.SourceGenerators.Common.dll" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<None Include="GFramework.SourceGenerators.Common.xml" Pack="true" PackagePath="lib\netstandard2.0" Visible="true"/>
|
||||
<!-- 包含targets文件 -->
|
||||
<None Include="GFramework.SourceGenerators.targets" Pack="true" PackagePath="build" Visible="false"/>
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace GFramework.SourceGenerators.Common.diagnostics;
|
||||
namespace GFramework.SourceGenerators.diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供通用诊断描述符的静态类
|
||||
@ -19,7 +19,7 @@ public static class CommonDiagnostics
|
||||
/// </remarks>
|
||||
public static readonly DiagnosticDescriptor ClassMustBePartial =
|
||||
new(
|
||||
"GFC001",
|
||||
"GF_Common_Class_001",
|
||||
"Class must be partial",
|
||||
"Class '{0}' must be declared partial for code generation",
|
||||
"GFramework.Common",
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace GFramework.SourceGenerators.rule;
|
||||
namespace GFramework.SourceGenerators.diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供与上下文感知相关的诊断规则定义
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace GFramework.SourceGenerators.logging;
|
||||
namespace GFramework.SourceGenerators.diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// 提供诊断描述符的静态类,用于GFramework日志生成器的编译时检查
|
||||
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GFramework.SourceGenerators.Common.diagnostics;
|
||||
using GFramework.SourceGenerators.diagnostics;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GFramework.SourceGenerators.Common.diagnostics;
|
||||
using GFramework.SourceGenerators.diagnostics;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
<None Remove="GFramework.SourceGenerators.Tests\**"/>
|
||||
<None Remove="GFramework.Godot.SourceGenerators.Abstractions\**"/>
|
||||
<None Remove="GFramework.SourceGenerators.Abstractions\**"/>
|
||||
<None Remove="GFramework.Godot.SourceGenerators.targets"/>
|
||||
</ItemGroup>
|
||||
<!-- 聚合核心模块 -->
|
||||
<ItemGroup>
|
||||
|
||||
@ -16,8 +16,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Godot.SourceGene
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Godot.SourceGenerators.Abstractions", "GFramework.Godot.SourceGenerators.Abstractions\GFramework.Godot.SourceGenerators.Abstractions.csproj", "{3A1132B7-EC3B-4BB6-A752-8ADC92BC08A0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.SourceGenerators.Common", "GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj", "{3DB57A3A-ACCF-47BE-A17B-2ADD68B6C8AA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.SourceGenerators.Tests", "GFramework.SourceGenerators.Tests\GFramework.SourceGenerators.Tests.csproj", "{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}"
|
||||
EndProject
|
||||
Global
|
||||
@ -58,10 +56,6 @@ Global
|
||||
{3A1132B7-EC3B-4BB6-A752-8ADC92BC08A0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3A1132B7-EC3B-4BB6-A752-8ADC92BC08A0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3A1132B7-EC3B-4BB6-A752-8ADC92BC08A0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3DB57A3A-ACCF-47BE-A17B-2ADD68B6C8AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3DB57A3A-ACCF-47BE-A17B-2ADD68B6C8AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3DB57A3A-ACCF-47BE-A17B-2ADD68B6C8AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3DB57A3A-ACCF-47BE-A17B-2ADD68B6C8AA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
||||
105
README.md
105
README.md
@ -1,9 +1,102 @@
|
||||
# 项目介绍
|
||||
# GFramework
|
||||
|
||||
本项目参考(CV)自[QFramework](https://github.com/liangxiegame/QFramework)
|
||||
A comprehensive C# game development framework designed for Godot and general game development scenarios.
|
||||
|
||||
# 为什么要有这个项目
|
||||
## Features
|
||||
|
||||
- 原来的项目是单文件框架,我把框架拆成多个文件,方便管理
|
||||
- 纯粹个人自用,要使用还是请访问[QFramework](https://github.com/liangxiegame/QFramework)
|
||||
- 至于修改名字,是因为我为了方便会发布GuGet包,假设将来QFramework也要发布GuGet包,那么就会冲突了
|
||||
### Core Architecture
|
||||
|
||||
- **Dependency Injection**: Built-in IoC container for managing object lifecycles
|
||||
- **Event System**: Type-safe event system for loose coupling
|
||||
- **Property Binding**: Bindable properties for reactive programming
|
||||
- **Logging Framework**: Structured logging with multiple log levels
|
||||
|
||||
### Game Development Features
|
||||
|
||||
- **Asset Management**: Centralized asset catalog system
|
||||
- **Resource Factory**: Factory pattern for resource creation
|
||||
- **Architecture Pattern**: Clean architecture with separation of concerns
|
||||
|
||||
### Godot Integration
|
||||
|
||||
- **Godot-Specific Extensions**: Extensions and utilities for Godot development
|
||||
- **Node Extensions**: Helpful extensions for Godot Node classes
|
||||
- **Godot Logger**: Specialized logging system for Godot applications
|
||||
|
||||
## Projects
|
||||
|
||||
### Core Projects
|
||||
|
||||
- **GFramework.Core**: Core framework functionality
|
||||
- **GFramework.Game**: Game-specific abstractions and systems
|
||||
- **GFramework.Godot**: Godot-specific implementations
|
||||
|
||||
### Source Generators
|
||||
|
||||
- **GFramework.SourceGenerators**: Code generators for automatic code generation
|
||||
- **GFramework.Godot.SourceGenerators**: Godot-specific code generators
|
||||
- **GFramework.SourceGenerators.Abstractions**: Abstractions for source generators
|
||||
- **GFramework.Godot.SourceGenerators.Abstractions**: Godot-specific abstractions
|
||||
|
||||
## Getting Started
|
||||
|
||||
### Installation
|
||||
|
||||
1. Install the NuGet packages:
|
||||
|
||||
```bash
|
||||
dotnet add package GeWuYou.GFramework.Core
|
||||
dotnet add package GeWuYou.GFramework.Game
|
||||
dotnet add package GeWuYou.GFramework.Godot
|
||||
```
|
||||
|
||||
### Basic Usage
|
||||
|
||||
```csharp
|
||||
// Create an architecture instance
|
||||
var architecture = new MyArchitecture();
|
||||
|
||||
// Initialize the architecture
|
||||
await architecture.InitializeAsync();
|
||||
|
||||
// Access services
|
||||
var service = architecture.Container.Resolve<IMyService>();
|
||||
```
|
||||
|
||||
### Godot Integration
|
||||
|
||||
```csharp
|
||||
// Use Godot-specific features
|
||||
[GodotLog]
|
||||
public partial class MyGodotNode : Node
|
||||
{
|
||||
// Auto-generated logger will be available
|
||||
private readonly ILogger _log = Log.GetLogger("MyGodotNode");
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_log.Info("Node is ready!");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Architecture
|
||||
|
||||
The framework follows clean architecture principles with the following layers:
|
||||
|
||||
1. **Core Layer**: Fundamental abstractions and interfaces
|
||||
2. **Application Layer**: Use cases and application services
|
||||
3. **Infrastructure Layer**: External dependencies and implementations
|
||||
4. **Presentation Layer**: UI and user interaction components
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
|
||||
|
||||
## Support
|
||||
|
||||
For support and questions, please open an issue in the repository.
|
||||
Loading…
x
Reference in New Issue
Block a user