Skip to content

Commit

Permalink
Replace "auto implemented" with "automatically" (#43211)
Browse files Browse the repository at this point in the history
* Replace "auto implemented" with "automatically"

Fixes #42252

In preparation for "field backed properties", make sure all our docs use the correct "automatically implemented" terminology.

Because, field backed properties are kind of auto-implemented as well.

I did update the VB docs as well, to keep them consistent.

* fix the warnings

* Apply suggestions from code review

Co-authored-by: Genevieve Warren <[email protected]>

---------

Co-authored-by: Genevieve Warren <[email protected]>
  • Loading branch information
BillWagner and gewarren authored Oct 25, 2024
1 parent 56d4947 commit ed97bb1
Show file tree
Hide file tree
Showing 46 changed files with 110 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ In **Solution Explorer**, right-click the **ThisAddIn.cs** file and then select

## Create a list of bank accounts

In **Solution Explorer**, right-click your project's name, select **Add**, and then select **Class**. Name the class Account.cs. Select **Add**. Replace the definition of the `Account` class with the following code. The class definitions use *auto-implemented properties*.
In **Solution Explorer**, right-click your project's name, select **Add**, and then select **Class**. Name the class Account.cs. Select **Add**. Replace the definition of the `Account` class with the following code. The class definitions use *automatically implemented properties*.

:::code language="csharp" source="./snippets/OfficeWalkthrough/account.cs" id="AccountClass":::

Expand Down Expand Up @@ -122,13 +122,13 @@ In Visual Studio, select **Clean Solution** on the **Build** menu. Otherwise, th

## See also

- [Auto-Implemented Properties (C#)](../../programming-guide/classes-and-structs/auto-implemented-properties.md)
- [Object and Collection Initializers](../../programming-guide/classes-and-structs/object-and-collection-initializers.md)
- [Automatically implemented properties (C#)](../../programming-guide/classes-and-structs/auto-implemented-properties.md)
- [Object and collection initializers](../../programming-guide/classes-and-structs/object-and-collection-initializers.md)
- [Visual Studio Tools for Office (VSTO)](/visualstudio/vsto/visual-studio-tools-for-office-runtime-overview)
- [Named and Optional Arguments](../../programming-guide/classes-and-structs/named-and-optional-arguments.md)
- [Named and optional arguments](../../programming-guide/classes-and-structs/named-and-optional-arguments.md)
- [dynamic](../../language-reference/builtin-types/reference-types.md)
- [Using Type dynamic](using-type-dynamic.md)
- [Lambda Expressions (C#)](../../language-reference/operators/lambda-expressions.md)
- [Walkthrough: Embedding Type Information from Microsoft Office Assemblies in Visual Studio](/previous-versions/visualstudio/visual-studio-2013/ee317478(v=vs.120))
- [Walkthrough: Embedding Types from Managed Assemblies](../../../standard/assembly/embed-types-visual-studio.md)
- [Walkthrough: Creating Your First VSTO Add-in for Excel](/visualstudio/vsto/walkthrough-creating-your-first-vsto-add-in-for-excel)
- [Using type dynamic](using-type-dynamic.md)
- [Lambda expressions (C#)](../../language-reference/operators/lambda-expressions.md)
- [Walkthrough: Embedding type information from Microsoft Office assemblies in Visual Studio](/previous-versions/visualstudio/visual-studio-2013/ee317478(v=vs.120))
- [Walkthrough: Embedding types from managed assemblies](../../../standard/assembly/embed-types-visual-studio.md)
- [Walkthrough: Creating your first VSTO add-in for Excel](/visualstudio/vsto/walkthrough-creating-your-first-vsto-add-in-for-excel)
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ The list of possible `target` values is shown in the following table.
| `return` | Return value of a method, property indexer, or `get` property accessor |
| `type` | Struct, class, interface, enum, or delegate |

You would specify the `field` target value to apply an attribute to the backing field created for an [auto-implemented property](../../programming-guide/classes-and-structs/properties.md).
You would specify the `field` target value to apply an attribute to the backing field created for an [automatically implemented property](../../programming-guide/classes-and-structs/properties.md).

The following example shows how to apply attributes to assemblies and modules. For more information, see [Common Attributes (C#)](../../language-reference/attributes/global.md).

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/fundamentals/types/interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ helpviewer_keywords:
---
# Interfaces - define behavior for multiple types

An interface contains definitions for a group of related functionalities that a non-abstract [`class`](../../language-reference/keywords/class.md) or a [`struct`](../../language-reference/builtin-types/struct.md) must implement. An interface may define `static` methods, which must have an implementation. An interface may define a default implementation for members. An interface may not declare instance data such as fields, auto-implemented properties, or property-like events.
An interface contains definitions for a group of related functionalities that a non-abstract [`class`](../../language-reference/keywords/class.md) or a [`struct`](../../language-reference/builtin-types/struct.md) must implement. An interface may define `static` methods, which must have an implementation. An interface may define a default implementation for members. An interface may not declare instance data such as fields, automatically implemented properties, or property-like events.

By using interfaces, you can, for example, include behavior from multiple sources in a class. That capability is important in C# because the language doesn't support multiple inheritance of classes. In addition, you must use an interface if you want to simulate inheritance for structs, because they can't actually inherit from another struct or class.

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/how-to/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ There are several tips and tricks that are common C# developer practices:

You create classes, records, and structs to implement your program. These techniques are commonly used when writing classes, records, or structs.

- [Declare auto implemented properties](../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md).
- [Declare automatically implemented properties](../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md).
- [Declare and use read/write properties](../programming-guide/classes-and-structs/how-to-declare-and-use-read-write-properties.md).
- [Define constants](../programming-guide/classes-and-structs/how-to-define-constants.md).
- [Override the `ToString` method to provide string output](../programming-guide/classes-and-structs/how-to-override-the-tostring-method.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/attributes/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ If <xref:System.AttributeUsageAttribute.Inherited> is `false`, then derived clas

In this case, `NonInheritedAttribute` isn't applied to `DClass` via inheritance.

You can also use these keywords to specify where an attribute should be applied. For example, you can use the `field:` specifier to add an attribute to the backing field of an [autoimplemented property](../../programming-guide/classes-and-structs/properties.md#auto-implemented-properties). Or you can use the `field:`, `property:` or `param:` specifier to apply an attribute to any of the elements generated from a positional record. For an example, see [Positional syntax for property definition](../builtin-types/record.md#positional-syntax-for-property-definition).
You can also use these keywords to specify where an attribute should be applied. For example, you can use the `field:` specifier to add an attribute to the backing field of an [automatically implemented property](../../programming-guide/classes-and-structs/properties.md#automatically-implemented-properties). Or you can use the `field:`, `property:` or `param:` specifier to apply an attribute to any of the elements generated from a positional record. For an example, see [Positional syntax for property definition](../builtin-types/record.md#positional-syntax-for-property-definition).

## `AsyncMethodBuilder` attribute

Expand Down
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/builtin-types/struct.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Because structure types have value semantics, we recommend you define *immutable
You use the `readonly` modifier to declare that a structure type is immutable. All data members of a `readonly` struct must be read-only as follows:

- Any field declaration must have the [`readonly` modifier](../keywords/readonly.md)
- Any property, including auto-implemented ones, must be read-only or [`init` only](../keywords/init.md). Note that init-only setters are only available from [C# version 9 onwards](../../whats-new/csharp-version-history.md).
- Any property, including automatically implemented ones, must be read-only or [`init` only](../keywords/init.md). Note that init-only setters are only available from [C# version 9 onwards](../../whats-new/csharp-version-history.md).

That guarantees that no member of a `readonly` struct modifies the state of the struct. That means that other instance members except constructors are implicitly [`readonly`](#readonly-instance-members).

Expand Down Expand Up @@ -62,7 +62,7 @@ Typically, you apply the `readonly` modifier to the following kinds of instance
If you need to apply the `readonly` modifier to both accessors of a property or indexer, apply it in the declaration of the property or indexer.

> [!NOTE]
> The compiler declares a `get` accessor of an [auto-implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) as `readonly`, regardless of presence of the `readonly` modifier in a property declaration.
> The compiler declares a `get` accessor of an [automatically implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) as `readonly`, regardless of presence of the `readonly` modifier in a property declaration.
You may apply the `readonly` modifier to a property or indexer with an `init` accessor:

Expand Down
4 changes: 2 additions & 2 deletions docs/csharp/language-reference/compiler-messages/cs0840.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ms.assetid: f307083f-8d86-4142-a9fd-b735910687b2

'Property name' must declare a body because it is not marked abstract or extern. Automatically implemented properties must define both get and set accessors.

Unless a regular property is marked as `abstract` or `extern`, or is a member of a `partial` type, it must supply a body. Auto-implemented properties do not provide accessor bodies, but they must specify both accessors. To create a read-only auto-implemented property, make the set accessor `private`.
Unless a regular property is marked as `abstract` or `extern`, or is a member of a `partial` type, it must supply a body. Automatically implemented properties do not provide accessor bodies, but they must specify both accessors. To create a read-only automatically implemented property, make the set accessor `private`.

## To correct this error

Expand All @@ -39,4 +39,4 @@ class Test

## See also

- [Auto-Implemented Properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md)
- [Automatically implemented properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md)
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/compiler-messages/cs8145.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords:

Auto-implemented properties cannot return by reference

Auto-implemented properties are not guaranteed to have a member or variable that can be referenced and thus do not support return by reference.
Automatically implemented properties are not guaranteed to have a member or variable that can be referenced and thus do not support return by reference.

## Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,4 @@ The following warning indicates a signature difference in the declaring and impl

- **CS9256**: *Partial property declarations have signature differences.*

A partial property or indexer must have both a *declaring declaration* and an *implementing declaration*. The signatures for both declarations must match. Because the *declaring declaration* uses the same syntax as an auto-implemented property, the *implementing declaration* can't be an auto-implemented property. The accessors must have bodies.
A partial property or indexer must have both a *declaring declaration* and an *implementing declaration*. The signatures for both declarations must match. Because the *declaring declaration* uses the same syntax as an automatically implemented property, the *implementing declaration* can't be an automatically implemented property. The accessors must have bodies.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ms.date: 07/30/2024

A [`ref struct`](../builtin-types/ref-struct.md) type can include `ref` fields. Other types aren't allowed `ref` fields. The compiler enforces restrictions on the declarations and use of `ref struct` types to enforce ref safety rules on instances of any `ref struct` type:

- Only `ref struct` types can contain auto-implemented `ref` properties.
- Only `ref struct` types can contain automatically implemented `ref` properties.
- Only `ref struct` types or `ref` variables can have the `scoped` modifier.
- A `ref` field can be declared only in a `ref struct` type.
- A `ref` field can't refer to a `ref struct` type/
Expand Down
6 changes: 3 additions & 3 deletions docs/csharp/language-reference/keywords/get.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ helpviewer_keywords:
---
# get (C# Reference)

The `get` keyword defines an *accessor* method in a property or indexer that returns the property value or the indexer element. For more information, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Auto-Implemented Properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md).
The `get` keyword defines an *accessor* method in a property or indexer that returns the property value or the indexer element. For more information, see [Properties](../../programming-guide/classes-and-structs/properties.md), [Automatically implemented Properties](../../programming-guide/classes-and-structs/automatically implemented-properties.md), and [Indexers](../../programming-guide/indexers/index.md).

The following example defines both a `get` and a `set` accessor for a property named `Seconds`. It uses a private field named `_seconds` to back the property value.

Expand All @@ -20,12 +20,12 @@ Often, the `get` accessor consists of a single statement that returns a value, a

:::code language="csharp" source="./snippets/PropertyAccessors.cs" id="GetSetExpressions":::

For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for auto-implemented properties. The following example implements `Hours` as an auto-implemented property.
For simple cases in which a property's `get` and `set` accessors perform no other operation than setting or retrieving a value in a private backing field, you can take advantage of the C# compiler's support for automatically implemented properties. The following example implements `Hours` as an automatically implemented property.

:::code language="csharp" source="./snippets/PropertyAccessors.cs" id="AutoImplementedProperties":::

> [!IMPORTANT]
> Auto-implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or [partial property declarations](./partial-member.md). In both cases, the compiler interprets syntax matching an auto-implemented property as the declaring declaration, not an implementing declaration.
> Automatically implemented properties aren't allowed for [interface property declarations](../../programming-guide/classes-and-structs/interface-properties.md) or the implementing declaration for a [partial property](./partial-member.md). The compiler interprets syntax matching an automatically implemented property as the declaring declaration, not an implementing declaration.
## C# Language Specification

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/keywords/group-clause.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Use a composite key when you want to group elements according to more than one k
group person by new {name = person.surname, city = person.city};
```

Use a named type if you must pass the query variable to another method. Create a special class using auto-implemented properties for the keys, and then override the <xref:System.Object.Equals%2A> and <xref:System.Object.GetHashCode%2A> methods. You can also use a struct, in which case you do not strictly have to override those methods. For more information see [How to implement a lightweight class with auto-implemented properties](../../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md) and [How to query for duplicate files in a directory tree](../../linq/how-to-query-files-and-directories.md). The latter article has a code example that demonstrates how to use a composite key with a named type.
Use a named type if you must pass the query variable to another method. Create a special class using automatically implemented properties for the keys, and then override the <xref:System.Object.Equals%2A> and <xref:System.Object.GetHashCode%2A> methods. You can also use a struct, in which case you do not strictly have to override those methods. For more information see [How to implement a lightweight class with automatically implemented properties](../../programming-guide/classes-and-structs/how-to-implement-a-lightweight-class-with-auto-implemented-properties.md) and [How to query for duplicate files in a directory tree](../../linq/how-to-query-files-and-directories.md). The latter article has a code example that demonstrates how to use a composite key with a named type.

## Example 1

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/keywords/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords:
# init (C# Reference)

The `init` keyword defines an *accessor* method in a property or indexer. An init-only setter assigns a value to the property or the indexer element **only** during object construction. An `init` enforces immutability, so that once the object is initialized, it can't be changed. An `init` accessor enables calling code to use an [object initializer](../../programming-guide/classes-and-structs/how-to-initialize-objects-by-using-an-object-initializer.md) to set the initial value. As a contrast, an
[auto-implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) with only a `get` setter must be initialized by calling a constructor. A property with a `private set` accessor can be modified after construction, but only in the class.
[automatically implemented property](../../programming-guide/classes-and-structs/auto-implemented-properties.md) with only a `get` setter must be initialized by calling a constructor. A property with a `private set` accessor can be modified after construction, but only in the class.

The following example defines both a `get` and an `init` accessor for a property named `YearOfBirth`. It uses a private field named `_yearOfBirth` to back the property value.

Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/keywords/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can try this feature by working with the tutorial on [static abstract member

## Interface inheritance

Interfaces may not contain instance state. While static fields are now permitted, instance fields aren't permitted in interfaces. [Instance auto-properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) aren't supported in interfaces, as they would implicitly declare a hidden field. This rule has a subtle effect on property declarations. In an interface declaration, the following code doesn't declare an auto-implemented property as it does in a `class` or `struct`. Instead, it declares a property that doesn't have a default implementation but must be implemented in any type that implements the interface:
Interfaces may not contain instance state. While static fields are now permitted, instance fields aren't permitted in interfaces. [Instance auto-properties](../../programming-guide/classes-and-structs/auto-implemented-properties.md) aren't supported in interfaces, as they would implicitly declare a hidden field. This rule has a subtle effect on property declarations. In an interface declaration, the following code doesn't declare an automatically implemented property as it does in a `class` or `struct`. Instead, it declares a property that doesn't have a default implementation but must be implemented in any type that implements the interface:

```csharp
public interface INamed
Expand Down
Loading

0 comments on commit ed97bb1

Please sign in to comment.