Skip to content

Commit b503300

Browse files
BillWagnerpkulikov
andauthored
Remove references to "new" features introduced before C# 9 (#31333)
* Remove "beginning in C# 2" Remove any version consideration for a feature that was introduced in C# 2. In once instance, the description of delegate creation discussed syntax added in C# 3. Remove that as well. * Remove references to C# 3 Several COM / Office interop samples show the syntax used before C# 4.0 Several reference to LINQ introduce it as a "new" feature. * Remove "new" references to C# 4 features These are mostly dynamic and COM interop features. * Remove references to "new" C# 5. When describing any features in C#, remove the version information. * remove references to "new" in C# 6 features. They are not "new" as of C# 11. * Remove references to C# 7.x as "new" features New features in C# 7 aren't "new" anymore. * Remove references to C# 8 as "new" features They are just C# features now. * fix markdown lint issue * add expected errors. This reverts commit 4cafd60. * add notes in code files for CI build error suppression * Apply suggestions from code review Co-authored-by: Petr Kulikov <[email protected]> Co-authored-by: Petr Kulikov <[email protected]>
1 parent c802a0c commit b503300

File tree

122 files changed

+451
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+451
-449
lines changed

docs/csharp/expression-trees-building.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ represented not by their C# constructs, but by constructs that represent the und
208208
logic that the compiler generates from these higher level constructs.
209209

210210
Also, at this time, there are C# expressions that cannot be built directly
211-
using `Expression` class methods. In general, these will be the newest operators
212-
and expressions added in C# 5 and C# 6. (For example, `async` expressions cannot be built, and
211+
using `Expression` class methods. In general, these will be the any operators
212+
and expressions added in C# 5 and more recent versions. (For example, `async` expressions cannot be built, and
213213
the new `?.` operator cannot be directly created.)
214214

215215
[Next -- Translating Expressions](expression-trees-translating.md)

docs/csharp/expression-trees-summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ translate that algorithm into another language or environment.
2626
There are some newer C# language elements that don't translate
2727
well into expression trees. Expression trees cannot contain
2828
`await` expressions, or `async` lambda expressions. Many of the
29-
features added in the C# 6 release don't appear exactly as written
29+
features added in C# 6 and later don't appear exactly as written
3030
in expression trees. Instead, newer features will be exposed
3131
in expressions trees in the equivalent, earlier syntax. This
3232
may not be as much of a limitation as you might think. In fact,

docs/csharp/fundamentals/coding-style/coding-conventions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ The following declaration uses the full syntax.
263263

264264
:::code language="csharp" source="./snippets/coding-conventions/program.cs" id="Snippet17b":::
265265

266-
In C# 8 and later versions, use the new [`using` syntax](../../language-reference/keywords/using-statement.md) that doesn't require braces:
266+
Use the new [`using` syntax](../../language-reference/keywords/using-statement.md) that doesn't require braces:
267267

268268
:::code language="csharp" source="./snippets/coding-conventions/program.cs" id="Snippet17c":::
269269

docs/csharp/fundamentals/functional/deconstruct.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ A tuple provides a lightweight way to retrieve multiple values from a method cal
1111

1212
Retrieving multiple field and property values from an object can be equally cumbersome: you must assign a field or property value to a variable on a member-by-member basis.
1313

14-
In C# 7.0 and later, you can retrieve multiple elements from a tuple or retrieve multiple field, property, and computed values from an object in a single *deconstruct* operation. To deconstruct a tuple, you assign its elements to individual variables. When you deconstruct an object, you assign selected values to individual variables.
14+
You can retrieve multiple elements from a tuple or retrieve multiple field, property, and computed values from an object in a single *deconstruct* operation. To deconstruct a tuple, you assign its elements to individual variables. When you deconstruct an object, you assign selected values to individual variables.
1515

1616
## Tuples
1717

@@ -52,7 +52,7 @@ You must assign each element of the tuple to a variable. If you omit any element
5252

5353
## Tuple elements with discards
5454

