-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test plan for ref fields #59194
Comments
dotnet-issue-labeler
bot
added
Area-Compilers
untriaged
Issues and PRs which have not yet been triaged by a lead
labels
Feb 1, 2022
jcouv
removed
the
untriaged
Issues and PRs which have not yet been triaged by a lead
label
Feb 17, 2022
This was referenced May 3, 2022
This was referenced Jun 28, 2022
This was referenced Jul 21, 2022
This was referenced Jul 29, 2022
Closed
This was referenced Aug 5, 2022
This was referenced Oct 12, 2022
Closed
Test plan contains the following item.
i.e. if I have a method |
We've addressed everything needed for .NET 7 and moved everything else out to separate issues. Closing out the test plan. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Spec: https://github.com/dotnet/csharplang/blob/main/proposals/low-level-struct-improvements.md
Tracking issue in runtime repo: dotnet/runtime#63768
Championed issue: dotnet/csharplang#1147
Guideline for addressing remaining issues:
Compiler
scoped
can only be applied to aref
type or a type that is aref struct
ref
field when runtime feature flag is missing:RefFieldTests.RuntimeFeature
ref
fields are emitted asref
for reference assemblies (no change). Note that our ability to control what old compilers actually do with these fields is somewhat limited. We prefer if it just gives a use site error when the ref field is used, but may not be able to make changes if the behavior does not end up being ideal. (RefFieldTests.RefAssembly)ref assemblies which contain ref fields not consumable by old compilers (even if ref field is private)(not a supported scenario)Test metadata compatibility with previous compiler release (C# and VB)(not a supported scenario)scoped
keyword) Supportscoped
modifier for other local declarations #62039manual test of C++/CLI (can reference local assemblies with ref fields)(known issue, tracked by C++/CLI team)-langversion:11
ref
field declarations in source (also requires RuntimeFeature.ByRefFields)ref
fields from metadata or compilation reference (RefFieldTests.LanguageVersionDiagnostics)-langversion:11
orSystem.Runtime.CompilerServices.RuntimeFeature.ByRefFields
Enable updated escape rules ifSystem.Runtime.CompilerServices.RuntimeFeature.ByRefFields
exists #62131ref
andref readonly
fields forref struct
onlyref
field inclass
,struct
,record
in source No error for ref fields in non-ref structs #62596ref
parameter inrecord
in sourceref
field inclass
orstruct
from metadata for C# and VB Report use-site error using ref field from type other thanref struct
in C# #64682readonly ref
inreadonly ref struct
readonly
methods (RefFieldTests.MethodArgumentsMustMatch_13)readonly ref
emitted asinitonly
ref readonly
emitted withSystem.Runtime.CompilerServices.IsReadOnlyAttribute
ref struct
with aref
field is not consideredunmanaged
stackalloc should be disallowed for structs with ref fields #63104ref
initializer Syntax error parsing field initializer withref
expression #64720ref struct
field initializer safe-to-escape: see #60577 commentref
field modifiersstatic ref
fields disallowedconst ref
fields disallowedvolatile ref
fields disallowedfixed ref
fields disallowedref
auto-properties disallowedref
in object initializers supported:new S { F = ref t }
Support ref field assignment in object initializers #62120ref
field of the containing type: Allow ref field of the containing type #62098_ = s.F;
should throwNullReferenceException
if ref field isnull
- see Record read of ref local even if value is discarded #60910 (comment)scoped
as type name-langversion:10
and earlier for compat-langversion:11
scoped
modifier roundtripped to metadatascoped
considered in overrides and interface implementationscoped
scoped
to be added to aref
orin
parameter, or to aref struct
parameter Allow addingscoped
or removing[UnscopedRef]
for override, interface implementation, or delegate conversion #62340[UnscopedRef]
to be removed from anout
parameter or from aref
parameter of aref struct
Allow addingscoped
or removing[UnscopedRef]
for override, interface implementation, or delegate conversion #62340scoped
included in inferred delegate types:var f = (R x, scoped R y) => x;
scoped
parametersref
,in
,out
scoped this
in extension methodparams scoped
scoped
localsref
,ref readonly
const
foreach
iteration variableusing
variableout
declarationvar
andref var
scoped
modifier with scoped/unscoped initializerScopedRefAttribute
changes scoped default when targeting:ref
toref struct
parametersout
parametersScopedRefAttribute
disallowed in source Report error if ScopedRefAttribute is used directly in source #62124UnscopedRefAttribute
:[UnscopedRef]
cannot implement an interface member Report error implementing unannotated interface member with[UnscopedRef]
member #64508ref
fieldsscoped
,scoped ref
,ref scoped
parameters and localsstruct
this
is implicitlyscoped ref T
out
parameters are implicitlyscoped out
scoped
parameters affect argument contribution for ref-safe-to-escape and safe-to-escape of method invocationscoped
parameters affect "method arguments must match" rule (arg "mixing")scoped
Report warning for unannotated parameters that could be markedscoped
#64344SymbolDisplay
ref
qualifier and ref custom modifiersscoped
andscoped ref
for parameters and localsout
parameters (should we show the implicitscoped
?)out
parameter by referencescoped ref
orscoped in
cannot be passed as an argument to an ordinaryref
/in
parameter.ref struct
(RefFieldTests.ReturnRefFieldByValue)ref
/ref readonly
(RefFieldTests.ReturnRefFieldByRef_03)ref
parameter whose type isref struct
(RefFieldTests.MethodArgumentsMustMatch_03)ref
fields which are not explicitlyref
-assigned before all usages and returns. Auto-default ref fields with a null ref-assignment #63065void F([UnscopedRef] scoped ref int i) { }
(RefFieldTests.UnscopedScoped)-langversion:11
or RuntimeFeature.ByRefFields (i.e. NET 7) (RefFieldTests.UseUpdatedEscapeRules)required
ref fields (RefFieldTests.RequiredField_01, _02)RefFieldTests.InitRefField_UnsafeNullRef
Public API
ScopedTypeSyntax
IFieldSymbol.RefKind
andRefCustomModifiers
IParameterSymbol.ScopedKind
ILocalSymbol.ScopedKind
SymbolDisplay*Options
UpdateSymbolDisplay
to includescoped
for parameters and locals #63208ScopedRefAttribute
Productivity
scoped
scoped
scoped
attributes (extracted to MetadataAsSource should show scoped modifiers #64906)out
parameters (should we show the implicitscoped
?) (extracted to MetadataAsSource should show scoped modifiers #64906)ref
fieldref
field Test ref fields in the Expression Evaluator #62156Open questions
scoped
modifier whenref
orref struct
value cannot escape?scoped out
sinceout
parameters are implicitlyscoped
? Answer: No, unless we hear further interest in such behavior.[ScopedRef]
attribute in metadata for anout
parameter? The spec says it's implicitlyscoped out
. Answer: Don't emit ScopedRef when parameters are implicitly scoped.The text was updated successfully, but these errors were encountered: