You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docfx.json
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -791,9 +791,9 @@
791
791
"_csharplang/proposals/csharp-13.0/ref-struct-interfaces.md": "This proposal provides features that enable interface authors to allow `ref struct` types to implement a particular interface",
792
792
"_csharplang/proposals/csharp-13.0/partial-properties.md": "This proposal provides for partial properties and indexers, allowing the definition of a property or indexer to be split across multiple parts.",
793
793
"_csharplang/proposals/csharp-13.0/overload-resolution-priority.md": "This proposal introduces a new attribute, `OverloadResolutionPriorityAttribute`, that can be applied to methods to influence overload resolution.",
794
-
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "Learn about any breaking changes since the initial release of C# 10",
795
-
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "Learn about any breaking changes since the initial release of C# 11",
796
-
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "Learn about any breaking changes since the initial release of C# 12",
794
+
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "Learn about any breaking changes since the initial release of C# 10 and included in C# 11",
795
+
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "Learn about any breaking changes since the initial release of C# 11 and included in C# 12",
796
+
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "Learn about any breaking changes since the initial release of C# 12 and included in C# 13",
797
797
"_vblang/spec/introduction.md": "This chapter provides and introduction to the Visual Basic language.",
798
798
"_vblang/spec/lexical-grammar.md": "This chapter defines the lexical grammar for Visual Basic.",
799
799
"_vblang/spec/preprocessing-directives.md": "This chapter defines the preprocessing directives allowed in Visual Basic",
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/compiler-messages/inline-array-errors.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ f1_keywords:
16
16
- "CS9183"
17
17
- "CS9184"
18
18
- "CS9189"
19
+
- "CS9259"
19
20
helpviewer_keywords:
20
21
- "CS9164"
21
22
- "CS9165"
@@ -31,7 +32,8 @@ helpviewer_keywords:
31
32
- "CS9183"
32
33
- "CS9184"
33
34
- "CS9189"
34
-
ms.date: 11/02/2023
35
+
- "CS9259"
36
+
ms.date: 11/06/2024
35
37
---
36
38
# Resolve errors and warnings with inline array declarations
37
39
@@ -54,6 +56,7 @@ That's by design. The text closely matches the text of the compiler error / warn
54
56
-[**CS9183**](#conversions-to-span): *Inline array conversion operator will not be used for conversion from expression of the declaring type.*
55
57
-[**CS9184**](#inline-array-declaration): *'Inline arrays' language feature is not supported for inline array types with element field which is either a '`ref`' field, or has type that is not valid as a type argument.*
56
58
-[**CS9189**](#element-access): *`foreach` statement on an inline array of type is not supported*
59
+
-[**CS9259**](#inline-array-declaration): *Attribute <xref:System.Runtime.CompilerServices.InlineArrayAttribute?displayProperty=fullName> cannot be applied to a record struct.*
57
60
58
61
## Inline array declaration
59
62
@@ -64,6 +67,7 @@ You declare inline arrays as a `struct` type with a single field, and an attribu
64
67
-**CS9169**: *Inline array struct must declare one and only one instance field which must not be a ref field.*
65
68
-**CS9180**: *Inline array element field cannot be declared as required, readonly, volatile, or as a fixed size buffer.*
66
69
-**CS9184**: *'Inline arrays' language feature is not supported for inline array types with element field which is either a '`ref`' field, or has type that is not valid as a type argument.*
70
+
-**CS9259**: *Attribute <xref:System.Runtime.CompilerServices.InlineArrayAttribute?displayProperty=fullName> cannot be applied to a record struct.*
67
71
68
72
To fix these arrays, ensure the following are true:
69
73
@@ -72,6 +76,7 @@ To fix these arrays, ensure the following are true:
72
76
- The enclosing `struct` has a single instance field, and that instance field is not a `ref` field.
73
77
- The single instance field is not a fixed size buffer.
74
78
- The single instance field doesn't include the `required`, `volatile`, or `readonly` modifiers.
79
+
- Remove the `record` modifier from your inline array declaration.
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/compiler-messages/ref-modifiers-errors.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,6 +66,7 @@ f1_keywords:
66
66
- "CS9199"
67
67
- "CS9200"
68
68
- "CS9201"
69
+
- "CS9265"
69
70
helpviewer_keywords:
70
71
- "CS0192"
71
72
- "CS0199"
@@ -131,7 +132,8 @@ helpviewer_keywords:
131
132
- "CS9199"
132
133
- "CS9200"
133
134
- "CS9201"
134
-
ms.date: 11/02/2023
135
+
- "CS9265"
136
+
ms.date: 11/06/2024
135
137
---
136
138
# Errors and warnings associated with reference parameters, variables, and returns
137
139
@@ -207,6 +209,7 @@ The following warnings are generated when reference variables are used incorrect
207
209
-[**CS9198**](#reference-variable-restrictions): *Reference kind modifier of parameter doesn't match the corresponding parameter in target.*
208
210
-[**CS9200**](#reference-variable-restrictions): *A default value is specified for `ref readonly` parameter, but `ref readonly` should be used only for references. Consider declaring the parameter as `in`.*
209
211
-[**CS9201**](#reference-variable-restrictions): *Ref field should be ref-assigned before use.*
212
+
-[**CS9265**](#reference-variable-restrictions): *Field is never ref-assigned to, and will always have its default value (null reference)*
210
213
211
214
These errors and warnings follow these themes:
212
215
@@ -261,6 +264,7 @@ The following warnings indicate that a reference variable shouldn't be used, and
261
264
-**CS9198**: *Reference kind modifier of parameter doesn't match the corresponding parameter in target.*
262
265
-**CS9200**: *A default value is specified for `ref readonly` parameter, but `ref readonly` should be used only for references. Consider declaring the parameter as `in`.*
263
266
-**CS9201**: *Ref field should be ref-assigned before use.*
267
+
-**CS9265**: *Field is never ref-assigned to, and will always have its default value (null reference)*
264
268
265
269
To fix the error, remove the reference variable where it isn't allowed:
266
270
@@ -277,6 +281,7 @@ To fix the error, remove the reference variable where it isn't allowed:
277
281
- Methods attributed with <xref:System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute?displayProperty=nameWithType> can't use reference parameters.
278
282
- A Windows runtime event can't be passed as a reference variable.
279
283
- A `ref readonly` parameter can't have the <xref:System.Runtime.InteropServices.OutAttribute?displayProperty=nameWithType> applied to it in remoting API.
284
+
- Initialize a `ref` field in the constructor or as a field initializer.
Copy file name to clipboardExpand all lines: docs/csharp/language-reference/compiler-messages/ref-struct-errors.md
+6-1Lines changed: 6 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ f1_keywords:
15
15
- "CS9245"
16
16
- "CS9246"
17
17
- "CS9247"
18
+
- "CS9267"
18
19
helpviewer_keywords:
19
20
- "CS8343"
20
21
- "CS8344"
@@ -29,7 +30,8 @@ helpviewer_keywords:
29
30
- "CS9245"
30
31
- "CS9246"
31
32
- "CS9247"
32
-
ms.date: 07/30/2024
33
+
- "CS9267"
34
+
ms.date: 11/06/2024
33
35
---
34
36
# Errors and warnings associated with `ref struct` types
35
37
@@ -46,6 +48,7 @@ ms.date: 07/30/2024
46
48
-[**CS9245**](#ref-struct-interface-implementations): *Type cannot implement interface member for `ref struct` type.*
47
49
-[**CS9246**](#ref-struct-interface-implementations): *A non-virtual instance interface member cannot be accessed on a type parameter that allows ref struct.*
48
50
-[**CS9247**](#ref-struct-interface-implementations): *foreach statement cannot operate on enumerators of type because it is a type parameter that allows ref struct and it is not known at compile time to implement `IDisposable`.*
51
+
-[**CS9267**](#ref-struct-interface-implementations): *Element type of an iterator may not be a ref struct or a type parameter allowing ref structs*
49
52
50
53
## ref safety violations
51
54
@@ -74,6 +77,7 @@ Violating any of these rules produces one of the listed errors. If you intended
74
77
-**CS9245**: *Type cannot implement interface member for `ref struct` type.*
75
78
-**CS9246**: *A non-virtual instance interface member cannot be accessed on a type parameter that allows ref struct.*
76
79
-**CS9247**: *foreach statement cannot operate on enumerators of type because it is a type parameter that allows ref struct and it is not known at compile time to implement `IDisposable`.*
80
+
-**CS9267**: *Element type of an iterator may not be a ref struct or a type parameter allowing ref structs*
77
81
78
82
Prior to C# 13, [`ref struct`](../builtin-types/ref-struct.md) types can't implement interfaces; the compiler generates *CS8343*. Beginning with C# 13, `ref struct` types can implement interfaces, subject to the following rules:
79
83
@@ -84,3 +88,4 @@ Beginning with C# 13, a `ref struct` can be used as a type argument for a generi
84
88
85
89
- A `ref struct` is used as a type argument, the type parameter *must* have the `allows ref struct` anti-constraint.- The `allows ref struct` anti-constraint must be last in the `where` clause for that parameter
86
90
- Uses of instances the type parameter must obey ref safety rules.
91
+
- A `ref struct` or a type argument that can be a `ref struct` type can't be used as the element type for an [iterator method](../statements/yield.md).
0 commit comments