Skip to content

Commit 27f0740

Browse files
committed
Basic test works. More needed.
1 parent 2d3d153 commit 27f0740

File tree

80 files changed

+15867
-843
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+15867
-843
lines changed

.editorconfig

Lines changed: 189 additions & 189 deletions
Large diffs are not rendered by default.

AStar.Dev.slnx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
</Folder>
6565
<Folder Name="/src/source-generators/">
6666
<Project Path="src\source-generators\AStar.Dev.Annotations\AStar.Dev.Annotations.csproj" Type="Classic C#" />
67+
<Project Path="src\source-generators\AStar.Dev.Source.Generators\AStar.Dev.Source.Generators.csproj" Type="Classic C#" />
6768
<Project Path="src\source-generators\AStar.Dev.SourceGenerators.TestApp\AStar.Dev.SourceGenerators.TestApp.csproj" Type="Classic C#" />
68-
<Project Path="src\source-generators\AStar.Dev.SourceGenerators\AStar.Dev.SourceGenerators.csproj" Type="Classic C#" />
6969
</Folder>
7070
<Folder Name="/src/uis/">
7171
<Project Path="src/uis/AStar.Dev.Web/AStar.Dev.Web.csproj" />
@@ -114,6 +114,9 @@
114114
<Project Path="test/nuget-packages/AStar.Dev.Test.Helpers.Tests.Unit/AStar.Dev.Test.Helpers.Tests.Unit.csproj" />
115115
<Project Path="test/nuget-packages/AStar.Dev.Utilities.Tests.Unit/AStar.Dev.Utilities.Tests.Unit.csproj" />
116116
</Folder>
117+
<Folder Name="/test/source-generators/">
118+
<Project Path="test\source-generators\AStar.Dev.Source.Generators.Tests.Unit\AStar.Dev.Source.Generators.Test.Unit.csproj" Type="Classic C#" />
119+
</Folder>
117120
<Folder Name="/test/test-helpers/">
118121
<Project Path="test/test-helpers/AStar.Dev.TestHelpers/AStar.Dev.TestHelpers.csproj" />
119122
</Folder>

Directory.Build.props

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project>
2-
<PropertyGroup>
3-
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4-
<TargetFramework>net9.0</TargetFramework>
5-
<Nullable>enable</Nullable>
6-
<ImplicitUsings>true</ImplicitUsings>
7-
</PropertyGroup>
2+
<PropertyGroup>
3+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>true</ImplicitUsings>
7+
</PropertyGroup>
88

9-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
11-
<NoWarn>1701;1702;</NoWarn>
12-
</PropertyGroup>
9+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
10+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
11+
<NoWarn>1701;1702;</NoWarn>
12+
</PropertyGroup>
1313

14-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
15-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
16-
<NoWarn>1701;1702;</NoWarn>
17-
</PropertyGroup>
14+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
15+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
16+
<NoWarn>1701;1702;</NoWarn>
17+
</PropertyGroup>
1818
</Project>

src/nuget-packages/AStar.Dev.Infrastructure.FilesDb/AStar.Dev.Infrastructure.FilesDb.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<ItemGroup>
5858
<ProjectReference Include="..\..\source-generators\AStar.Dev.Annotations\AStar.Dev.Annotations.csproj" />
59-
<ProjectReference Include="..\..\source-generators\AStar.Dev.SourceGenerators\AStar.Dev.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
59+
<ProjectReference Include="..\..\source-generators\AStar.Dev.Source.Generators\AStar.Dev.Source.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
6060
<ProjectReference Include="..\AStar.Dev.Infrastructure\AStar.Dev.Infrastructure.csproj"/>
6161
<ProjectReference Include="..\AStar.Dev.Technical.Debt.Reporting\AStar.Dev.Technical.Debt.Reporting.csproj"/>
6262
<ProjectReference Include="..\AStar.Dev.Utilities\AStar.Dev.Utilities.csproj"/>
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFramework>netstandard2.0</TargetFramework>
4-
<LangVersion>preview</LangVersion>
5-
<Nullable>enable</Nullable>
4+
<TargetFramework>net9.0</TargetFramework>
65
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
77
</PropertyGroup>
8-
</Project>
8+
9+
</Project>

