dotnet-cqrs/Svrnty.CQRS.Grpc.Generators/Models/QueryInfo.cs
Jean-Philippe Brule 179b06374d fix: improve gRPC source generator type mapping and property naming
- Add ProtoPropertyName to PropertyInfo for correct proto property naming
- Fix ToPascalCaseHelper to match Grpc.Tools naming (e.g., value_per100g → ValuePer100G)
- Add IsResultNullable and ResultTypeWithoutNullable to QueryInfo
- Fix IsPrimitiveType to correctly handle nullable complex types
- Add GetCollectionElementType helper (excludes strings from collection detection)
- Use AddRange pattern for repeated/collection fields in proto messages
- Add explicit Analyzer reference in props for reliable source generator loading
- Handle null cases in single complex type response mapping
- Fix collection properties in complex results with proper nested type mapping

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-25 10:47:05 -05:00

56 lines
2.2 KiB
C#

using System.Collections.Generic;
namespace Svrnty.CQRS.Grpc.Generators.Models
{
public class QueryInfo
{
public string Name { get; set; }
public string FullyQualifiedName { get; set; }
public string Namespace { get; set; }
public List<PropertyInfo> Properties { get; set; }
public string ResultType { get; set; }
public string ResultFullyQualifiedName { get; set; }
public string HandlerInterfaceName { get; set; }
public List<PropertyInfo> ResultProperties { get; set; }
public bool IsResultPrimitiveType { get; set; }
/// <summary>
/// True if the result type is a collection (List, IEnumerable, etc.)
/// </summary>
public bool IsResultCollection { get; set; }
/// <summary>
/// The element type name if IsResultCollection is true
/// </summary>
public string ResultElementType { get; set; }
/// <summary>
/// The fully qualified element type name if IsResultCollection is true
/// </summary>
public string ResultElementTypeFullyQualified { get; set; }
/// <summary>
/// True if the result type is nullable (ends with ? or is Nullable<T>)
/// </summary>
public bool IsResultNullable { get; set; }
/// <summary>
/// The result type name without the nullable annotation (e.g., "CnfFoodDetailItem" instead of "CnfFoodDetailItem?")
/// </summary>
public string ResultTypeWithoutNullable { get; set; }
public QueryInfo()
{
Name = string.Empty;
FullyQualifiedName = string.Empty;
Namespace = string.Empty;
Properties = new List<PropertyInfo>();
ResultType = string.Empty;
ResultFullyQualifiedName = string.Empty;
HandlerInterfaceName = string.Empty;
ResultProperties = new List<PropertyInfo>();
IsResultPrimitiveType = false;
IsResultCollection = false;
ResultElementType = string.Empty;
ResultElementTypeFullyQualified = string.Empty;
IsResultNullable = false;
ResultTypeWithoutNullable = string.Empty;
}
}
}