55-
Often when deconstructing a tuple, you're interested in the values of only some elements. Starting with C# 7.0, you can take advantage of C#'s support for *discards*, which are write-only variables whose values you've chosen to ignore. A discard is chosen by an underscore character ("\_") in an assignment. You can discard as many values as you like; all are represented by the single discard, `_`.
55+
Often when deconstructing a tuple, you're interested in the values of only some elements. You can take advantage of C#'s support for *discards*, which are write-only variables whose values you've chosen to ignore. A discard is chosen by an underscore character ("\_") in an assignment. You can discard as many values as you like; all are represented by the single discard, `_`.
5656

5757
The following example illustrates the use of tuples with discards. The `QueryCityDataForYears` method returns a six-tuple with the name of a city, its area, a year, the city's population for that year, a second year, and the city's population for that second year. The example shows the change in population between those two years. Of the data available from the tuple, we're unconcerned with the city area, and we know the city name and the two dates at design-time. As a result, we're only interested in the two population values stored in the tuple, and can handle its remaining values as discards.
5858

docs/csharp/fundamentals/functional/discards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ f1_keywords:
77
---
88
# Discards - C# Fundamentals
99

10-
Starting with C# 7.0, C# supports discards, which are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; they don't have a value. A discard communicates intent to the compiler and others that read your code: You intended to ignore the result of an expression. You may want to ignore the result of an expression, one or more members of a tuple expression, an `out` parameter to a method, or the target of a pattern matching expression.
10+
Discards are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; they don't have a value. A discard communicates intent to the compiler and others that read your code: You intended to ignore the result of an expression. You may want to ignore the result of an expression, one or more members of a tuple expression, an `out` parameter to a method, or the target of a pattern matching expression.
1111

1212
Discards make the intent of your code clear. A discard indicates that our code never uses the variable. They enhance its readability and maintainability.
1313

docs/csharp/fundamentals/program-structure/main-command-line.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For information about how to write application code with an implicit entry point
3030

3131
- The `Main` method is the entry point of an executable program; it is where the program control starts and ends.
3232
- `Main` is declared inside a class or struct. `Main` must be [`static`](../../language-reference/keywords/static.md) and it need not be [`public`](../../language-reference/keywords/public.md). (In the earlier example, it receives the default access of [`private`](../../language-reference/keywords/private.md).) The enclosing class or struct is not required to be static.
33-
- `Main` can either have a `void`, `int`, or, starting with C# 7.1, `Task`, or `Task<int>` return type.
33+
- `Main` can either have a `void`, `int`, `Task`, or `Task<int>` return type.
3434
- If and only if `Main` returns a `Task` or `Task<int>`, the declaration of `Main` may include the [`async`](../../language-reference/keywords/async.md) modifier. This specifically excludes an `async void Main` method.
3535
- The `Main` method can be declared with or without a `string[]` parameter that contains command-line arguments. When using Visual Studio to create Windows applications, you can add the parameter manually or else use the <xref:System.Environment.GetCommandLineArgs> method to obtain the command-line arguments. Parameters are read as zero-indexed command-line arguments. Unlike C and C++, the name of the program is not treated as the first command-line argument in the `args` array, but it is the first element of the <xref:System.Environment.GetCommandLineArgs> method.
3636

docs/csharp/fundamentals/tutorials/pattern-matching.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.custom: contperf-fy21q1
66
---
77
# Tutorial: Use pattern matching to build type-driven and data-driven algorithms
88

9-
C# 7 introduced basic pattern matching features. Those features are extended in C# 8 through C# 10 with new expressions and patterns. You can write functionality that behaves as though you extended types that may be in other libraries. Another use for patterns is to create functionality your application requires that isn't a fundamental feature of the type being extended.
9+
You can write functionality that behaves as though you extended types that may be in other libraries. Another use for patterns is to create functionality your application requires that isn't a fundamental feature of the type being extended.
1010

1111
In this tutorial, you'll learn how to:
1212

docs/csharp/fundamentals/types/interfaces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ helpviewer_keywords:
88
---
99
# Interfaces - define behavior for multiple types
1010

11-
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. Beginning with C# 8.0, 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.
11+
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.
1212

1313
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.
1414

docs/csharp/language-reference/attributes/general.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ The first <xref:System.AttributeUsageAttribute> argument must be one or more ele
8282

8383
:::code language="csharp" source="snippets/NewPropertyOrFieldAttribute.cs" ID="SnippetDefinePropertyAttribute" :::
8484

85-
Beginning in C# 7.3, attributes can be applied to either the property or the backing field for an auto-implemented property. The attribute applies to the property, unless you specify the `field` specifier on the attribute. Both are shown in the following example:
85+
Attributes can be applied to either the property or the backing field for an auto-implemented property. The attribute applies to the property, unless you specify the `field` specifier on the attribute. Both are shown in the following example:
8686

8787
:::code language="csharp" source="snippets/NewPropertyOrFieldAttribute.cs" ID="SnippetUsePropertyAttribute" :::
8888

@@ -102,7 +102,7 @@ You can also use these keywords to specify where an attribute should be applied.
102102

103103
## `AsyncMethodBuilder` attribute
104104

105-
Beginning with C# 7, you add the <xref:System.Runtime.CompilerServices.AsyncMethodBuilderAttribute?displayProperty=nameWithType> attribute to a type that can be an async return type. The attribute specifies the type that builds the async method implementation when the specified type is returned from an async method. The `AsyncMethodBuilder` attribute can be applied to a type that:
105+
You add the <xref:System.Runtime.CompilerServices.AsyncMethodBuilderAttribute?displayProperty=nameWithType> attribute to a type that can be an async return type. The attribute specifies the type that builds the async method implementation when the specified type is returned from an async method. The `AsyncMethodBuilder` attribute can be applied to a type that:
106106

107107
* Has an accessible `GetAwaiter` method.
108108
* The object returned by the `GetAwaiter` method implements the <xref:System.Runtime.CompilerServices.ICriticalNotifyCompletion?displayProperty=nameWithType> interface.

docs/csharp/language-reference/attributes/nullable-analysis.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ These states enable the compiler to provide warnings when you may dereference a
1414

1515
This article provides a brief description of each of the nullable reference type attributes and how to use them.
1616

17-
Let's start with an example. Imagine your library has the following API to retrieve a resource string. This method was originally written before C# 8.0 and nullable annotations:
17+
Let's start with an example. Imagine your library has the following API to retrieve a resource string. This method was originally compiled in a *nullable oblivious* context:
1818

1919
:::code language="csharp" source="snippets/NullableAttributes.cs" ID="TryGetExample" :::
2020

@@ -24,7 +24,7 @@ The preceding example follows the familiar `Try*` pattern in .NET. There are two
2424
- Callers can pass a variable whose value is `null` as the argument for `message`.
2525
- If the `TryGetMessage` method returns `true`, the value of `message` isn't null. If the return value is `false,` the value of `message` is null.
2626

27-
The rule for `key` can be expressed succinctly in C# 8.0: `key` should be a non-nullable reference type. The `message` parameter is more complex. It allows a variable that is `null` as the argument, but guarantees, on success, that the `out` argument isn't `null`. For these scenarios, you need a richer vocabulary to describe the expectations. The `NotNullWhen` attribute, described below describes the *null-state* for the argument used for the `message` parameter.
27+
The rule for `key` can be expressed succinctly: `key` should be a non-nullable reference type. The `message` parameter is more complex. It allows a variable that is `null` as the argument, but guarantees, on success, that the `out` argument isn't `null`. For these scenarios, you need a richer vocabulary to describe the expectations. The `NotNullWhen` attribute, described below describes the *null-state* for the argument used for the `message` parameter.
2828

2929
> [!NOTE]
3030
> Adding these attributes gives the compiler more information about the rules for your API. When calling code is compiled in a nullable enabled context, the compiler will warn callers when they violate those rules. These attributes don't enable more checks on your implementation.

0 commit comments

Comments
 (0)