Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
378 changes: 189 additions & 189 deletions .editorconfig

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions AStar.Dev.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</Folder>
<Folder Name="/src/modules/usage module/">
<Project Path="src/nuget-packages/AStar.Dev.Api.Usage.Sdk/AStar.Dev.Api.Usage.Sdk.csproj" />
<Project Path="src\nuget-packages\AStar.Dev.Usage.Api.Client.SDK\AStar.Dev.Usage.Api.Client.SDK.csproj" Type="C#" />
<Project Path="src/nuget-packages/AStar.Dev.Usage.Api.Client.SDK/AStar.Dev.Usage.Api.Client.SDK.csproj" Type="C#" />
</Folder>
<Folder Name="/src/nuget-packages/">
<Project Path="src/nuget-packages/AStar.Dev.Api.HealthChecks/AStar.Dev.Api.HealthChecks.csproj" />
Expand All @@ -63,8 +63,9 @@
<Project Path="src/nuget-packages/AStar.Dev.Utilities/AStar.Dev.Utilities.csproj" />
</Folder>
<Folder Name="/src/source-generators/">
<Project Path="src/source-generators/AStar.Dev.SourceGenerators/AStar.Dev.SourceGenerators.csproj" />
<Project Path="src\source-generators\AStar.Dev.Annotations\AStar.Dev.Annotations.csproj" Type="Classic C#" />
<Project Path="src\source-generators\AStar.Dev.Source.Generators\AStar.Dev.Source.Generators.csproj" Type="Classic C#" />
<Project Path="src\source-generators\AStar.Dev.SourceGenerators.TestApp\AStar.Dev.SourceGenerators.TestApp.csproj" Type="Classic C#" />
</Folder>
<Folder Name="/src/uis/">
<Project Path="src/uis/AStar.Dev.Web/AStar.Dev.Web.csproj" />
Expand All @@ -78,9 +79,9 @@
<Project Path="test/AStar.Dev.Tests.Architecture/AStar.Dev.Tests.Architecture.csproj" />
</Folder>
<Folder Name="/test/modules/">
<Project Path="test/modules/AStar.Dev.Database.Updater.Core.Tests.Unit/AStar.Dev.Database.Updater.Core.Tests.Unit.csproj" />
<Project Path="test/modules/AStar.Dev.Database.Updater.Tests.Integration/AStar.Dev.Database.Updater.Tests.Integration.csproj" />
<Project Path="test/modules/AStar.Dev.Database.Updater.Tests.Unit/AStar.Dev.Database.Updater.Tests.Unit.csproj" />
<Project Path="test\modules\AStar.Dev.Database.Updater.Core.Tests.Integration\AStar.Dev.Database.Updater.Core.Tests.Integration.csproj" />
</Folder>
<Folder Name="/test/modules/apis/">
<Project Path="test/modules/apis/AStar.Dev.Admin.Api.Tests.EndToEnd/AStar.Dev.Admin.Api.Tests.EndToEnd.csproj" />
Expand Down Expand Up @@ -113,6 +114,9 @@
<Project Path="test/nuget-packages/AStar.Dev.Test.Helpers.Tests.Unit/AStar.Dev.Test.Helpers.Tests.Unit.csproj" />
<Project Path="test/nuget-packages/AStar.Dev.Utilities.Tests.Unit/AStar.Dev.Utilities.Tests.Unit.csproj" />
</Folder>
<Folder Name="/test/source-generators/">
<Project Path="test\source-generators\AStar.Dev.Source.Generators.Tests.Unit\AStar.Dev.Source.Generators.Test.Unit.csproj" Type="Classic C#" />
</Folder>
<Folder Name="/test/test-helpers/">
<Project Path="test/test-helpers/AStar.Dev.TestHelpers/AStar.Dev.TestHelpers.csproj" />
</Folder>
Expand Down
28 changes: 14 additions & 14 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<Project>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<NoWarn>1701;1702;</NoWarn>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

<ItemGroup>
<ProjectReference Include="..\..\source-generators\AStar.Dev.Annotations\AStar.Dev.Annotations.csproj" />
<ProjectReference Include="..\..\source-generators\AStar.Dev.SourceGenerators\AStar.Dev.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\..\source-generators\AStar.Dev.Source.Generators\AStar.Dev.Source.Generators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\AStar.Dev.Infrastructure\AStar.Dev.Infrastructure.csproj"/>
<ProjectReference Include="..\AStar.Dev.Technical.Debt.Reporting\AStar.Dev.Technical.Debt.Reporting.csproj"/>
<ProjectReference Include="..\AStar.Dev.Utilities\AStar.Dev.Utilities.csproj"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace AStar.Dev.Annotations;

