Skip to content

Commit

Permalink
fix build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
BillWagner committed Jul 2, 2024
1 parent 045d298 commit 97761c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .openpublishing.redirection.csharp.json
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,10 @@
"source_path_from_root": "/docs/csharp/misc/cs1629.md",
"redirect_url": "/dotnet/csharp/language-reference/compiler-messages/iterator-yield"
},
{
"source_path_from_root": "/docs/csharp/misc/cs1631.md",
"redirect_url": "/dotnet/csharp/language-reference/compiler-messages/iterator-yield"
},
{
"source_path_from_root": "/docs/csharp/misc/cs1632.md",
"redirect_url": "/dotnet/csharp/language-reference/compiler-messages/lambda-expression-errors#syntax-limitations-in-lambda-expressions"
Expand Down
35 changes: 16 additions & 19 deletions docs/csharp/language-reference/compiler-messages/iterator-yield.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,20 @@ There are numerous *errors* related to the `yield return` statement and iterator
<!-- The text in this list generates issues for Acrolinx, because they don't use contractions.
That's by design. The text closely matches the text of the compiler error / warning for SEO purposes.
-->
- [**CS1622**](#): *Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.*
- [**CS1624**](#): *The body of 'accessor' cannot be an iterator block because 'type' is not an iterator interface type*
- [**CS1625**](#): *Cannot yield in the body of a finally clause*
- [**CS1626**](#): *Cannot yield a value in the body of a try block with a catch clause*
- [**CS1627**](#): *Expression expected after yield return*
- [**CS1629**](#): *Unsafe code may not appear in iterators*
- [**CS1631**](#): *Cannot yield a value in the body of a catch clause*
- [**CS1637**](#): *Iterators cannot have unsafe parameters or yield types*
- [**CS4013**](#): *Instance of type cannot be used inside a nested function, query expression, iterator block or async method*
- [**CS8154**](#): *The body cannot be an iterator block because it returns by reference*
- [**CS8176**](#): *Iterators cannot have by-reference locals*
- [**CS9237**](#): *'yield return' should not be used in the body of a lock statement*
- [**CS9238**](#): *Cannot use 'yield return' in an 'unsafe' block*
- [**CS9239**](#): *The `&` operator cannot be used on parameters or local variables in iterator methods.*

In addition, the compiler might produce the following *warning* related to `lock` statements and thread synchronization:

- [**CS9216**](#lock-warning): *A value of type `System.Threading.Lock` converted to a different type will use likely unintended monitor-based locking in `lock` statement.*
- [**CS1622**](#compiler-error-cs1622): *Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.*
- [**CS1624**](#compiler-error-cs1624): *The body of 'accessor' cannot be an iterator block because 'type' is not an iterator interface type*
- [**CS1625**](#compiler-error-cs1625): *Cannot yield in the body of a finally clause*
- [**CS1626**](#compiler-error-cs1626): *Cannot yield a value in the body of a try block with a catch clause*
- [**CS1627**](#compiler-error-cs1627): *Expression expected after yield return*
- [**CS1629**](#compiler-error-cs1629): *Unsafe code may not appear in iterators*
- [**CS1631**](#compiler-error-cs1631): *Cannot yield a value in the body of a catch clause*
- [**CS1637**](#compiler-error-cs1637): *Iterators cannot have unsafe parameters or yield types*
- [**CS4013**](#compiler-error-cs4013): *Instance of type cannot be used inside a nested function, query expression, iterator block or async method*
- [**CS8154**](#compiler-error-cs8154): *The body cannot be an iterator block because it returns by reference*
- [**CS8176**](#compiler-error-cs8176): *Iterators cannot have by-reference locals*
- [**CS9237**](#new-errors): *'yield return' should not be used in the body of a lock statement*
- [**CS9238**](#new-errors): *Cannot use 'yield return' in an 'unsafe' block*
- [**CS9239**](#new-errors): *The `&` operator cannot be used on parameters or local variables in iterator methods.*

## Compiler Error CS1622

Expand Down Expand Up @@ -232,7 +228,7 @@ class C
}
```

# Compiler Error CS1631
## Compiler Error CS1631

Cannot yield a value in the body of a catch clause

Expand Down Expand Up @@ -476,6 +472,7 @@ class C
}
}
```

## New errors

- **CS9237**: *''yield return' should not be used in the body of a lock statement*
Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/language-reference/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ items:
CS9093, CS9094, CS9095, CS9096, CS9097, CS9101, CS9102, CS9104, CS9190, CS9191, CS9192, CS9193, CS9195, CS9196, CS9197,
CS9198, CS9199, CS9200, CS9201
- name: Iterator methods
href: ./iterator-yield.md
href: ./compiler-messages/iterator-yield.md
displayName: >
yield return, yield break,
CS1622, CS1624, CS1625, CS1626, CS1627, CS1629, CS1631, CS1637, CS4013, CS8154, CS8176, CS9237, CS9238, CS9239
Expand Down

0 comments on commit 97761c2

Please sign in to comment.