Skip to content

Commit dd7c01e

Browse files
committed
Update SA1600 documentation for covariant return types
1 parent ec05be8 commit dd7c01e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

documentation/SA1600.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,31 @@ class Car : Vehicle
8383
}
8484
```
8585

86+
Starting with C# 9, overrides can declare covariant return types. Documentation can still be inherited directly from the base member using `<inheritdoc/>`:
87+
88+
```csharp
89+
/// <summary>
90+
/// Base factory.
91+
/// </summary>
92+
class WidgetFactory
93+
{
94+
/// <summary>
95+
/// Creates a widget.
96+
/// </summary>
97+
/// <returns>The newly created <see cref="Widget"/>.</returns>
98+
public virtual Widget Create() => new Widget();
99+
}
100+
101+
/// <summary>
102+
/// Specialized factory.
103+
/// </summary>
104+
class FancyWidgetFactory : WidgetFactory
105+
{
106+
/// <inheritdoc/>
107+
public override FancyWidget Create() => new FancyWidget();
108+
}
109+
```
110+
86111
## How to suppress violations
87112

88113
```csharp

0 commit comments

Comments
 (0)