dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.02k stars 4.03k forks source link

Test plan for "ref readonly" and related features (7.2) #19216

Closed jcouv closed 5 years ago

jcouv commented 7 years ago

Write a test plan for "ref readonly", "readonly structs", "ref and ref readonly extensions" and "ref ternary"

LDM

Spec

Misc

Ref readonly parameters

Ref readonly returns

Readonly struct

Ref ternary

Ref readonly extension methods

Ref-like types and safety (Span)

Misc

See also

jcouv commented 7 years ago

FYI @VSadov @OmarTawfik I'll start gathering ideas for test plan.

OmarTawfik commented 7 years ago

After talking with @cston, it seems that we need to add tests for both EnC and EE for:

  1. Generating IsReadOnly attribute if needed.
  2. Evaluating ref-readonly-ness from source if necessary.
  3. Overload resolution on such parameters.
  4. Using attributes from referenced assemblies vs generating a new one.

I was going to do that in #18715, but this is getting too big of a PR, so I'll keep it for later.

cc @VSadov @jcouv

tmat commented 7 years ago

Is this doc up-to-date, so I can review it to see what's needed to make the debugging experience good?

tmat commented 7 years ago

Turns out it isn't. Specifically https://github.com/dotnet/csharplang/blob/master/proposals/readonly-ref.md#metadata-representaion.

OmarTawfik commented 7 years ago

@tmat for metadata representation specifically, I've the work to enable that in #18715. Basically, we added a new attribute to the framework (IsReadOnlyAttribute) and we will use that to annotate parameters and return types.

tmat commented 7 years ago

@OmarTawfik So we are not using custom modifiers anywhere? Last time I heard we used a mix. How do we mark local variables that are readonly ref? A specification clarifying these questions would be useful.

OmarTawfik commented 7 years ago

@tmat the plan (in a future PR) is to use modreqs on parameters and return types to break older compilers and other languages from using it (until they support the feature). @VSadov can you please comment on the local variables? is there anything I'm missing?

tmat commented 7 years ago

@OmarTawfik Could you update the spec please?

OmarTawfik commented 7 years ago

@tmat. Yes. I'll send a PR out later.

tmat commented 7 years ago

@OmarTawfik Thanks!

OmarTawfik commented 7 years ago

@jcouv about this part:

ref readonly string M(ref readonly string s = "hello") { return ref s; }. Same with value type. (gives a unsafe-to-escape diagnostic)

The current design doesn't prohibit such scenario. Can you explain?