[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class ConfigSectionAttribute(string name) : Attribute
{
public string Name { get; } = name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
namespace AStar.Dev.Annotations;

public enum Lifetime
{
Singleton,
Scoped,
Transient
}

/// <summary>
/// An attribute used to register a class as a service within a dependency injection container.
/// The attribute allows specifying the service's lifetime, the interface it should be registered against,
/// and whether the concrete type should also be registered as itself.
/// </summary>
/// <param name="lifetime">The required lifetime of the service being registered</param>
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public sealed class RegisterServiceAttribute(Lifetime lifetime = Lifetime.Scoped) : Attribute
{
/// <summary>
/// Specifies the lifetime of a service when registered in a dependency injection container.
/// </summary>
/// <remarks>
/// Lifetime defines how the service is instantiated and shared within the application:
/// - Singleton: A single instance is created and shared across the entire application.
/// - Scoped: A single instance is created and shared within the same scope, such as a single HTTP request in web applications.
/// - Transient: A new instance is created each time the service is requested.
/// </remarks>
public Lifetime Lifetime { get; } = lifetime;

/// <summary>
/// Specifies the interface or base type that the service should be registered against
/// within the dependency injection container.
/// </summary>
/// <remarks>
/// This property allows for explicitly defining the type the service is associated with,
/// enabling more control over how the service is resolved at runtime. If not specified,
/// the default behavior may vary based on the DI container implementation.
/// </remarks>
public Type? As { get; set; }

/// <summary>
/// Determines whether the concrete type of the service should be registered as itself
/// in addition to any specified service interface.
/// </summary>
/// <remarks>
/// If set to <c>true</c>, the concrete type will be registered in the dependency injection
/// container so that it can be resolved directly. This is useful when the service
/// needs to be resolved by its own type rather than an interface.
/// </remarks>
public bool AsSelf { get; set; } = false;
}
39 changes: 5 additions & 34 deletions src/source-generators/AStar.Dev.Annotations/StrongIdAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
using System;

namespace AStar.Dev.Annotations;

/// <summary>
/// Represents an attribute that can be used to mark a struct as a strong identifier.
/// </summary>
/// <remarks>
/// This attribute is used to annotate structures with a specific identifier type, typically
/// to signify that the struct is a strongly typed id. The default identifier type is a GUID.
/// </remarks>
/// <param name="idType">
/// The type of the identifier associated with the struct. By default, it is "System.Guid".
/// </param>
/// <param name="guidV7">
/// Indicates whether the GUID used as the identifier for the struct conforms to the version 7 GUID format.
/// </param>
[AttributeUsage(AttributeTargets.Struct)]
public sealed class StrongIdAttribute(string idType = "System.Guid", bool guidV7 = true) : Attribute
public sealed class StrongIdAttribute(string underlying = "System.Guid") : Attribute
{
/// <summary>
/// Gets the type of the identifier associated with a struct marked by the <see cref="StrongIdAttribute"/>.
/// </summary>
/// <remarks>
/// This property returns the string name of the identifier type. By default, it is "System.Guid".
/// The identifier type specifies the type used as an identifier for the struct.
/// </remarks>
public string IdType { get; } = idType;

/// <summary>
/// Indicates whether the GUID used as the identifier for a struct marked by the <see cref="StrongIdAttribute"/>
/// conforms to the version 7 GUID format.
/// Underlying CLR type. Defaults to System.Guid.
/// Examples: "System.Guid", "int", "long", "string".
/// </summary>
/// <remarks>
/// Version 7 GUIDs are designed to facilitate time-based sorting and are a newer standard
/// compared to the traditional random GUIDs (version 4). When this property is set to true,
/// the identifier adopts the version 7 format.
/// </remarks>
public bool GuidV7 { get; } = guidV7;
}
public string Underlying { get; } = underlying;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<IsRoslynComponent>true</IsRoslynComponent>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NoWarn>$(NoWarn);NU5128</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0"/>
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions src/source-generators/AStar.Dev.Source.Generators/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace AStar.Dev.Source.Generators;

/// <summary>
/// Provides a centralized location for constant values used in the AStar.Dev.Source.Generators library.
/// </summary>
public static class Constants
{
/// <summary>
/// Represents a predefined string indicating the namespace of the source generators within the AStar.Dev.Source.Generators library.
/// </summary>
public const string Namespace = "AStar.Dev.Source.Generators";

/// <summary>
/// Represents a predefined string containing the header comment added to the top of generated source files,
/// indicating that the file is auto-generated by the AStar.Dev.Source.Generators library and should not be manually edited.
/// </summary>
public const string SourceGeneratorHeader = $"""
//----------------------
// <auto-generated>
// Generated by {Namespace}
// Do not edit this file manually. Any changes will be overwritten at the next build.
// </auto-generated>
//----------------------
""";

public const string GeneratedSourceXmlClassHeader = """
/// <summary>
/// Generated class header to quiet the compiler when XML Documentation is generated.
/// This class contains the registration for services tagged with the RegisterService attribute.
/// </summary>
""";

public const string GeneratedSourceXmlHeader = """
/// <summary>
/// Generated method summary to quiet the compiler when XML Documentation is generated.
/// </summary>
""";
}
Loading