Skip to content

Commit 188211e

Browse files
committed
Use the preferred terms
Use the preferred terms for memory safety.
1 parent 0df3ba1 commit 188211e

14 files changed

Lines changed: 27 additions & 25 deletions

File tree

docfx.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,7 @@
648648
"_csharplang/proposals/collection-expression-arguments.md": "Collection expression arguments",
649649
"_csharplang/proposals/unions.md": "Unions",
650650
"_csharplang/proposals/closed-hierarchies.md": "Closed hierarchies",
651+
"_csharplang/proposals/unsafe-evolution.md": "Memory safety",
651652
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 7.md": "C# compiler breaking changes since C# 10",
652653
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 8.md": "C# compiler breaking changes since C# 11",
653654
"_roslyn/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md": "C# compiler breaking changes since C# 12",
@@ -732,6 +733,7 @@
732733
"_csharplang/proposals/collection-expression-arguments.md": "This proposal introduces collection expression arguments.",
733734
"_csharplang/proposals/unions.md": "This proposal describes union types and union declarations. Unions allow expressing values from a closed set of types with exhaustive pattern matching.",
734735
"_csharplang/proposals/closed-hierarchies.md": "This proposal describes closed class hierarchies. A closed class restricts derivation to its declaring assembly, enabling exhaustive `switch` expressions over its direct descendants.",
736+
"_csharplang/proposals/unsafe-evolution.md": "This proposal describes the evolution of memory safety in C#. It ties the `unsafe` context to operations that access unmanaged memory, rather than to the existence of pointer types.",
735737
"_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",
736738
"_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",
737739
"_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",

