Skip to content

Source generator fails with entities marked with '@' #207

@buraktamturk

Description

@buraktamturk

Hello,

event is a reserved keyword in c# and because of that we were using at symbol in front of the entity.

public static class EventExtensions
{    
    [Projectable(NullConditionalRewriteSupport = NullConditionalRewriteSupport.Rewrite)]
    public static Event ToEvent(this @event a) => new Event
    {
        id = a.id,
        name = a.name,
        branch = a.branch.ToBranch(),
        logo = a.logo?.ToLogo(),
        rooms = a.rooms
            .Select(a => a.ToRoomBasic())
            .ToList(),
        start_at = a.start_at,
        created_at = a.created_at,
        updated_at = a.updated_at
    };
}

This was working with 4.0.0-preview.4

We have updated the project from .NET 9 to 10 and Projectables to 6.0.4 and now this code causes the source generator to fail and exception on runtime.

exception on runtime:

Unable to resolve generated expression for ProjectName.Query.Projections.UserExtensions.ToUser

warning on build time:

2>CSC: Warning CS8785 : Generator 'ProjectionExpressionGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ArgumentException' with message 'The hintName 'ProjectName_Query_Projections_EventExtensions_ToEvent_P0_ProjectName_Storage_@event.g.cs' contains an invalid character '@' at position 75. (Parameter 'hintName')'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions