Skip to content

Commit 74f6081

Browse files
committed
markdown lint for C# 7.1 proposals
These had two sets of changes: 1. use `csharp` as the language identifier for code fences. 1. use relative links to other articles in the dotnet/csharplang repo that are being published on docs.microsoft.com so those links resolve to the article published there from that site.
1 parent 0298b86 commit 74f6081

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

proposals/csharp-7.1/async-main.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ It is very common when learning C#, when writing console-based utilities, and wh
1717
to call and `await` `async` methods from Main. Today we add a level of complexity here by forcing such `await`'ing to be
1818
done in a separate async method, which causes developers to need to write boilerplate like the following just to get
1919
started:
20-
```C#
20+
21+
```csharp
2122
public static void Main()
2223
{
2324
MainAsync().GetAwaiter().GetResult();
@@ -28,27 +29,31 @@ private static async Task MainAsync()
2829
... // Main body here
2930
}
3031
```
32+
3133
We can remove the need for this boilerplate and make it easier to get started simply by allowing Main itself to be
3234
`async` such that `await`s can be used in it.
3335

3436
## Detailed design
3537
[design]: #detailed-design
3638

3739
The following signatures are currently allowed entrypoints:
38-
```C#
40+
41+
```csharp
3942
static void Main()
4043
static void Main(string[])
4144
static int Main()
4245
static int Main(string[])
4346
```
4447

4548
We extend the list of allowed entrypoints to include:
46-
```
49+
50+
```csharp
4751
static Task Main()
4852
static Task<int> Main()
4953
static Task Main(string[])
5054
static Task<int> Main(string[])
5155
```
56+
5257
To avoid compatibility risks, these new signatures will only be considered as valid entrypoints if no overloads of the previous set are present.
5358
The language / compiler will not require that the entrypoint be marked as `async`, though we expect the vast majority of uses will be marked as such.
5459

@@ -59,7 +64,8 @@ When one of these is identified as the entrypoint, the compiler will synthesize
5964
- ```static Task<int> Main(string[])``` will result in the compiler emitting the equivalent of ```private static int $GeneratedMain(string[] args) => Main(args).GetAwaiter().GetResult();```
6065

6166
Example usage:
62-
```C#
67+
68+
```csharp
6369
using System;
6470
using System.Net.Http;
6571

@@ -81,14 +87,17 @@ The main drawback is simply the additional complexity of supporting additional e
8187
Other variants considered:
8288

8389
Allowing `async void`. We need to keep the semantics the same for code calling it directly, which would then make it difficult for a generated entrypoint to call it (no Task returned). We could solve this by generating two other methods, e.g.
84-
```C#
90+
91+
```csharp
8592
public static async void Main()
8693
{
8794
... // await code
8895
}
8996
```
97+
9098
becomes
91-
```C#
99+
100+
```csharp
92101
public static async void Main() => await $MainTask();
93102

94103
private static void $EntrypointMain() => Main().GetAwaiter().GetResult();
@@ -98,6 +107,7 @@ private static async Task $MainTask()
98107
... // await code
99108
}
100109
```
110+
101111
There are also concerns around encouraging usage of `async void`.
102112

103113
Using "MainAsync" instead of "Main" as the name. While the async suffix is recommended for Task-returning methods, that's primarily about library functionality, which Main is not, and supporting additional entrypoint names beyond "Main" is not worth it.

proposals/csharp-7.1/generics-pattern-match.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
## Summary
99
[summary]: #summary
1010

11-
The specification for the [existing C# as operator](https://github.com/dotnet/csharplang/blob/master/spec/expressions.md#the-as-operator) permits there to be no conversion between the type of the operand and the specified type when either is an open type. However, in C# 7 the `Type identifier` pattern requires there be a conversion between the type of the input and the given type.
11+
The specification for the [existing C# as operator](../../spec/expressions.md#the-as-operator) permits there to be no conversion between the type of the operand and the specified type when either is an open type. However, in C# 7 the `Type identifier` pattern requires there be a conversion between the type of the input and the given type.
1212

1313
We propose to relax this and change `expression is Type identifier`, in addition to being permitted in the conditions when it is permitted in C# 7, to also be permitted when `expression as Type` would be allowed. Specifically, the new cases are cases where the type of the expression or the specified type is an open type.
1414

proposals/csharp-7.1/infer-tuple-names.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This parallels the behavior of anonymous types, which allow inferring member na
99

1010
This is particularly handy when using tuples in LINQ:
1111

12-
```
12+
```csharp
1313
// "c" and "result" have element names "f1" and "f2"
1414
var result = list.Select(c => (c.f1, c.f2)).Where(t => t.f2 == 1);
1515
```
@@ -30,7 +30,8 @@ There are two parts to the change:
3030
Note that the rule for handling duplicates is different than that for anonymous types. For instance, `new { x.f1, x.f1 }` produces an error, but `(x.f1, x.f1)` would still be allowed (just without any inferred names). This avoids breaking existing tuple code.
3131

3232
For consistency, the same would apply to tuples produced by deconstruction-assignments (in C#):
33-
```C#
33+
34+
```csharp
3435
// tuple has element names "f1" and "f2"
3536
var tuple = ((x.f1, x?.f2) = (1, 2));
3637
```
@@ -44,7 +45,7 @@ When using the C# 7.1 compiler (or later) with language version "7.0", the eleme
4445

4546
The main drawback is that this introduces a compatibility break from C# 7.0:
4647

47-
```C#
48+
```csharp
4849
Action y = () => M();
4950
var t = (x: x, y);
5051
t.y(); // this might have previously picked up an extension method called “y”, but would now call the lambda.

0 commit comments

Comments
 (0)