Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
docs(mocks): note @-prefix legitimacy for GetWrapperName safeName
Extend the GetWrapperName comment to clarify that safeName may
legitimately start with '@' when the member name is a reserved
keyword routed through EscapeIdentifier, and that the resulting
"@event_someMethod_M0_MockCall" form is valid C#.
  • Loading branch information
thomhurst committed Apr 23, 2026
commit b296be2cd4818bd3edd55a143d22d8159bcce653
4 changes: 4 additions & 0 deletions TUnit.Mocks.SourceGenerator/Builders/MockMembersBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ private static bool ShouldGenerateTypedWrapper(MockMemberModel method, bool hasE
// "event" or "class", it appears only as a non-terminal substring of a larger token, which is
// a valid C# identifier. Escaping (via EscapeIdentifier) is only required when the name would
// stand alone as a complete identifier in the emitted source.
// Note: safeName itself may legitimately start with '@' (when the member name is a reserved
// keyword and GetSafeMemberName routed it through EscapeIdentifier), yielding e.g.
// "@event_someMethod_M0_MockCall". This is valid C#: the '@' prefix applies to the entire
// compound identifier, and the resulting token after '@' is not itself a keyword.
private static string GetWrapperName(string safeName, MockMemberModel method)
=> $"{safeName}_{method.Name}_M{method.MemberId}_MockCall";

Expand Down
Loading