You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated type expressions still lose keyword identifier escapes #7674
Generated C# type expressions outside attribute constructor names still use a display format that omits keyword escapes. For example, a type in namespace @event can be emitted as typeof(global::event.Payload), which is invalid C#. Valid keyword identifiers should remain escaped wherever the source generator emits C# expressions.
Reproduction
Add a generator regression case with namespace @event { public class Payload {} } and an attribute with a System.Type named argument set to typeof(@event.Payload). Exercise the metadata-backed attribute writer and compile the generated initializer.
At main commit 885ee5f, src/TUnit.Core.SourceGenerator/CodeGenerators/Formatting/TypedConstantFormatter.cs:49 emits typeof({type.GloballyQualified()}). TypeExtensions.GloballyQualified uses DisplayFormats.FullyQualifiedGenericWithGlobalPrefix, which omits EscapeKeywordIdentifiers. Other expression emitters, including InstanceFactoryGenerator, use the same helper. This is a source inspection finding; this additional reproduction has not been executed.
Expected and actual
Generated expressions should preserve @event; the current formatter drops the escape. Keep raw runtime reflection names unchanged.
Proposal
Audit C# expression emission sites and add compilation regressions for keyword namespaces and type names, including attribute type values. Distinguish expression formatting from runtime-name formatting rather than changing every raw-name consumer.
Follow-up to the non-blocking Claude review on #7669; that PR fixes attribute constructor names only. Please preserve keyword escapes in the remaining generated C# type expressions.
Activity
Disambiguate escaped test source names (#7674)
Fix keyword property-injection identifiers (#7674)
Preserve keyword escapes in generated type expressions (#7675)