docs/csharp/language-reference/keywords/unsafe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ unsafe
4141
To compile unsafe code, you must specify the [**AllowUnsafeBlocks**](../compiler-options/language.md#allowunsafeblocks) compiler option. The common language runtime can't verify unsafe code.
4242

4343
> [!NOTE]
44-
> Beginning with C# 15, the [unsafe evolution](../unsafe-code.md#unsafe-evolution-preview) preview feature narrows the operations that require an `unsafe` context. Creating a pointer, the `fixed` statement, and converting a `stackalloc` to a pointer no longer require an `unsafe` context. Only operations that access the pointed-to memory, such as pointer indirection, do. A later preview also changes `unsafe` on a member to mark it as *requires-unsafe*, so callers must use the member from an `unsafe` context.
44+
> Beginning with C# 15, the [memory safety](../unsafe-code.md#memory-safety-preview) preview feature narrows the operations that require an `unsafe` context. Creating a pointer, the `fixed` statement, and converting a `stackalloc` to a pointer no longer require an `unsafe` context. Only operations that access the pointed-to memory, such as pointer indirection, do. A later preview also changes `unsafe` on a member to mark it as *requires-unsafe*, so callers must use the member from an `unsafe` context.
4545
4646
## Example
4747

docs/csharp/language-reference/operators/pointer-related-operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ For information about pointer types, see [Pointer types](../unsafe-code.md#point
4141
> Any operation with pointers requires an [unsafe](../keywords/unsafe.md) context. You must compile the code that contains unsafe blocks with the [**AllowUnsafeBlocks**](../compiler-options/language.md#allowunsafeblocks) compiler option.
4242
4343
> [!NOTE]
44-
> Beginning with C# 15, the [unsafe evolution](../unsafe-code.md#unsafe-evolution-preview) preview feature lets you use the address-of `&` operator outside an `unsafe` context. The pointer indirection, member access, and element access operators that read or write the pointed-to memory still require an `unsafe` context.
44+
> Beginning with C# 15, the [memory safety](../unsafe-code.md#memory-safety-preview) preview feature lets you use the address-of `&` operator outside an `unsafe` context. The pointer indirection, member access, and element access operators that read or write the pointed-to memory still require an `unsafe` context.
4545
4646
## <a name="address-of-operator-"></a> Address-of operator &amp;
4747

docs/csharp/language-reference/operators/sizeof.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The size of the types in the preceding table is a compile-time constant.
3737
In [unsafe](../keywords/unsafe.md) code, you can use `sizeof` on any non-`void` type, including types constructed from type parameters.
3838

3939
> [!NOTE]
40-
> Beginning with C# 15, the [unsafe evolution](../unsafe-code.md#unsafe-evolution-preview) preview feature lets you use `sizeof` on any unmanaged type outside an `unsafe` context.
40+
> Beginning with C# 15, the [memory safety](../unsafe-code.md#memory-safety-preview) preview feature lets you use `sizeof` on any unmanaged type outside an `unsafe` context.
4141
4242
- The size of a reference or pointer type is the size of a reference or pointer, not the size of the object it might refer to.
4343
- The size of a value type, unmanaged or not, is the size of such a value.

docs/csharp/language-reference/operators/stackalloc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can assign the result of a `stackalloc` expression to a variable of one of t
3939
As the preceding example shows, you must use an `unsafe` context when you work with pointer types.
4040

4141
> [!NOTE]
42-
> Beginning with C# 15, the [unsafe evolution](../unsafe-code.md#unsafe-evolution-preview) preview feature lets you convert a `stackalloc` expression to a pointer outside an `unsafe` context. Operations that access the allocated memory through the pointer still require an `unsafe` context.
42+
> Beginning with C# 15, the [memory safety](../unsafe-code.md#memory-safety-preview) preview feature lets you convert a `stackalloc` expression to a pointer outside an `unsafe` context. Operations that access the allocated memory through the pointer still require an `unsafe` context.
4343
4444
For pointer types, you can use a `stackalloc` expression only in a local variable declaration to initialize the variable.
4545

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Entry point so the snippet project produces an executable and is verified by a build.
2+
MemorySafety.Relaxations.CreatePointer();
3+
MemorySafety.Relaxations.PinArray([1, 2, 3]);
4+
MemorySafety.Relaxations.AllocateOnStack();
5+
System.Console.WriteLine(MemorySafety.Relaxations.SizeOfStruct());
6+
System.Console.WriteLine(MemorySafety.Relaxations.ReadValue([10, 20, 30]));

docs/csharp/language-reference/snippets/unsafe-evolution/Relaxations.cs renamed to docs/csharp/language-reference/snippets/memory-safety/Relaxations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// This file demonstrates the C# 15 unsafe evolution relaxations verified against
1+
// This file demonstrates the C# 15 memory safety relaxations verified against
22
// .NET 11 Preview 5. Creating pointers, the fixed statement, stackalloc-to-pointer,
33
// and sizeof no longer require an unsafe context. Only operations that access the
44
// pointed-to memory still require one.
55

6-
namespace UnsafeEvolution;
6+
namespace MemorySafety;
77

88
public class Relaxations
99
{

docs/csharp/language-reference/snippets/unsafe-evolution/unsafe-evolution.csproj renamed to docs/csharp/language-reference/snippets/memory-safety/memory-safety.csproj

File renamed without changes.

docs/csharp/language-reference/snippets/unsafe-evolution/Program.cs

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/csharp/language-reference/statements/fixed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The `fixed` statement prevents the [garbage collector](../../../standard/garbage
2121
> You can use the `fixed` statement only in an [unsafe](../keywords/unsafe.md) context. The code that contains unsafe blocks must be compiled by using the [**AllowUnsafeBlocks**](../compiler-options/language.md#allowunsafeblocks) compiler option.
2222
2323
> [!NOTE]
24-
> Beginning with C# 15, the [unsafe evolution](../unsafe-code.md#unsafe-evolution-preview) preview feature lets you use the `fixed` statement outside an `unsafe` context. Only operations that access the pinned memory through the pointer, such as pointer indirection, still require an `unsafe` context.
24+
> Beginning with C# 15, the [memory safety](../unsafe-code.md#memory-safety-preview) preview feature lets you use the `fixed` statement outside an `unsafe` context. Only operations that access the pinned memory through the pointer, such as pointer indirection, still require an `unsafe` context.
2525
2626
You can initialize the declared pointer as follows:
2727

0 commit comments

Comments
 (0)