diff --git a/GFramework.Godot.SourceGenerators/AnalyzerReleases.Unshipped.md b/GFramework.Godot.SourceGenerators/AnalyzerReleases.Unshipped.md
index 7043d79..58de45e 100644
--- a/GFramework.Godot.SourceGenerators/AnalyzerReleases.Unshipped.md
+++ b/GFramework.Godot.SourceGenerators/AnalyzerReleases.Unshipped.md
@@ -5,5 +5,4 @@
Rule ID | Category | Severity | Notes
----------------------|--------------------------|----------|------------------------
- GF_Common_Class_001 | GFramework.Common | Error | CommonDiagnostics
GF_Godot_Logging_001 | GFramework.Godot.Logging | Warning | GodotLoggerDiagnostics
\ No newline at end of file
diff --git a/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj b/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj
index c62f58b..1e4b9fc 100644
--- a/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj
+++ b/GFramework.Godot.SourceGenerators/GFramework.Godot.SourceGenerators.csproj
@@ -29,6 +29,7 @@
+
@@ -44,10 +45,17 @@
Pack="true"
PackagePath="analyzers/dotnet/cs"
Visible="false"/>
+
+
+
+
diff --git a/GFramework.Godot.SourceGenerators/GeWuYou.GFramework.Godot.SourceGenerators.targets b/GFramework.Godot.SourceGenerators/GeWuYou.GFramework.Godot.SourceGenerators.targets
index d1196d5..37971c9 100644
--- a/GFramework.Godot.SourceGenerators/GeWuYou.GFramework.Godot.SourceGenerators.targets
+++ b/GFramework.Godot.SourceGenerators/GeWuYou.GFramework.Godot.SourceGenerators.targets
@@ -6,6 +6,7 @@
+
diff --git a/GFramework.Godot.SourceGenerators/constants/PathContests.cs b/GFramework.Godot.SourceGenerators/constants/PathContests.cs
new file mode 100644
index 0000000..d439327
--- /dev/null
+++ b/GFramework.Godot.SourceGenerators/constants/PathContests.cs
@@ -0,0 +1,6 @@
+namespace GFramework.Godot.SourceGenerators.constants;
+
+public static class PathContests
+{
+ public const string RootAbstractionsPath = "GFramework.Godot.SourceGenerators.Abstractions";
+}
\ No newline at end of file
diff --git a/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs b/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs
index 7ce8b19..e5f8dbd 100644
--- a/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs
+++ b/GFramework.Godot.SourceGenerators/logging/GodotLoggerGenerator.cs
@@ -1,7 +1,8 @@
using System;
using System.Linq;
using System.Text;
-using GFramework.Godot.SourceGenerators.diagnostics;
+using GFramework.Godot.SourceGenerators.constants;
+using GFramework.SourceGenerators.Common.diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -16,7 +17,7 @@ namespace GFramework.Godot.SourceGenerators.logging;
public sealed class GodotLoggerGenerator : IIncrementalGenerator
{
private const string AttributeMetadataName =
- "GFramework.Godot.SourceGenerators.Abstractions.logging.GodotLogAttribute";
+ $"{PathContests.RootAbstractionsPath}.logging.GodotLogAttribute";
private const string AttributeShortName = "GodotLogAttribute";
private const string AttributeShortNameWithoutSuffix = "GodotLog";
diff --git a/GFramework.SourceGenerators.Common/AnalyzerReleases.Shipped.md b/GFramework.SourceGenerators.Common/AnalyzerReleases.Shipped.md
new file mode 100644
index 0000000..60b59dd
--- /dev/null
+++ b/GFramework.SourceGenerators.Common/AnalyzerReleases.Shipped.md
@@ -0,0 +1,3 @@
+; Shipped analyzer releases
+; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md
+
diff --git a/GFramework.SourceGenerators.Common/AnalyzerReleases.Unshipped.md b/GFramework.SourceGenerators.Common/AnalyzerReleases.Unshipped.md
new file mode 100644
index 0000000..7f402e3
--- /dev/null
+++ b/GFramework.SourceGenerators.Common/AnalyzerReleases.Unshipped.md
@@ -0,0 +1,8 @@
+; 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
+---------------------|-------------------|----------|-------------------
+ GF_Common_Class_001 | GFramework.Common | Error | CommonDiagnostics
\ No newline at end of file
diff --git a/GFramework.SourceGenerators.Common/Directory.Build.props b/GFramework.SourceGenerators.Common/Directory.Build.props
new file mode 100644
index 0000000..82f43af
--- /dev/null
+++ b/GFramework.SourceGenerators.Common/Directory.Build.props
@@ -0,0 +1,24 @@
+
+
+
+ netstandard2.0
+ true
+ true
+
+ preview
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
diff --git a/GFramework.SourceGenerators.Common/GFramework.SourceGenerators.Common.csproj b/GFramework.SourceGenerators.Common/GFramework.SourceGenerators.Common.csproj
new file mode 100644
index 0000000..2bcf12c
--- /dev/null
+++ b/GFramework.SourceGenerators.Common/GFramework.SourceGenerators.Common.csproj
@@ -0,0 +1,24 @@
+
+
+
+
+ false
+ true
+ T:System.Diagnostics.CodeAnalysis.NotNullWhenAttribute
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/GFramework.Godot.SourceGenerators/diagnostics/CommonDiagnostics.cs b/GFramework.SourceGenerators.Common/diagnostics/CommonDiagnostics.cs
similarity index 93%
rename from GFramework.Godot.SourceGenerators/diagnostics/CommonDiagnostics.cs
rename to GFramework.SourceGenerators.Common/diagnostics/CommonDiagnostics.cs
index 2b7d586..78cd1b8 100644
--- a/GFramework.Godot.SourceGenerators/diagnostics/CommonDiagnostics.cs
+++ b/GFramework.SourceGenerators.Common/diagnostics/CommonDiagnostics.cs
@@ -1,6 +1,6 @@
using Microsoft.CodeAnalysis;
-namespace GFramework.Godot.SourceGenerators.diagnostics;
+namespace GFramework.SourceGenerators.Common.diagnostics;
///
/// 提供通用诊断描述符的静态类
diff --git a/GFramework.SourceGenerators/AnalyzerReleases.Unshipped.md b/GFramework.SourceGenerators/AnalyzerReleases.Unshipped.md
index 9ceb908..325ddf4 100644
--- a/GFramework.SourceGenerators/AnalyzerReleases.Unshipped.md
+++ b/GFramework.SourceGenerators/AnalyzerReleases.Unshipped.md
@@ -5,6 +5,5 @@
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
\ No newline at end of file
diff --git a/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj b/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj
index 86fc3f2..cec2481 100644
--- a/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj
+++ b/GFramework.SourceGenerators/GFramework.SourceGenerators.csproj
@@ -29,6 +29,7 @@
+
@@ -44,12 +45,18 @@
Pack="true"
PackagePath="analyzers/dotnet/cs"
Visible="false"/>
+
+
-
+
+
diff --git a/GFramework.SourceGenerators/GeWuYou.GFramework.SourceGenerators.targets b/GFramework.SourceGenerators/GeWuYou.GFramework.SourceGenerators.targets
index 1bfd5a0..de3165c 100644
--- a/GFramework.SourceGenerators/GeWuYou.GFramework.SourceGenerators.targets
+++ b/GFramework.SourceGenerators/GeWuYou.GFramework.SourceGenerators.targets
@@ -6,6 +6,7 @@
+
diff --git a/GFramework.SourceGenerators/constants/PathContests.cs b/GFramework.SourceGenerators/constants/PathContests.cs
new file mode 100644
index 0000000..9814aab
--- /dev/null
+++ b/GFramework.SourceGenerators/constants/PathContests.cs
@@ -0,0 +1,6 @@
+namespace GFramework.SourceGenerators.constants;
+
+public static class PathContests
+{
+ public const string RootAbstractionsPath = "GFramework.SourceGenerators.Abstractions";
+}
\ No newline at end of file
diff --git a/GFramework.SourceGenerators/diagnostics/CommonDiagnostics.cs b/GFramework.SourceGenerators/diagnostics/CommonDiagnostics.cs
deleted file mode 100644
index 1bd575d..0000000
--- a/GFramework.SourceGenerators/diagnostics/CommonDiagnostics.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.CodeAnalysis;
-
-namespace GFramework.SourceGenerators.diagnostics;
-
-///
-/// 提供通用诊断描述符的静态类
-///
-public static class CommonDiagnostics
-{
- ///
- /// 定义类必须为partial的诊断描述符
- ///
- ///
- /// 诊断ID: GF001
- /// 诊断消息: "Class '{0}' must be declared partial for code generation"
- /// 分类: GFramework.Common
- /// 严重性: Error
- /// 是否启用: true
- ///
- 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
- );
-}
\ No newline at end of file
diff --git a/GFramework.SourceGenerators/enums/EnumExtensionsGenerator.cs b/GFramework.SourceGenerators/enums/EnumExtensionsGenerator.cs
index 9d9b36f..1f23cab 100644
--- a/GFramework.SourceGenerators/enums/EnumExtensionsGenerator.cs
+++ b/GFramework.SourceGenerators/enums/EnumExtensionsGenerator.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Text;
+using GFramework.SourceGenerators.constants;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
@@ -11,7 +12,7 @@ namespace GFramework.SourceGenerators.enums;
public class EnumExtensionsGenerator : IIncrementalGenerator
{
private const string AttributeFullName =
- "GFramework.SourceGenerators.Abstractions.generator.enums.GenerateEnumExtensionsAttribute";
+ $"{PathContests.RootAbstractionsPath}.enums.GenerateEnumExtensionsAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
@@ -35,9 +36,8 @@ public class EnumExtensionsGenerator : IIncrementalGenerator
.Where(symbol => symbol != null)
.Select((symbol, _) =>
{
- var hasAttr = symbol.GetAttributes().Any(ad =>
- ad.AttributeClass?.ToDisplayString() == AttributeFullName ||
- ad.AttributeClass?.ToDisplayString().EndsWith(".GenerateEnumExtensionsAttribute") == true);
+ var hasAttr = symbol!.GetAttributes().Any(ad =>
+ ad.AttributeClass?.ToDisplayString() == AttributeFullName);
return (Symbol: symbol, HasAttr: hasAttr);
})
.Where(x => x.HasAttr)
diff --git a/GFramework.SourceGenerators/logging/LoggerGenerator.cs b/GFramework.SourceGenerators/logging/LoggerGenerator.cs
index fa2b3bf..554ab2a 100644
--- a/GFramework.SourceGenerators/logging/LoggerGenerator.cs
+++ b/GFramework.SourceGenerators/logging/LoggerGenerator.cs
@@ -1,7 +1,8 @@
using System;
using System.Linq;
using System.Text;
-using GFramework.SourceGenerators.diagnostics;
+using GFramework.SourceGenerators.Common.diagnostics;
+using GFramework.SourceGenerators.constants;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -15,7 +16,7 @@ namespace GFramework.SourceGenerators.logging;
[Generator]
public sealed class LoggerGenerator : IIncrementalGenerator
{
- private const string AttributeMetadataName = "GFramework.SourceGenerators.Abstractions.logging.LogAttribute";
+ private const string AttributeMetadataName = $"{PathContests.RootAbstractionsPath}.logging.LogAttribute";
private const string AttributeShortName = "LogAttribute";
private const string AttributeShortNameWithoutSuffix = "Log";
diff --git a/GFramework.SourceGenerators/rule/ContextAwareGenerator.cs b/GFramework.SourceGenerators/rule/ContextAwareGenerator.cs
index 942e58e..d6a8ffb 100644
--- a/GFramework.SourceGenerators/rule/ContextAwareGenerator.cs
+++ b/GFramework.SourceGenerators/rule/ContextAwareGenerator.cs
@@ -1,5 +1,7 @@
using System.Linq;
using System.Text;
+using GFramework.SourceGenerators.Common.diagnostics;
+using GFramework.SourceGenerators.constants;
using GFramework.SourceGenerators.diagnostics;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
@@ -11,7 +13,7 @@ namespace GFramework.SourceGenerators.rule;
public sealed class ContextAwareGenerator : IIncrementalGenerator
{
private const string AttributeMetadataName =
- "GFramework.SourceGenerators.Abstractions.rule.ContextAwareAttribute";
+ $"{PathContests.RootAbstractionsPath}.rule.ContextAwareAttribute";
public void Initialize(IncrementalGeneratorInitializationContext context)
{
diff --git a/GFramework.sln b/GFramework.sln
index a7b836a..76f7d5f 100644
--- a/GFramework.sln
+++ b/GFramework.sln
@@ -18,6 +18,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.Godot.SourceGene
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.SourceGenerators.Tests", "GFramework.SourceGenerators.Tests\GFramework.SourceGenerators.Tests.csproj", "{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GFramework.SourceGenerators.Common", "GFramework.SourceGenerators.Common\GFramework.SourceGenerators.Common.csproj", "{B6511C9A-40E1-4E51-8D1F-18EAFB3C5BFC}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -60,5 +62,9 @@ Global
{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
{BB047F43-6AA0-4EA0-8AE9-E6B9784D9E8E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B6511C9A-40E1-4E51-8D1F-18EAFB3C5BFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B6511C9A-40E1-4E51-8D1F-18EAFB3C5BFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B6511C9A-40E1-4E51-8D1F-18EAFB3C5BFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B6511C9A-40E1-4E51-8D1F-18EAFB3C5BFC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal