SqlBatch.ValidateExecuteCommandBehavior XML comment says NotSupportedException but code throws ArgumentOutOfRangeException
I maintainer di solito rispondono entro 2 giorni
Valutazione
- Difficoltà
- 1/5
- Tempo stimato
- Meno di un'ora
- Idoneità per principianti
- 90/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- csharp
- Ambito
- databases, documentation
Direzione di ricerca
Inizia dal commento /// su ValidateExecuteCommandBehavior in src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlBatch.cs (intorno alla riga 382) e controlla l'helper NotSupportedCommandBehavior in AdapterUtil.cs, che restituisce ArgumentOutOfRangeException. Esegui SqlBatchTest.cs in tests/UnitTests (righe 22 e 32) per confermare il tipo atteso. È fatto quando il cref indica ArgumentOutOfRangeException e i test unitari continuano a passare; la formulazione in doc/snippets SqlBatch.xml è facoltativa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The /// comment on SqlBatch.ValidateExecuteCommandBehavior documents the wrong exception type.
/// <exception cref="NotSupportedException">Thrown when unsupported behavior flags are detected.</exception>
internal static void ValidateExecuteCommandBehavior(string method, CommandBehavior behavior)
The method throws through ADP.NotSupportedCommandBehavior (line 388), which returns an ArgumentOutOfRangeException (AdapterUtil.cs line 1333):
internal static ArgumentOutOfRangeException NotSupportedCommandBehavior(CommandBehavior value, string method)
=> NotSupportedEnumerationValue(typeof(CommandBehavior), value.ToString(), method);
The unit tests assert ArgumentOutOfRangeException for both an invalid value and a valid but unsupported value such as CommandBehavior.KeyInfo (SqlBatchTest.cs lines 22 and 32).
The method is called from ExecuteReader and ExecuteReaderAsync, so callers passing KeyInfo, SchemaOnly, SingleResult, or SingleRow get ArgumentOutOfRangeException. Accepted values are Default, SequentialAccess, CloseConnection, and SequentialAccess | CloseConnection.
Suggested fix
- Change the cref on line 382 to
ArgumentOutOfRangeException. - Optional: in
doc/snippets/Microsoft.Data.SqlClient/SqlBatch.xml, the public docs listArgumentException("The CommandBehavior value is invalid."). That is accurate because it's the base class, butArgumentOutOfRangeExceptionis more specific. The same file says "Only SequentialAccess and CloseConnection are supported at the batch level" and doesn't mention thatDefaultis also accepted.
The helper name NotSupportedCommandBehavior likely caused the mismatch. Renaming it is out of scope here; it's also used by SqlCommandSet.
Found while documenting SqlBatch behavior in the SqlClient docs on Microsoft Learn.
- Lingua principale
- C#
- Stelle
- 996
- Fork
- 351
- Merge medio
- 4g 20h
- PR unite (30g)
- 67
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di dotnet/SqlClient
-
Sync ExecuteReader on an STA thread deadlocks against a StateChange handler that marshals to the UI thread (OpenAsyncRetry path)Forse di nuovo libera @mdaigle l’ha presa 37 giorni fa e non c’è nessuna pull request aperta. ApertaExternal :link:
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
dotnet/SqlClient#4534 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 2 giorni
-
Area\Tests
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
dotnet/SqlClient#4377 · 2 commenti ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 2 giorni
-
[7.1] Backport #4875Aperta:new: Triage Needed
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
I maintainer di solito rispondono entro 2 giorni
-
[7.0] Backport #4875Aperta:new: Triage Needed
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di dotnet/SqlClient
Issue simili
-
fix(testing): HeadlessTerminal disposes services synchronouslyForse già presa @zidad l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
RazorConsole/RazorConsole#388 ·
I maintainer di solito rispondono entro 1 giorno
-
A practical example of rulerAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
starlinghq/starling#209 ·
I maintainer di solito rispondono entro 1 giorno
-
affected/v17 area/frontend type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
umbraco/Umbraco-CMS#24323 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
dotnet/roslynator#1859 ·
I maintainer di solito rispondono entro 1 giorno