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
10 changes: 8 additions & 2 deletions src/Linqraft.SourceGenerator/SelectExprInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ internal abstract record SelectExprInfo
// Get the namespace where DTOs will be placed
protected abstract string GetDtoNamespace();

// Get expression type string (for documentation)
protected abstract string GetExprTypeString();

// Get the full name for a nested DTO class (can be overridden for nested class support)
protected virtual string GetNestedDtoFullName(string nestedClassName)
{
Expand Down Expand Up @@ -132,10 +135,13 @@ protected string GetLocationId()

protected string GenerateMethodHeaderPart(string dtoName, InterceptableLocation location)
{
var typeString = GetExprTypeString();
var displayLocationRaw = location.GetDisplayLocation();
var locationFileOnly = displayLocationRaw.Split(['/', '\\']).Last();
return $"""
/// <summary>
/// generated select expression method {dtoName} <br/>
/// at {location.GetDisplayLocation()}
/// generated select expression method {dtoName} ({typeString}) <br/>
/// at {locationFileOnly}
/// </summary>
{location.GetInterceptsLocationAttributeSyntax()}
""";
Expand Down
3 changes: 3 additions & 0 deletions src/Linqraft.SourceGenerator/SelectExprInfoAnonymous.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ protected override DtoStructure GenerateDtoStructure()
// Anonymous types don't generate separate DTOs, but return caller namespace for consistency
protected override string GetDtoNamespace() => CallerNamespace;

// Get expression type string (for documentation)
protected override string GetExprTypeString() => "anonymous";

// Generate SelectExpr method
protected override string GenerateSelectExprMethod(
string dtoName,
Expand Down
9 changes: 4 additions & 5 deletions src/Linqraft.SourceGenerator/SelectExprInfoExplicitDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ protected override string GetClassName(DtoStructure structure) =>
// Get the namespace where DTOs will be placed
protected override string GetDtoNamespace() => GetActualDtoNamespace();

// Get expression type string (for documentation)
protected override string GetExprTypeString() => "explicit";

// Get the full name for a nested DTO class (including parent classes)
protected override string GetNestedDtoFullName(string nestedClassName)
{
Expand Down Expand Up @@ -169,11 +172,7 @@ InterceptableLocation location
var id = GetUniqueId();
var methodDecl =
$"public static {returnTypePrefix}<TResult> SelectExpr_{id}<TIn, TResult>(";
sb.AppendLine($"/// <summary>");
sb.AppendLine($"/// generated select expression method {dtoName} (explicit)");
sb.AppendLine($"/// at {location.GetDisplayLocation()}");
sb.AppendLine($"/// </summary>");
sb.AppendLine($"{location.GetInterceptsLocationAttributeSyntax()}");
sb.AppendLine(GenerateMethodHeaderPart(dtoName, location));
sb.AppendLine($"{methodDecl}");
sb.AppendLine($" this {returnTypePrefix}<TIn> query,");
sb.AppendLine($" Func<TIn, object> selector) where TResult : {dtoFullName}");
Expand Down
3 changes: 3 additions & 0 deletions src/Linqraft.SourceGenerator/SelectExprInfoNamed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ protected override string GetParentDtoClassName(DtoStructure structure) =>
protected override string GetDtoNamespace() =>
SourceType.ContainingNamespace?.ToDisplayString() ?? CallerNamespace;

// Get expression type string (for documentation)
protected override string GetExprTypeString() => "predefined";

protected override string GenerateSelectExprMethod(
string dtoName,
DtoStructure structure,
Expand Down