-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-CompilersFeature - Ref Readonly Parameters`ref readonly` parameters`ref readonly` parametersFeature Request
Milestone
Description
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
inbut not forref readonly) - disallow
ref readonlyin dynamic invocation
- Parse
ref readonly- permutations and combinations (
RefReadonlyTestsparsing tests) - allowed on parameters
- in cref
- permutations and combinations (
- 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 readonlyin combination with various attributes-
[IsReadOnly](generally disallowed in source, seeManuallyAppliedAttributes_IsReadOnly) -
[In],[Out](seeManuallyAppliedAttributes_InOut) -
[RequiresLocation](disallow in source, seeManuallyAppliedAttribute; hide on symbols)
-
- Disallow in expression trees (post-merge)
- decoding from metadata
- misplaced
[RequiresLocation](seeReturnParameter) - priority order decoding
- misplaced
- Default parameter values (warn)
- extension
thisparameter (seeRefReadonlyWithThis_*) - dynamic binding (blocked)
- Argument matching
- LangVer-conditional for
refargument oninparameter - 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
- LangVer-conditional for
- 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
thisparameter for extension methods)
- invocations, indexer access (see
- 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
RefKindon symbol - SyntaxNormalizer
- cref
- new
- 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
RequiresLocationAttributeto 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.Inand check ifRefKind.RefReadonlyParameterneeds to be handled there as well - document any compat breaks
- update feature status
IDE
- colorization and formatting
- QuickInfo
-
scoped,readonlycompletion - F1/Help
- interface implementation and override generation
- cref
- EE/EnC (manual smoketest)
Sergio0694, kyoyama-kazusa and hamarb123
Metadata
Metadata
Labels
Area-CompilersFeature - Ref Readonly Parameters`ref readonly` parameters`ref readonly` parametersFeature Request