-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything featureResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented
Milestone
Description
Version Used:
.NET SDK:
Version: 10.0.100-preview.4.25258.110
Commit: c22dcd0c7a
Workload version: 10.0.100-manifests.e9b6aa6e
MSBuild version: 17.15.0-preview-25258-110+c22dcd0c7
Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100-preview.4.25258.110\
Microsoft Visual Studio Community 2022 (64-bit) - Preview Version 17.14.0 Preview 7.0
Steps to Reproduce:
- Create any project type
- Set net10.0 and preview
- Write an
extensionblock method that requiresextern, something like:
extension(System.IO.MemoryStream stream)
{
[UnsafeAccessor(UnsafeAccessorKind.Field)]
public extern ref byte[] _buffer();
}
- Attempt a build.
Diagnostic Ids:
CS0106: The modifier 'extern' is not valid for this item
CS0501: 'Program.extension(MemoryStream)._buffer()' must declare a body because it is not marked abstract, extern, or partial
Expected Behavior: The code compiles.
Actual Behavior: extern is complained about and the build fails. I'm assuming it's because it's not technically static anymore, but even adding it doesn't help (and would prevent use of the extension parameter if it did).
I'm assuming this is the case for a few more "niche" features in the context of extensions. (And yeah, granted, the example I chose is a bit silly.)
"Legacy" implementation method syntax compiles fine:
[UnsafeAccessor(UnsafeAccessorKind.Field)]
public static extern ref byte[] _buffer(this System.IO.MemoryStream stream);
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-CompilersFeature - Extension EverythingThe extension everything featureThe extension everything featureResolution-FixedThe bug has been fixed and/or the requested behavior has been implementedThe bug has been fixed and/or the requested behavior has been implemented