dotnet / dotnet/roslyn

Support for new extension members in CSharpScript

Open
#84,190 2 comments 0 reactions 0 assignees View on GitHub
Area-Compilers Feature - Extension Everything
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

CSharpScript will need some support for the new extension members before an extension can be used in scripting.

Currently if you submit code like

```cs
extension(string)
{
public static string Hello => "Hello!";
}
```

It will end up with

```
error CS9283: Extensions must be declared in a top-level, non-generic, static class.
```

because CSharpScript always define members in a nested class `Submission##`.

I think https://github.com/dotnet/roslyn/pull/3472 needs to be done for extension members as well.

This is also blocking https://github.com/waf/CSharpRepl/issues/489

Contributor guide

Open the contributing guide

Research direction

Start with CSharpScript and compare the requested extension-member support with the referenced Roslyn pull request 3472. Reproduce the extension(string) sample and trace why members are emitted in the nested Submission## class. Done means the sample no longer produces CS9283 and the blocking CSharpRepl issue can proceed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.