[AI Task] Fault NfcTag transceive/read NDEF tasks on native error and remove double dictionary lookup - #7774
[AI Task] Fault NfcTag transceive/read NDEF tasks on native error and remove double dictionary lookup#7774JoonghyunCho wants to merge 2 commits into
Conversation
… double dictionary lookup (Fixes #7675)
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
|
| } | ||
| else | ||
| { | ||
| taskSource.TrySetException(new InvalidOperationException(((NfcError)result).ToString())); |
There was a problem hiding this comment.
🤖 [AI Review]
🟡 Suggestion: Faulting with a hardcoded InvalidOperationException bypasses the NfcErrorFactory mapping used by every synchronous error path in this file (NotSupportedError → NotSupportedException, InvalidParameterError → ArgumentException, both documented on TransceiveAsync), and drops the Log.Error parity of the other error branches.
| taskSource.TrySetException(new InvalidOperationException(((NfcError)result).ToString())); | |
| Log.Error(Globals.LogTag, $"Failed to transceive data, Error - {(NfcError)result}"); | |
| try | |
| { | |
| NfcErrorFactory.ThrowNfcException(result); | |
| } | |
| catch (Exception e) | |
| { | |
| taskSource.TrySetException(e); | |
| } |
There was a problem hiding this comment.
🤖 [AI Review]
Addressed in efeb1a1 — the transceive error path now logs the failure and routes the native result through NfcErrorFactory.ThrowNfcException, so the faulted exception type matches the documented contract.
| } | ||
| else | ||
| { | ||
| taskSource.TrySetException(new InvalidOperationException(((NfcError)result).ToString())); |
There was a problem hiding this comment.
🤖 [AI Review]
🟡 Suggestion: Same as TransceiveCompletedCallback — routing the error through NfcErrorFactory keeps the faulted exception type consistent with the documented contract and restores Log.Error parity.
| taskSource.TrySetException(new InvalidOperationException(((NfcError)result).ToString())); | |
| Log.Error(Globals.LogTag, $"Failed to read ndef message, Error - {(NfcError)result}"); | |
| try | |
| { | |
| NfcErrorFactory.ThrowNfcException(result); | |
| } | |
| catch (Exception e) | |
| { | |
| taskSource.TrySetException(e); | |
| } |
There was a problem hiding this comment.
🤖 [AI Review]
Addressed in efeb1a1 — the read-NDEF error path now logs the failure and routes the native result through NfcErrorFactory.ThrowNfcException, matching TransceiveCompletedCallback.
|
🤖 [AI Review] Automated review by AI assistant |
Route native errors through NfcErrorFactory in TransceiveCompletedCallback and ReadNdefCallback to keep faulted exception types consistent with the documented contract and restore Log.Error parity Applied-AI-Comments: 3653647061,3653647146
Summary
Fixes a silent-failure bug in the NFC tag async callbacks: when the native transceive or NDEF-read completed with an error, the
TaskCompletionSourcewas removed from the tracking dictionary without ever being completed, so awaitingTransceiveAsync()/ReadNdefMessageAsync()hung forever and the captured async state machine, TCS, and buffers leaked. The callbacks now fault the task withInvalidOperationException(consistent with the documented exception contract and with the write/format paths). The redundantContainsKey+ indexer double lookup is also collapsed into a singleTryGetValue.Changes
src/Tizen.Network.Nfc/Tizen.Network.Nfc/NfcTag.csTransceiveCompletedCallback:ContainsKey+ indexer →TryGetValue; on non-Noneresult,TrySetException(new InvalidOperationException(((NfcError)result).ToString()))so the awaiting caller faults instead of hanging.ReadNdefCallback: same treatment; the callback'sboolreturn value on error is unchanged (false).VoidCallback(already completes its TCS on every result) are untouched.Mode
Refactoring
Verification
dotnet build src/Tizen.Network.Nfc/Tizen.Network.Nfc.csproj— 0 errors, 0 warnings)API Compatibility
Tasknow faults, matching the documentedInvalidOperationExceptioncontract, instead of never completing; success path is byte-for-byte identical.Fixes #7675