src/source-generators/AStar.Dev.Annotations/MapFromAttribute.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace AStar.Dev.Annotations;
2+
3+
public enum Lifetime
4+
{
5+
Singleton,
6+
Scoped,
7+
Transient
8+
}
9+
10+
/// <summary>
11+
/// An attribute used to register a class as a service within a dependency injection container.
12+
/// The attribute allows specifying the service's lifetime, the interface it should be registered against,
13+
/// and whether the concrete type should also be registered as itself.
14+
/// </summary>
15+
/// <param name="lifetime">The required lifetime of the service being registered</param>
16+
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
17+
public sealed class RegisterServiceAttribute(Lifetime lifetime = Lifetime.Scoped) : Attribute
18+
{
19+
/// <summary>
20+
/// Specifies the lifetime of a service when registered in a dependency injection container.
21+
/// </summary>
22+
/// <remarks>
23+
/// Lifetime defines how the service is instantiated and shared within the application:
24+
/// - Singleton: A single instance is created and shared across the entire application.
25+
/// - Scoped: A single instance is created and shared within the same scope, such as a single HTTP request in web applications.
26+
/// - Transient: A new instance is created each time the service is requested.
27+
/// </remarks>
28+
public Lifetime Lifetime { get; } = lifetime;
29+
30+
/// <summary>
31+
/// Specifies the interface or base type that the service should be registered against
32+
/// within the dependency injection container.
33+
/// </summary>
34+
/// <remarks>
35+
/// This property allows for explicitly defining the type the service is associated with,
36+
/// enabling more control over how the service is resolved at runtime. If not specified,
37+
/// the default behavior may vary based on the DI container implementation.
38+
/// </remarks>
39+
public Type? As { get; set; }
40+
41+
/// <summary>
42+
/// Determines whether the concrete type of the service should be registered as itself
43+
/// in addition to any specified service interface.
44+
/// </summary>
45+
/// <remarks>
46+
/// If set to <c>true</c>, the concrete type will be registered in the dependency injection
47+
/// container so that it can be resolved directly. This is useful when the service
48+
/// needs to be resolved by its own type rather than an interface.
49+
/// </remarks>
50+
public bool AsSelf { get; set; } = false;
51+
}

src/source-generators/AStar.Dev.Annotations/ServiceAttribute.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>latest</LangVersion>
6+
<Nullable>enable</Nullable>
7+
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
8+
<IsRoslynComponent>true</IsRoslynComponent>
9+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10+
<IncludeBuildOutput>false</IncludeBuildOutput>
11+
<NoWarn>$(NoWarn);NU5128</NoWarn>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
16+
<PrivateAssets>all</PrivateAssets>
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
</PackageReference>
19+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0"/>
20+
</ItemGroup>
21+
22+
</Project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
namespace AStar.Dev.Source.Generators;
2+
3+
/// <summary>
4+
/// Provides a centralized location for constant values used in the AStar.Dev.Source.Generators library.
5+
/// </summary>
6+
public static class Constants
7+
{
8+
/// <summary>
9+
/// Represents a predefined string indicating the namespace of the source generators within the AStar.Dev.Source.Generators library.
10+
/// </summary>
11+
public const string Namespace = "AStar.Dev.Source.Generators";
12+
13+
/// <summary>
14+
/// Represents a predefined string containing the header comment added to the top of generated source files,
15+
/// indicating that the file is auto-generated by the AStar.Dev.Source.Generators library and should not be manually edited.
16+
/// </summary>
17+
public const string SourceGeneratorHeader = $"""
18+
//----------------------
19+
// <auto-generated>
20+
// Generated by {Namespace}
21+
// Do not edit this file manually. Any changes will be overwritten at the next build.
22+
// </auto-generated>
23+
//----------------------
24+
""";
25+
26+
public const string GeneratedSourceXmlClassHeader = """
27+
/// <summary>
28+
/// Generated class header to quiet the compiler when XML Documentation is generated.
29+
/// This class contains the registration for services tagged with the RegisterService attribute.
30+
/// </summary>
31+
""";
32+
33+
public const string GeneratedSourceXmlHeader = """
34+
/// <summary>
35+
/// Generated method summary to quiet the compiler when XML Documentation is generated.
36+
/// </summary>
37+
""";
38+
}

0 commit comments

Comments
 (0)