forked from dotnet/docs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create CS8964 * Add entry to `toc.yml` * Minor nit on CS8964
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
docs/csharp/language-reference/compiler-messages/cs8964.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--- | ||
description: "Compiler Error CS8964" | ||
title: "Compiler Error CS8964" | ||
ms.date: 9/28/2023 | ||
f1_keywords: | ||
- "CS8964" | ||
helpviewer_keywords: | ||
- "CS8964" | ||
--- | ||
# Compiler Error CS8964 | ||
|
||
The `CallerArgumentExpressionAttribute` may only be applied to parameters with default values. | ||
|
||
## Example | ||
|
||
The following sample generates CS8964: | ||
|
||
```csharp | ||
// CS8964.cs (6,44) | ||
using System.Runtime.CompilerServices; | ||
|
||
class C | ||
{ | ||
public void Predicate(bool condition, [CallerArgumentExpression("condition")] string conditionExpr) {} | ||
} | ||
``` | ||
|
||
## To correct this error | ||
|
||
Add a default value to the affected parameters: | ||
|
||
```csharp | ||
using System.Runtime.CompilerServices; | ||
|
||
class C | ||
{ | ||
public void Predicate(bool condition, [CallerArgumentExpression("condition")] string? conditionExpr = null) {} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters