Skip to content

Commit

Permalink
Create CS8964 (dotnet#37291)
Browse files Browse the repository at this point in the history
* Create CS8964

* Add entry to `toc.yml`

* Minor nit on CS8964
  • Loading branch information
Rageking8 authored Sep 28, 2023
1 parent b4f34d1 commit be15b1c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions docs/csharp/language-reference/compiler-messages/cs8964.md
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) {}
}
```
2 changes: 2 additions & 0 deletions docs/csharp/language-reference/compiler-messages/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,8 @@ items:
href: cs1610.md
- name: CS1712
href: ../../misc/cs1712.md
- name: CS8964
href: CS8964.md
- name: Feature or version missing
href: feature-version-errors.md
displayName: CS0171, CS0188, CS0843, CS8904, CS1738, CS8022, CS8023, CS8024, CS8025, CS8026, CS8059, CS8107, CS8302, CS8320, CS8370, CS8400, CS8773, CS8936, CS9058, CS8303, CS8304, CS8306, CS8371, CS8401, CS8511, CS8192, CS8627, CS8630, CS8314, CS8652, CS8703, CS8704, CS8706, CS8957, CS8912, CS9014, CS9015, CS9016, CS9017, CS8967
Expand Down

0 comments on commit be15b1c

Please sign in to comment.