Skip to content

Test Plan: ref readonly #68056

@jaredpar

Description

@jaredpar

Proposal: dotnet/csharplang#6010
Speclet: https://github.com/dotnet/csharplang/blob/main/proposals/csharp-12.0/ref-readonly-parameters.md

Compiler

  • Spec
    • Call out indexers
    • Operators (disallow, made sense for in but not for ref readonly)
    • disallow ref readonly in dynamic invocation
  • Parse ref readonly
    • permutations and combinations (RefReadonlyTests parsing tests)
    • allowed on parameters
    • in cref
  • Bind, emit and roundtrip parameter declarations
    • Methods, lambdas, local functions, delegates, constructors, primary constructor, function pointers, indexers
    • operators (post-merge)
    • LangVer check on parameter modifiers
    • modreq, attributes
    • Emit RequiresLocation
    • Disallow ref readonly in combination with various attributes
      • [IsReadOnly] (generally disallowed in source, see ManuallyAppliedAttributes_IsReadOnly)
      • [In], [Out] (see ManuallyAppliedAttributes_InOut)
      • [RequiresLocation] (disallow in source, see ManuallyAppliedAttribute; hide on symbols)
    • Disallow in expression trees (post-merge)
    • decoding from metadata
      • misplaced [RequiresLocation] (see ReturnParameter)
      • priority order decoding
    • Default parameter values (warn)
    • extension this parameter (see RefReadonlyWithThis_*)
    • dynamic binding (blocked)
  • Argument matching
    • LangVer-conditional for ref argument on in parameter
    • method group conversion
    • function type inference (see MethodGroupComparer_*)
    • OHI (warn on overriding/hiding/implementing with different ref-ness)
    • partial methods (must match strictly, see PartialMembers_*)
    • interceptors
  • Bind and emit
    • invocations, indexer access (see Invocation_*, RefReadonlyParameter_Indexer_*)
    • operator
    • LangVer check (behave like old compiler, ie. treat as ref)
    • Check argument value kind during argument coercion (ok for lvalue but warn for rvalue)
    • Warn for no modifier (except on this parameter for extension methods)
  • Enforce readonliness
    • Mutable struct with a readonly and a non-readonly member - call the readonly member (no silent copy) and vice versa
  • Public API:
    • new RefKind
    • IOperation
    • symbol display
    • check GetSymbolInfo and RefKind on symbol
    • SyntaxNormalizer
    • cref
  • Synthesized usages of ref parameters? Maybe in interpolated strings?
  • (readonly) refs, ref structs, readonly structs, readonly members
  • scoped, UnscopedRef

General

  • add to compiler test plan
  • compile runtime
  • compile VS
  • Add RequiresLocationAttribute to BCL (tracked by [API Proposal]: RequiresLocationAttribute (supporting ref readonly parameters) runtime#85910)
  • VB should be able to consume by-ref, except for virtual (since those involve modreq). See what we did for in. Override in VB should be disallowed
  • Let F# know
  • Notify managed C++ team for new modopt, but should be fine (they should tolerate/ignore) (Jared)
  • go over usages of RefKind.In and check if RefKind.RefReadonlyParameter needs to be handled there as well
  • document any compat breaks
  • update feature status

IDE

  • colorization and formatting
  • QuickInfo
  • scoped, readonly completion
  • F1/Help
  • interface implementation and override generation
  • cref
  • EE/EnC (manual smoketest)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions