Repository navigation
Read, write, parse and compare C# 14 extension blocks - #109
Merged
Merged
Conversation
A static class's extension blocks are read from the compiler's grouping and marker types and written as the source declares them, `extension<T>(List<T> list) where T : struct`, with their members under them; the static methods the compiler writes for those members are left out. A receiver only static members use has no name and is written `extension(string)`. The comparison pairs each block member with its receiver, so a member that moves to another block over the same type is a receiver change on that member, and a method that moves from `static int A(this string s)` into a block, or back, is no change: callers compile and run against the same method. Reading System.Private.CoreLib found an old bug: a parameter without a metadata row got a default attribute collection, which has no reader. Extension blocks there have no parameter rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
C# 14 extension blocks were read as the compiler's lowering: a nested
<G>$…type nobody can name and a set of static methods. They are now first-class.Reading and writing.
ApiExtensionmember holds the receiver, type parameters and members of each block.extension<T>(List<T> list) where T : struct, with its members indented under it.extension(string).Comparing. Each block member is paired with its receiver.
static int A(this string s)as a block member, or back, reports no change: callers compile and run against the same method.An older bug. Reading
System.Private.CoreLib(whoseVector128and others have blocks with no parameter rows) turned up a crash inReadParameters: a parameter without a row got a defaultCustomAttributeHandleCollection, which has no reader.Verified:
refreceivers and unnamed receivers. All properties pass: compile, oracle, round trip, split files, self-comparison, mirror.mise run ciis green locally.🤖 Generated with Claude Code